Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 V8HiddenValue_h | 5 #ifndef V8HiddenValue_h |
| 6 #define V8HiddenValue_h | 6 #define V8HiddenValue_h |
| 7 | 7 |
| 8 #include <v8.h> | |
| 9 #include <memory> | |
| 8 #include "bindings/core/v8/ScopedPersistent.h" | 10 #include "bindings/core/v8/ScopedPersistent.h" |
| 9 #include "bindings/core/v8/ScriptPromiseProperties.h" | 11 #include "bindings/core/v8/ScriptPromiseProperties.h" |
| 12 #include "bindings/core/v8/V8PerIsolateData.h" | |
| 10 #include "core/CoreExport.h" | 13 #include "core/CoreExport.h" |
| 11 #include "wtf/Allocator.h" | 14 #include "wtf/Allocator.h" |
| 12 #include "wtf/PtrUtil.h" | 15 #include "wtf/PtrUtil.h" |
| 13 #include <memory> | |
| 14 #include <v8.h> | |
| 15 | 16 |
| 16 namespace blink { | 17 namespace blink { |
| 17 | 18 |
| 18 class ScriptState; | 19 class ScriptState; |
| 19 class ScriptWrappable; | 20 class ScriptWrappable; |
| 20 | 21 |
| 21 #define V8_HIDDEN_VALUES(V) \ | 22 #define V8_HIDDEN_VALUES(V) \ |
| 22 V(customElementAttachedCallback) \ | 23 V(customElementAttachedCallback) \ |
| 23 V(customElementAttributeChangedCallback) \ | 24 V(customElementAttributeChangedCallback) \ |
| 24 V(customElementCreatedCallback) \ | 25 V(customElementCreatedCallback) \ |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 37 V(port2) \ | 38 V(port2) \ |
| 38 V(requestInFetchEvent) \ | 39 V(requestInFetchEvent) \ |
| 39 V(state) \ | 40 V(state) \ |
| 40 V(testInterfaces) \ | 41 V(testInterfaces) \ |
| 41 V(thenableHiddenPromise) \ | 42 V(thenableHiddenPromise) \ |
| 42 V(toStringString) \ | 43 V(toStringString) \ |
| 43 V(injectedScriptNative) \ | 44 V(injectedScriptNative) \ |
| 44 SCRIPT_PROMISE_PROPERTIES(V, Promise) \ | 45 SCRIPT_PROMISE_PROPERTIES(V, Promise) \ |
| 45 SCRIPT_PROMISE_PROPERTIES(V, Resolver) | 46 SCRIPT_PROMISE_PROPERTIES(V, Resolver) |
| 46 | 47 |
| 47 class CORE_EXPORT V8HiddenValue { | 48 class CORE_EXPORT V8HiddenValue : public V8PerIsolateData::Data { |
| 48 USING_FAST_MALLOC(V8HiddenValue); | 49 USING_FAST_MALLOC(V8HiddenValue); |
| 49 WTF_MAKE_NONCOPYABLE(V8HiddenValue); | 50 WTF_MAKE_NONCOPYABLE(V8HiddenValue); |
| 50 | 51 |
| 51 public: | 52 public: |
| 52 static std::unique_ptr<V8HiddenValue> create() { | 53 static void initialize(v8::Isolate* isolate) { |
| 53 return WTF::wrapUnique(new V8HiddenValue()); | 54 V8PerIsolateData::from(isolate)->setHiddenValue(new V8HiddenValue()); |
| 55 } | |
| 56 static V8HiddenValue* from(v8::Isolate* isolate) { | |
|
Yuki
2017/02/15 10:00:40
No need to expose this method as public:, I think.
| |
| 57 return static_cast<V8HiddenValue*>( | |
| 58 V8PerIsolateData::from(isolate)->hiddenValue()); | |
| 54 } | 59 } |
| 55 | 60 |
| 56 #define V8_DECLARE_METHOD(name) \ | 61 #define V8_DECLARE_METHOD(name) \ |
| 57 static v8::Local<v8::String> name(v8::Isolate* isolate); | 62 static v8::Local<v8::String> name(v8::Isolate* isolate); |
| 58 V8_HIDDEN_VALUES(V8_DECLARE_METHOD); | 63 V8_HIDDEN_VALUES(V8_DECLARE_METHOD); |
| 59 #undef V8_DECLARE_METHOD | 64 #undef V8_DECLARE_METHOD |
| 60 | 65 |
| 61 static v8::Local<v8::Value> getHiddenValue(ScriptState*, | 66 static v8::Local<v8::Value> getHiddenValue(ScriptState*, |
| 62 v8::Local<v8::Object>, | 67 v8::Local<v8::Object>, |
| 63 v8::Local<v8::String>); | 68 v8::Local<v8::String>); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 77 V8HiddenValue() {} | 82 V8HiddenValue() {} |
| 78 | 83 |
| 79 #define V8_DECLARE_FIELD(name) ScopedPersistent<v8::String> m_##name; | 84 #define V8_DECLARE_FIELD(name) ScopedPersistent<v8::String> m_##name; |
| 80 V8_HIDDEN_VALUES(V8_DECLARE_FIELD); | 85 V8_HIDDEN_VALUES(V8_DECLARE_FIELD); |
| 81 #undef V8_DECLARE_FIELD | 86 #undef V8_DECLARE_FIELD |
| 82 }; | 87 }; |
| 83 | 88 |
| 84 } // namespace blink | 89 } // namespace blink |
| 85 | 90 |
| 86 #endif // V8HiddenValue_h | 91 #endif // V8HiddenValue_h |
| OLD | NEW |