| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "bindings/core/v8/ScriptWrappable.h" | |
| 6 | |
| 7 #include "bindings/core/v8/DOMDataStore.h" | |
| 8 #include "bindings/core/v8/ScriptWrappableVisitor.h" | |
| 9 #include "bindings/core/v8/V8DOMWrapper.h" | |
| 10 | |
| 11 namespace blink { | |
| 12 | |
| 13 struct SameSizeAsScriptWrappable { | |
| 14 virtual ~SameSizeAsScriptWrappable() {} | |
| 15 v8::Persistent<v8::Object> main_world_wrapper_; | |
| 16 }; | |
| 17 | |
| 18 static_assert(sizeof(ScriptWrappable) <= sizeof(SameSizeAsScriptWrappable), | |
| 19 "ScriptWrappable should stay small"); | |
| 20 | |
| 21 v8::Local<v8::Object> ScriptWrappable::Wrap( | |
| 22 v8::Isolate* isolate, | |
| 23 v8::Local<v8::Object> creation_context) { | |
| 24 const WrapperTypeInfo* wrapper_type_info = this->GetWrapperTypeInfo(); | |
| 25 | |
| 26 DCHECK(!DOMDataStore::ContainsWrapper(this, isolate)); | |
| 27 | |
| 28 v8::Local<v8::Object> wrapper = | |
| 29 V8DOMWrapper::CreateWrapper(isolate, creation_context, wrapper_type_info); | |
| 30 DCHECK(!wrapper.IsEmpty()); | |
| 31 return AssociateWithWrapper(isolate, wrapper_type_info, wrapper); | |
| 32 } | |
| 33 | |
| 34 v8::Local<v8::Object> ScriptWrappable::AssociateWithWrapper( | |
| 35 v8::Isolate* isolate, | |
| 36 const WrapperTypeInfo* wrapper_type_info, | |
| 37 v8::Local<v8::Object> wrapper) { | |
| 38 return V8DOMWrapper::AssociateObjectWithWrapper(isolate, this, | |
| 39 wrapper_type_info, wrapper); | |
| 40 } | |
| 41 | |
| 42 void ScriptWrappable::MarkWrapper(const WrapperVisitor* visitor) const { | |
| 43 if (ContainsWrapper()) | |
| 44 visitor->MarkWrapper(&main_world_wrapper_.As<v8::Value>()); | |
| 45 } | |
| 46 | |
| 47 } // namespace blink | |
| OLD | NEW |