OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "modules/worklet/WorkletGlobalScope.h" | 5 #include "modules/worklet/WorkletGlobalScope.h" |
6 | 6 |
7 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 7 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
8 #include "core/frame/FrameConsole.h" | 8 #include "core/frame/FrameConsole.h" |
9 #include "core/inspector/InspectorInstrumentation.h" | 9 #include "core/inspector/InspectorInstrumentation.h" |
10 #include "core/inspector/MainThreadDebugger.h" | 10 #include "core/inspector/MainThreadDebugger.h" |
11 #include "modules/worklet/WorkletConsole.h" | |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 | 13 |
15 WorkletGlobalScope::WorkletGlobalScope(LocalFrame* frame, const KURL& url, const
String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isol
ate) | 14 WorkletGlobalScope::WorkletGlobalScope(LocalFrame* frame, const KURL& url, const
String& userAgent, PassRefPtr<SecurityOrigin> securityOrigin, v8::Isolate* isol
ate) |
16 : MainThreadWorkletGlobalScope(frame) | 15 : MainThreadWorkletGlobalScope(frame) |
17 , m_url(url) | 16 , m_url(url) |
18 , m_userAgent(userAgent) | 17 , m_userAgent(userAgent) |
19 , m_scriptController(WorkerOrWorkletScriptController::create(this, isolate)) | 18 , m_scriptController(WorkerOrWorkletScriptController::create(this, isolate)) |
20 { | 19 { |
21 setSecurityOrigin(securityOrigin); | 20 setSecurityOrigin(securityOrigin); |
22 } | 21 } |
23 | 22 |
24 WorkletGlobalScope::~WorkletGlobalScope() | 23 WorkletGlobalScope::~WorkletGlobalScope() |
25 { | 24 { |
26 } | 25 } |
27 | 26 |
28 void WorkletGlobalScope::dispose() | 27 void WorkletGlobalScope::dispose() |
29 { | 28 { |
30 stopActiveDOMObjects(); | 29 stopActiveDOMObjects(); |
31 | 30 |
32 ASSERT(m_scriptController); | 31 ASSERT(m_scriptController); |
33 m_scriptController->willScheduleExecutionTermination(); | 32 m_scriptController->willScheduleExecutionTermination(); |
34 m_scriptController->dispose(); | 33 m_scriptController->dispose(); |
35 m_scriptController.clear(); | 34 m_scriptController.clear(); |
36 } | 35 } |
37 | 36 |
38 WorkletConsole* WorkletGlobalScope::console() | |
39 { | |
40 if (!m_console) | |
41 m_console = WorkletConsole::create(this); | |
42 return m_console.get(); | |
43 } | |
44 | |
45 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) | 37 v8::Local<v8::Object> WorkletGlobalScope::wrap(v8::Isolate*, v8::Local<v8::Objec
t> creationContext) |
46 { | 38 { |
47 // WorkletGlobalScope must never be wrapped with wrap method. The global | 39 // WorkletGlobalScope must never be wrapped with wrap method. The global |
48 // object of ECMAScript environment is used as the wrapper. | 40 // object of ECMAScript environment is used as the wrapper. |
49 RELEASE_NOTREACHED(); | 41 RELEASE_NOTREACHED(); |
50 return v8::Local<v8::Object>(); | 42 return v8::Local<v8::Object>(); |
51 } | 43 } |
52 | 44 |
53 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con
st WrapperTypeInfo*, v8::Local<v8::Object> wrapper) | 45 v8::Local<v8::Object> WorkletGlobalScope::associateWithWrapper(v8::Isolate*, con
st WrapperTypeInfo*, v8::Local<v8::Object> wrapper) |
54 { | 46 { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // behavior? | 89 // behavior? |
98 if (url.isNull()) | 90 if (url.isNull()) |
99 return KURL(); | 91 return KURL(); |
100 // Always use UTF-8 in Worklets. | 92 // Always use UTF-8 in Worklets. |
101 return KURL(m_url, url); | 93 return KURL(m_url, url); |
102 } | 94 } |
103 | 95 |
104 DEFINE_TRACE(WorkletGlobalScope) | 96 DEFINE_TRACE(WorkletGlobalScope) |
105 { | 97 { |
106 visitor->trace(m_scriptController); | 98 visitor->trace(m_scriptController); |
107 visitor->trace(m_console); | |
108 ExecutionContext::trace(visitor); | 99 ExecutionContext::trace(visitor); |
109 SecurityContext::trace(visitor); | 100 SecurityContext::trace(visitor); |
110 MainThreadWorkletGlobalScope::trace(visitor); | 101 MainThreadWorkletGlobalScope::trace(visitor); |
111 } | 102 } |
112 | 103 |
113 } // namespace blink | 104 } // namespace blink |
OLD | NEW |