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 "core/workers/Worklet.h" | 5 #include "core/workers/Worklet.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 "wtf/WTF.h" | 14 #include "wtf/WTF.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 | 17 |
18 Worklet::Worklet(LocalFrame* frame) | 18 Worklet::Worklet(LocalFrame* frame) |
19 : ContextLifecycleObserver(frame->document()), m_frame(frame) {} | 19 : ContextLifecycleObserver(frame->document()), m_frame(frame) {} |
20 | 20 |
21 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) { | 21 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) { |
22 DCHECK(isMainThread()); | 22 DCHECK(isMainThread()); |
23 if (!getExecutionContext()) { | 23 if (!getExecutionContext()) { |
24 return ScriptPromise::rejectWithDOMException( | 24 return ScriptPromise::rejectWithDOMException( |
25 scriptState, DOMException::create(InvalidStateError, | 25 scriptState, |
26 "This frame is already detached")); | 26 DOMException::create(InvalidStateError, |
| 27 "This frame is already detached")); |
27 } | 28 } |
28 | 29 |
29 KURL scriptURL = getExecutionContext()->completeURL(url); | 30 KURL scriptURL = getExecutionContext()->completeURL(url); |
30 if (!scriptURL.isValid()) { | 31 if (!scriptURL.isValid()) { |
31 return ScriptPromise::rejectWithDOMException( | 32 return ScriptPromise::rejectWithDOMException( |
32 scriptState, | 33 scriptState, |
33 DOMException::create(SyntaxError, "'" + url + "' is not a valid URL.")); | 34 DOMException::create(SyntaxError, "'" + url + "' is not a valid URL.")); |
34 } | 35 } |
35 | 36 |
36 if (!isInitialized()) | 37 if (!isInitialized()) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 m_frame = nullptr; | 73 m_frame = nullptr; |
73 } | 74 } |
74 | 75 |
75 DEFINE_TRACE(Worklet) { | 76 DEFINE_TRACE(Worklet) { |
76 visitor->trace(m_frame); | 77 visitor->trace(m_frame); |
77 visitor->trace(m_loaderAndResolvers); | 78 visitor->trace(m_loaderAndResolvers); |
78 ContextLifecycleObserver::trace(visitor); | 79 ContextLifecycleObserver::trace(visitor); |
79 } | 80 } |
80 | 81 |
81 } // namespace blink | 82 } // namespace blink |
OLD | NEW |