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

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

Issue 2620493002: binding: Changes the association among global-proxy/global/worker-instance. (Closed)
Patch Set: Synced. Created 3 years, 11 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "bindings/core/v8/ToV8.h" 5 #include "bindings/core/v8/ToV8.h"
6 6
7 #include "bindings/core/v8/WindowProxy.h" 7 #include "bindings/core/v8/WindowProxy.h"
8 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
9 #include "core/events/EventTarget.h" 8 #include "core/events/EventTarget.h"
10 #include "core/frame/DOMWindow.h" 9 #include "core/frame/DOMWindow.h"
11 #include "core/frame/Frame.h" 10 #include "core/frame/Frame.h"
12 #include "core/workers/WorkerOrWorkletGlobalScope.h"
13 11
14 namespace blink { 12 namespace blink {
15 13
16 v8::Local<v8::Value> ToV8(DOMWindow* window, 14 v8::Local<v8::Value> ToV8(DOMWindow* window,
haraken 2017/01/11 12:43:52 Are you planning to remove this in a follow-up?
Yuki 2017/01/11 12:48:28 Yes, I'm preparing a CL at https://codereview.chro
17 v8::Local<v8::Object> creationContext, 15 v8::Local<v8::Object> creationContext,
18 v8::Isolate* isolate) { 16 v8::Isolate* isolate) {
19 // Notice that we explicitly ignore creationContext because the DOMWindow 17 // Notice that we explicitly ignore creationContext because the DOMWindow
20 // has its own creationContext. 18 // has its own creationContext.
21 19
22 if (UNLIKELY(!window)) 20 if (UNLIKELY(!window))
23 return v8::Null(isolate); 21 return v8::Null(isolate);
24 // Initializes environment of a frame, and return the global object 22 // Initializes environment of a frame, and return the global object
25 // of the frame. 23 // of the frame.
26 Frame* frame = window->frame(); 24 Frame* frame = window->frame();
27 if (!frame) 25 if (!frame)
28 return v8Undefined(); 26 return v8Undefined();
29 27
30 return frame->windowProxy(DOMWrapperWorld::current(isolate)) 28 return frame->windowProxy(DOMWrapperWorld::current(isolate))
31 ->globalIfNotDetached(); 29 ->globalIfNotDetached();
32 } 30 }
33 31
34 v8::Local<v8::Value> ToV8(EventTarget* impl, 32 v8::Local<v8::Value> ToV8(EventTarget* impl,
35 v8::Local<v8::Object> creationContext, 33 v8::Local<v8::Object> creationContext,
36 v8::Isolate* isolate) { 34 v8::Isolate* isolate) {
37 if (UNLIKELY(!impl)) 35 if (UNLIKELY(!impl))
38 return v8::Null(isolate); 36 return v8::Null(isolate);
39 37
40 if (impl->interfaceName() == EventTargetNames::DOMWindow) 38 if (impl->interfaceName() == EventTargetNames::DOMWindow)
41 return ToV8(static_cast<DOMWindow*>(impl), creationContext, isolate); 39 return ToV8(static_cast<DOMWindow*>(impl), creationContext, isolate);
42 return ToV8(static_cast<ScriptWrappable*>(impl), creationContext, isolate); 40 return ToV8(static_cast<ScriptWrappable*>(impl), creationContext, isolate);
43 } 41 }
44 42
45 v8::Local<v8::Value> ToV8(WorkerOrWorkletGlobalScope* impl,
46 v8::Local<v8::Object> creationContext,
47 v8::Isolate* isolate) {
48 // Notice that we explicitly ignore creationContext because the
49 // WorkerOrWorkletGlobalScope has its own creationContext.
50
51 if (UNLIKELY(!impl))
52 return v8::Null(isolate);
53
54 WorkerOrWorkletScriptController* scriptController = impl->scriptController();
55 if (!scriptController)
56 return v8::Null(isolate);
57
58 v8::Local<v8::Object> global = scriptController->context()->Global();
59 ASSERT(!global.IsEmpty());
60 return global;
61 }
62
63 } // namespace blink 43 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698