| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef V8DOMWrapper_h | 31 #ifndef V8DOMWrapper_h |
| 32 #define V8DOMWrapper_h | 32 #define V8DOMWrapper_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/DOMDataStore.h" | 34 #include "platform/PlatformExport.h" |
| 35 #include "bindings/core/v8/ScriptWrappable.h" | 35 #include "platform/bindings/DOMDataStore.h" |
| 36 #include "bindings/core/v8/V8Binding.h" | 36 #include "platform/bindings/ScriptWrappable.h" |
| 37 #include "bindings/core/v8/WrapperCreationSecurityCheck.h" | 37 #include "platform/bindings/V8Binding.h" |
| 38 #include "core/CoreExport.h" | 38 #include "platform/bindings/WrapperCreationSecurityCheck.h" |
| 39 #include "platform/wtf/Compiler.h" | 39 #include "platform/wtf/Compiler.h" |
| 40 #include "platform/wtf/text/AtomicString.h" | 40 #include "platform/wtf/text/AtomicString.h" |
| 41 #include "v8/include/v8.h" | 41 #include "v8/include/v8.h" |
| 42 | 42 |
| 43 namespace blink { | 43 namespace blink { |
| 44 | 44 |
| 45 struct WrapperTypeInfo; | 45 struct WrapperTypeInfo; |
| 46 | 46 |
| 47 class V8DOMWrapper { | 47 class V8DOMWrapper { |
| 48 STATIC_ONLY(V8DOMWrapper); | 48 STATIC_ONLY(V8DOMWrapper); |
| 49 | 49 |
| 50 public: | 50 public: |
| 51 static v8::Local<v8::Object> CreateWrapper( | 51 static v8::Local<v8::Object> CreateWrapper( |
| 52 v8::Isolate*, | 52 v8::Isolate*, |
| 53 v8::Local<v8::Object> creation_context, | 53 v8::Local<v8::Object> creation_context, |
| 54 const WrapperTypeInfo*); | 54 const WrapperTypeInfo*); |
| 55 static bool IsWrapper(v8::Isolate*, v8::Local<v8::Value>); | 55 PLATFORM_EXPORT static bool IsWrapper(v8::Isolate*, v8::Local<v8::Value>); |
| 56 | 56 |
| 57 // Associates the given ScriptWrappable with the given |wrapper| if the | 57 // Associates the given ScriptWrappable with the given |wrapper| if the |
| 58 // ScriptWrappable is not yet associated with any wrapper. Returns the | 58 // ScriptWrappable is not yet associated with any wrapper. Returns the |
| 59 // wrapper already associated or |wrapper| if not yet associated. | 59 // wrapper already associated or |wrapper| if not yet associated. |
| 60 // The caller should always use the returned value rather than |wrapper|. | 60 // The caller should always use the returned value rather than |wrapper|. |
| 61 WARN_UNUSED_RESULT static v8::Local<v8::Object> AssociateObjectWithWrapper( | 61 WARN_UNUSED_RESULT static v8::Local<v8::Object> AssociateObjectWithWrapper( |
| 62 v8::Isolate*, | 62 v8::Isolate*, |
| 63 ScriptWrappable*, | 63 ScriptWrappable*, |
| 64 const WrapperTypeInfo*, | 64 const WrapperTypeInfo*, |
| 65 v8::Local<v8::Object> wrapper); | 65 v8::Local<v8::Object> wrapper); |
| 66 static void SetNativeInfo(v8::Isolate*, | 66 static void SetNativeInfo(v8::Isolate*, |
| 67 v8::Local<v8::Object>, | 67 v8::Local<v8::Object>, |
| 68 const WrapperTypeInfo*, | 68 const WrapperTypeInfo*, |
| 69 ScriptWrappable*); | 69 ScriptWrappable*); |
| 70 static void ClearNativeInfo(v8::Isolate*, v8::Local<v8::Object>); | 70 static void ClearNativeInfo(v8::Isolate*, v8::Local<v8::Object>); |
| 71 | 71 |
| 72 // hasInternalFieldsSet only checks if the value has the internal fields for | 72 // hasInternalFieldsSet only checks if the value has the internal fields for |
| 73 // wrapper obejct and type, and does not check if it's valid or not. The | 73 // wrapper obejct and type, and does not check if it's valid or not. The |
| 74 // value may not be a Blink's wrapper object. In order to make sure of it, | 74 // value may not be a Blink's wrapper object. In order to make sure of it, |
| 75 // Use isWrapper function instead. | 75 // Use isWrapper function instead. |
| 76 CORE_EXPORT static bool HasInternalFieldsSet(v8::Local<v8::Value>); | 76 PLATFORM_EXPORT static bool HasInternalFieldsSet(v8::Local<v8::Value>); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 inline void V8DOMWrapper::SetNativeInfo( | 79 inline void V8DOMWrapper::SetNativeInfo( |
| 80 v8::Isolate* isolate, | 80 v8::Isolate* isolate, |
| 81 v8::Local<v8::Object> wrapper, | 81 v8::Local<v8::Object> wrapper, |
| 82 const WrapperTypeInfo* wrapper_type_info, | 82 const WrapperTypeInfo* wrapper_type_info, |
| 83 ScriptWrappable* script_wrappable) { | 83 ScriptWrappable* script_wrappable) { |
| 84 DCHECK_GE(wrapper->InternalFieldCount(), 2); | 84 DCHECK_GE(wrapper->InternalFieldCount(), 2); |
| 85 DCHECK(script_wrappable); | 85 DCHECK(script_wrappable); |
| 86 DCHECK(wrapper_type_info); | 86 DCHECK(wrapper_type_info); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 bool did_enter_context_; | 186 bool did_enter_context_; |
| 187 v8::Local<v8::Context> context_; | 187 v8::Local<v8::Context> context_; |
| 188 v8::TryCatch try_catch_; | 188 v8::TryCatch try_catch_; |
| 189 const WrapperTypeInfo* type_; | 189 const WrapperTypeInfo* type_; |
| 190 bool access_check_failed_; | 190 bool access_check_failed_; |
| 191 }; | 191 }; |
| 192 | 192 |
| 193 } // namespace blink | 193 } // namespace blink |
| 194 | 194 |
| 195 #endif // V8DOMWrapper_h | 195 #endif // V8DOMWrapper_h |
| OLD | NEW |