| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "bindings/core/v8/ScopedPersistent.h" | 10 #include "bindings/core/v8/ScopedPersistent.h" |
| 11 #include "bindings/core/v8/ScriptPromiseProperties.h" | 11 #include "bindings/core/v8/ScriptPromiseProperties.h" |
| 12 #include "core/CoreExport.h" | 12 #include "core/CoreExport.h" |
| 13 #include "platform/wtf/Allocator.h" | 13 #include "platform/wtf/Allocator.h" |
| 14 #include "platform/wtf/PtrUtil.h" | 14 #include "platform/wtf/PtrUtil.h" |
| 15 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class ScriptState; | 19 class ScriptState; |
| 20 class ScriptWrappable; | |
| 21 | |
| 22 #define V8_HIDDEN_VALUES(V) \ | |
| 23 SCRIPT_PROMISE_PROPERTIES(V, Promise) \ | |
| 24 SCRIPT_PROMISE_PROPERTIES(V, Resolver) | |
| 25 | 20 |
| 26 class CORE_EXPORT V8HiddenValue { | 21 class CORE_EXPORT V8HiddenValue { |
| 27 USING_FAST_MALLOC(V8HiddenValue); | |
| 28 WTF_MAKE_NONCOPYABLE(V8HiddenValue); | |
| 29 | |
| 30 public: | 22 public: |
| 31 static std::unique_ptr<V8HiddenValue> create() { | |
| 32 return WTF::wrapUnique(new V8HiddenValue()); | |
| 33 } | |
| 34 | |
| 35 #define V8_DECLARE_METHOD(name) \ | |
| 36 static v8::Local<v8::String> name(v8::Isolate* isolate); | |
| 37 V8_HIDDEN_VALUES(V8_DECLARE_METHOD); | |
| 38 #undef V8_DECLARE_METHOD | |
| 39 | |
| 40 static v8::Local<v8::Value> getHiddenValue(ScriptState*, | 23 static v8::Local<v8::Value> getHiddenValue(ScriptState*, |
| 41 v8::Local<v8::Object>, | 24 v8::Local<v8::Object>, |
| 42 v8::Local<v8::String>); | 25 v8::Local<v8::String>); |
| 43 static bool setHiddenValue(ScriptState*, | 26 static bool setHiddenValue(ScriptState*, |
| 44 v8::Local<v8::Object>, | 27 v8::Local<v8::Object>, |
| 45 v8::Local<v8::String>, | 28 v8::Local<v8::String>, |
| 46 v8::Local<v8::Value>); | 29 v8::Local<v8::Value>); |
| 47 static bool deleteHiddenValue(ScriptState*, | 30 static bool deleteHiddenValue(ScriptState*, |
| 48 v8::Local<v8::Object>, | 31 v8::Local<v8::Object>, |
| 49 v8::Local<v8::String>); | 32 v8::Local<v8::String>); |
| 50 static v8::Local<v8::Value> getHiddenValueFromMainWorldWrapper( | |
| 51 ScriptState*, | |
| 52 ScriptWrappable*, | |
| 53 v8::Local<v8::String>); | |
| 54 | |
| 55 private: | |
| 56 V8HiddenValue() {} | |
| 57 | |
| 58 #define V8_DECLARE_FIELD(name) ScopedPersistent<v8::String> m_##name; | |
| 59 V8_HIDDEN_VALUES(V8_DECLARE_FIELD); | |
| 60 #undef V8_DECLARE_FIELD | |
| 61 }; | 33 }; |
| 62 | 34 |
| 63 } // namespace blink | 35 } // namespace blink |
| 64 | 36 |
| 65 #endif // V8HiddenValue_h | 37 #endif // V8HiddenValue_h |
| OLD | NEW |