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

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

Issue 2035713002: binding: Supports V8PrivateProperty::getOrUndefined. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added function comments to explain the difference. Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 V8PrivateProperty_h 5 #ifndef V8PrivateProperty_h
6 #define V8PrivateProperty_h 6 #define V8PrivateProperty_h
7 7
8 #include "bindings/core/v8/ScopedPersistent.h" 8 #include "bindings/core/v8/ScopedPersistent.h"
9 #include "bindings/core/v8/ScriptPromiseProperties.h" 9 #include "bindings/core/v8/ScriptPromiseProperties.h"
10 #include "bindings/core/v8/V8BindingMacros.h" 10 #include "bindings/core/v8/V8BindingMacros.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // expensive compared to get or set a private property. This class 65 // expensive compared to get or set a private property. This class
66 // provides a way to cache a private symbol and re-use it. 66 // provides a way to cache a private symbol and re-use it.
67 class CORE_EXPORT Symbol { 67 class CORE_EXPORT Symbol {
68 STACK_ALLOCATED(); 68 STACK_ALLOCATED();
69 public: 69 public:
70 bool hasValue(v8::Local<v8::Context> context, v8::Local<v8::Object> obje ct) const 70 bool hasValue(v8::Local<v8::Context> context, v8::Local<v8::Object> obje ct) const
71 { 71 {
72 return v8CallBoolean(object->HasPrivate(context, m_privateSymbol)); 72 return v8CallBoolean(object->HasPrivate(context, m_privateSymbol));
73 } 73 }
74 74
75 // Returns the value of the private property if set, or undefined.
76 v8::Local<v8::Value> getOrUndefined(v8::Local<v8::Context> context, v8:: Local<v8::Object> object) const
77 {
78 return v8CallOrCrash(object->GetPrivate(context, m_privateSymbol));
79 }
80
81 // Returns the value of the private property if set, or an empty handle.
75 v8::Local<v8::Value> get(v8::Local<v8::Context> context, v8::Local<v8::O bject> object) const 82 v8::Local<v8::Value> get(v8::Local<v8::Context> context, v8::Local<v8::O bject> object) const
76 { 83 {
77 if (!v8CallBoolean(object->HasPrivate(context, m_privateSymbol))) 84 if (!v8CallBoolean(object->HasPrivate(context, m_privateSymbol)))
78 return v8::Local<v8::Value>(); 85 return v8::Local<v8::Value>();
79 v8::Local<v8::Value> value; 86 v8::Local<v8::Value> value;
80 if (v8Call(object->GetPrivate(context, m_privateSymbol), value)) 87 if (v8Call(object->GetPrivate(context, m_privateSymbol), value))
81 return value; 88 return value;
82 return v8::Local<v8::Value>(); 89 return v8::Local<v8::Value>();
83 } 90 }
84 91
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 143
137 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \ 144 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \
138 ScopedPersistent<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, KeyName); // NOLINT(readability/naming/underscores) 145 ScopedPersistent<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, KeyName); // NOLINT(readability/naming/underscores)
139 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER) 146 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER)
140 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER 147 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER
141 }; 148 };
142 149
143 } // namespace blink 150 } // namespace blink
144 151
145 #endif // V8PrivateProperty_h 152 #endif // V8PrivateProperty_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