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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/Nullable.h

Issue 2887883002: Replace ASSERT with DCHECK in Nullable (Closed)
Patch Set: Created 3 years, 7 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef Nullable_h 5 #ifndef Nullable_h
6 #define Nullable_h 6 #define Nullable_h
7 7
8 #include "platform/heap/Handle.h" 8 #include "platform/heap/Handle.h"
9 #include "platform/wtf/Assertions.h" 9 #include "platform/wtf/Assertions.h"
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 value_ = value; 45 value_ = value;
46 is_null_ = false; 46 is_null_ = false;
47 } 47 }
48 48
49 void Set(std::nullptr_t) { 49 void Set(std::nullptr_t) {
50 value_ = T(); 50 value_ = T();
51 is_null_ = true; 51 is_null_ = true;
52 } 52 }
53 53
54 const T& Get() const { 54 const T& Get() const {
55 ASSERT(!is_null_); 55 DCHECK(!is_null_);
56 return value_; 56 return value_;
57 } 57 }
58 T& Get() { 58 T& Get() {
59 ASSERT(!is_null_); 59 DCHECK(!is_null_);
60 return value_; 60 return value_;
61 } 61 }
62 bool IsNull() const { return is_null_; } 62 bool IsNull() const { return is_null_; }
63 63
64 explicit operator bool() const { return !is_null_; } 64 explicit operator bool() const { return !is_null_; }
65 65
66 bool operator==(const Nullable& other) const { 66 bool operator==(const Nullable& other) const {
67 return (is_null_ && other.is_null_) || 67 return (is_null_ && other.is_null_) ||
68 (!is_null_ && !other.is_null_ && value_ == other.value_); 68 (!is_null_ && !other.is_null_ && value_ == other.value_);
69 } 69 }
70 70
71 DEFINE_INLINE_TRACE() { TraceIfNeeded<T>::Trace(visitor, value_); } 71 DEFINE_INLINE_TRACE() { TraceIfNeeded<T>::Trace(visitor, value_); }
72 72
73 private: 73 private:
74 T value_; 74 T value_;
75 bool is_null_; 75 bool is_null_;
76 }; 76 };
77 77
78 } // namespace blink 78 } // namespace blink
79 79
80 #endif // Nullable_h 80 #endif // Nullable_h
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698