OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "core/workers/MainThreadWorklet.h" | 5 #include "core/workers/MainThreadWorklet.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptSourceCode.h" | 7 #include "bindings/core/v8/ScriptSourceCode.h" |
8 #include "bindings/core/v8/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
9 #include "core/dom/DOMException.h" | 9 #include "core/dom/DOMException.h" |
10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
11 #include "core/dom/ExceptionCode.h" | 11 #include "core/dom/ExceptionCode.h" |
12 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
13 #include "core/workers/WorkletGlobalScopeProxy.h" | 13 #include "core/workers/WorkletGlobalScopeProxy.h" |
14 #include "platform/wtf/WTF.h" | 14 #include "platform/wtf/WTF.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 MainThreadWorklet::MainThreadWorklet(LocalFrame* frame) : Worklet(frame) {} | 18 MainThreadWorklet::MainThreadWorklet(LocalFrame* frame) : Worklet(frame) {} |
19 | 19 |
20 ScriptPromise MainThreadWorklet::import(ScriptState* script_state, | 20 ScriptPromise MainThreadWorklet::addModule(ScriptState* script_state, |
21 const String& url) { | 21 const String& url) { |
22 DCHECK(IsMainThread()); | 22 DCHECK(IsMainThread()); |
23 if (!GetExecutionContext()) { | 23 if (!GetExecutionContext()) { |
24 return ScriptPromise::RejectWithDOMException( | 24 return ScriptPromise::RejectWithDOMException( |
25 script_state, DOMException::Create(kInvalidStateError, | 25 script_state, DOMException::Create(kInvalidStateError, |
26 "This frame is already detached")); | 26 "This frame is already detached")); |
27 } | 27 } |
28 | 28 |
29 KURL script_url = GetExecutionContext()->CompleteURL(url); | 29 KURL script_url = GetExecutionContext()->CompleteURL(url); |
30 if (!script_url.IsValid()) { | 30 if (!script_url.IsValid()) { |
31 return ScriptPromise::RejectWithDOMException( | 31 return ScriptPromise::RejectWithDOMException( |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 loader_to_resolver_map_.Clear(); | 69 loader_to_resolver_map_.Clear(); |
70 Worklet::ContextDestroyed(execution_context); | 70 Worklet::ContextDestroyed(execution_context); |
71 } | 71 } |
72 | 72 |
73 DEFINE_TRACE(MainThreadWorklet) { | 73 DEFINE_TRACE(MainThreadWorklet) { |
74 visitor->Trace(loader_to_resolver_map_); | 74 visitor->Trace(loader_to_resolver_map_); |
75 Worklet::Trace(visitor); | 75 Worklet::Trace(visitor); |
76 } | 76 } |
77 | 77 |
78 } // namespace blink | 78 } // namespace blink |
OLD | NEW |