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

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

Issue 2027113003: binding: Makes PrivateScriptRunner use V8PrivateProperty instead of V8HiddenValue. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h ('k') | 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"
11 #include "bindings/core/v8/V8PerIsolateData.h" 11 #include "bindings/core/v8/V8PerIsolateData.h"
12 #include "core/CoreExport.h" 12 #include "core/CoreExport.h"
13 #include "wtf/Allocator.h" 13 #include "wtf/Allocator.h"
14 #include "wtf/PtrUtil.h" 14 #include "wtf/PtrUtil.h"
15 #include <memory> 15 #include <memory>
16 #include <v8.h> 16 #include <v8.h>
17 17
18 namespace blink { 18 namespace blink {
19 19
20 class ScriptState; 20 class ScriptState;
21 class ScriptWrappable; 21 class ScriptWrappable;
22 22
23 // Apply |X| for each pair of (InterfaceName, PrivateKeyName). 23 // Apply |X| for each pair of (InterfaceName, PrivateKeyName).
24 #define V8_PRIVATE_PROPERTY_FOR_EACH(X) \ 24 #define V8_PRIVATE_PROPERTY_FOR_EACH(X) \
25 X(MessageEvent, CachedData) 25 X(MessageEvent, CachedData) \
26 X(PrivateScriptRunner, IsInitialized)
26 27
27 // The getter's name for a private property. 28 // The getter's name for a private property.
28 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \ 29 #define V8_PRIVATE_PROPERTY_GETTER_NAME(InterfaceName, PrivateKeyName) \
29 get##InterfaceName##PrivateKeyName 30 get##InterfaceName##PrivateKeyName
30 31
31 // The member variable's name for a private property. 32 // The member variable's name for a private property.
32 #define V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, PrivateKeyName) \ 33 #define V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, PrivateKeyName) \
33 m_symbol##InterfaceName##PrivateKeyName 34 m_symbol##InterfaceName##PrivateKeyName
34 35
35 // The string used to create a private symbol. Must be unique per V8 instance. 36 // The string used to create a private symbol. Must be unique per V8 instance.
(...skipping 19 matching lines...) Expand all
55 WTF_MAKE_NONCOPYABLE(V8PrivateProperty); 56 WTF_MAKE_NONCOPYABLE(V8PrivateProperty);
56 public: 57 public:
57 // Provides fast access to V8's private properties. 58 // Provides fast access to V8's private properties.
58 // 59 //
59 // Retrieving/creating a global private symbol from a string is very 60 // Retrieving/creating a global private symbol from a string is very
60 // expensive compared to get or set a private property. This class 61 // expensive compared to get or set a private property. This class
61 // provides a way to cache a private symbol and re-use it. 62 // provides a way to cache a private symbol and re-use it.
62 class CORE_EXPORT Symbol { 63 class CORE_EXPORT Symbol {
63 STACK_ALLOCATED(); 64 STACK_ALLOCATED();
64 public: 65 public:
66 bool hasValue(v8::Local<v8::Context> context, v8::Local<v8::Object> obje ct) const
67 {
68 return v8CallBoolean(object->HasPrivate(context, m_privateSymbol));
69 }
70
65 v8::Local<v8::Value> get(v8::Local<v8::Context> context, v8::Local<v8::O bject> object) const 71 v8::Local<v8::Value> get(v8::Local<v8::Context> context, v8::Local<v8::O bject> object) const
66 { 72 {
67 if (!v8CallBoolean(object->HasPrivate(context, m_privateSymbol))) 73 if (!v8CallBoolean(object->HasPrivate(context, m_privateSymbol)))
68 return v8::Local<v8::Value>(); 74 return v8::Local<v8::Value>();
69 v8::Local<v8::Value> value; 75 v8::Local<v8::Value> value;
70 if (v8Call(object->GetPrivate(context, m_privateSymbol), value)) 76 if (v8Call(object->GetPrivate(context, m_privateSymbol), value))
71 return value; 77 return value;
72 return v8::Local<v8::Value>(); 78 return v8::Local<v8::Value>();
73 } 79 }
74 80
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 132
127 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \ 133 #define V8_PRIVATE_PROPERTY_DECLARE_MEMBER(InterfaceName, KeyName) \
128 ScopedPersistent<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, KeyName); // NOLINT(readability/naming/underscores) 134 ScopedPersistent<v8::Private> V8_PRIVATE_PROPERTY_MEMBER_NAME(InterfaceName, KeyName); // NOLINT(readability/naming/underscores)
129 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER) 135 V8_PRIVATE_PROPERTY_FOR_EACH(V8_PRIVATE_PROPERTY_DECLARE_MEMBER)
130 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER 136 #undef V8_PRIVATE_PROPERTY_DECLARE_MEMBER
131 }; 137 };
132 138
133 } // namespace blink 139 } // namespace blink
134 140
135 #endif // V8PrivateProperty_h 141 #endif // V8PrivateProperty_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8HiddenValue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698