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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptWrappable.cpp

Issue 2843603002: Move ScriptWrappable and dependencies to platform/bindings (Closed)
Patch Set: Rebase and try again Created 3 years, 7 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
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698