Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(140)

Side by Side Diff: webrtc/api/rtcerror.h

Issue 2762963002: Make lint errors fatal in presubmit and fix files in whitelisted paths (Closed)
Patch Set: Make lint errors fatal in presubmit Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « PRESUBMIT.py ('k') | webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2017 The WebRTC project authors. All Rights Reserved. 2 * Copyright 2017 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 template <typename U> 196 template <typename U>
197 friend class RTCErrorOr; 197 friend class RTCErrorOr;
198 198
199 public: 199 public:
200 typedef T element_type; 200 typedef T element_type;
201 201
202 // Constructs a new RTCErrorOr with RTCErrorType::INTERNAL_ERROR error. This 202 // Constructs a new RTCErrorOr with RTCErrorType::INTERNAL_ERROR error. This
203 // is marked 'explicit' to try to catch cases like 'return {};', where people 203 // is marked 'explicit' to try to catch cases like 'return {};', where people
204 // think RTCErrorOr<std::vector<int>> will be initialized with an empty 204 // think RTCErrorOr<std::vector<int>> will be initialized with an empty
205 // vector, instead of a RTCErrorType::INTERNAL_ERROR error. 205 // vector, instead of a RTCErrorType::INTERNAL_ERROR error.
206 explicit RTCErrorOr() : error_(RTCErrorType::INTERNAL_ERROR) {} 206 RTCErrorOr() : error_(RTCErrorType::INTERNAL_ERROR) {}
207 207
208 // Constructs a new RTCErrorOr with the given non-ok error. After calling 208 // Constructs a new RTCErrorOr with the given non-ok error. After calling
209 // this constructor, calls to value() will DCHECK-fail. 209 // this constructor, calls to value() will DCHECK-fail.
210 // 210 //
211 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return 211 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return
212 // value, so it is convenient and sensible to be able to do 'return 212 // value, so it is convenient and sensible to be able to do 'return
213 // RTCError(...)' when the return type is RTCErrorOr<T>. 213 // RTCError(...)' when the return type is RTCErrorOr<T>.
214 // 214 //
215 // REQUIRES: !error.ok(). This requirement is DCHECKed. 215 // REQUIRES: !error.ok(). This requirement is DCHECKed.
216 RTCErrorOr(RTCError&& error) : error_(std::move(error)) { 216 RTCErrorOr(RTCError&& error) : error_(std::move(error)) { // NOLINT
217 RTC_DCHECK(!error.ok()); 217 RTC_DCHECK(!error.ok());
218 } 218 }
219 219
220 // Constructs a new RTCErrorOr with the given value. After calling this 220 // Constructs a new RTCErrorOr with the given value. After calling this
221 // constructor, calls to value() will succeed, and calls to error() will 221 // constructor, calls to value() will succeed, and calls to error() will
222 // return a default-constructed RTCError. 222 // return a default-constructed RTCError.
223 // 223 //
224 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return type 224 // NOTE: Not explicit - we want to use RTCErrorOr<T> as a return type
225 // so it is convenient and sensible to be able to do 'return T()' 225 // so it is convenient and sensible to be able to do 'return T()'
226 // when the return type is RTCErrorOr<T>. 226 // when the return type is RTCErrorOr<T>.
227 RTCErrorOr(T&& value) : value_(std::move(value)) {} 227 RTCErrorOr(T&& value) : value_(std::move(value)) {} // NOLINT
228 228
229 // Delete the copy constructor and assignment operator; there aren't any use 229 // Delete the copy constructor and assignment operator; there aren't any use
230 // cases where you should need to copy an RTCErrorOr, as opposed to moving 230 // cases where you should need to copy an RTCErrorOr, as opposed to moving
231 // it. Can revisit this decision if use cases arise in the future. 231 // it. Can revisit this decision if use cases arise in the future.
232 RTCErrorOr(const RTCErrorOr& other) = delete; 232 RTCErrorOr(const RTCErrorOr& other) = delete;
233 RTCErrorOr& operator=(const RTCErrorOr& other) = delete; 233 RTCErrorOr& operator=(const RTCErrorOr& other) = delete;
234 234
235 // Move constructor and move-assignment operator. 235 // Move constructor and move-assignment operator.
236 // 236 //
237 // Visual Studio doesn't support "= default" with move constructors or 237 // Visual Studio doesn't support "= default" with move constructors or
238 // assignment operators (even though they compile, they segfault), so define 238 // assignment operators (even though they compile, they segfault), so define
239 // them explicitly. 239 // them explicitly.
240 RTCErrorOr(RTCErrorOr&& other) 240 RTCErrorOr(RTCErrorOr&& other)
241 : error_(std::move(other.error_)), value_(std::move(other.value_)) {} 241 : error_(std::move(other.error_)), value_(std::move(other.value_)) {}
242 RTCErrorOr& operator=(RTCErrorOr&& other) { 242 RTCErrorOr& operator=(RTCErrorOr&& other) {
243 error_ = std::move(other.error_); 243 error_ = std::move(other.error_);
244 value_ = std::move(other.value_); 244 value_ = std::move(other.value_);
245 return *this; 245 return *this;
246 } 246 }
247 247
248 // Conversion constructor and assignment operator; T must be copy or move 248 // Conversion constructor and assignment operator; T must be copy or move
249 // constructible from U. 249 // constructible from U.
250 template <typename U> 250 template <typename U>
251 RTCErrorOr(RTCErrorOr<U> other) 251 RTCErrorOr(RTCErrorOr<U> other) // NOLINT
252 : error_(std::move(other.error_)), value_(std::move(other.value_)) {} 252 : error_(std::move(other.error_)), value_(std::move(other.value_)) {}
253 template <typename U> 253 template <typename U>
254 RTCErrorOr& operator=(RTCErrorOr<U> other) { 254 RTCErrorOr& operator=(RTCErrorOr<U> other) {
255 error_ = std::move(other.error_); 255 error_ = std::move(other.error_);
256 value_ = std::move(other.value_); 256 value_ = std::move(other.value_);
257 return *this; 257 return *this;
258 } 258 }
259 259
260 // Returns a reference to our error. If this contains a T, then returns 260 // Returns a reference to our error. If this contains a T, then returns
261 // default-constructed RTCError. 261 // default-constructed RTCError.
(...skipping 29 matching lines...) Expand all
291 } 291 }
292 292
293 private: 293 private:
294 RTCError error_; 294 RTCError error_;
295 T value_; 295 T value_;
296 }; 296 };
297 297
298 } // namespace webrtc 298 } // namespace webrtc
299 299
300 #endif // WEBRTC_API_RTCERROR_H_ 300 #endif // WEBRTC_API_RTCERROR_H_
OLDNEW
« no previous file with comments | « PRESUBMIT.py ('k') | webrtc/modules/remote_bitrate_estimator/bwe_simulations.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698