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/Worklet.h" | 5 #include "modules/worklet/Worklet.h" |
6 | 6 |
7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "bindings/core/v8/ScriptSourceCode.h" | 8 #include "bindings/core/v8/ScriptSourceCode.h" |
9 #include "bindings/core/v8/V8Binding.h" | 9 #include "bindings/core/v8/V8Binding.h" |
10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 } | 62 } |
63 | 63 |
64 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver
* resolver) | 64 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver
* resolver) |
65 { | 65 { |
66 if (scriptLoader->failed()) { | 66 if (scriptLoader->failed()) { |
67 resolver->reject(DOMException::create(NetworkError)); | 67 resolver->reject(DOMException::create(NetworkError)); |
68 } else { | 68 } else { |
69 // TODO(ikilpatrick): Worklets don't have the same error behaviour | 69 // TODO(ikilpatrick): Worklets don't have the same error behaviour |
70 // as workers, etc. For a SyntaxError we should reject, however if | 70 // as workers, etc. For a SyntaxError we should reject, however if |
71 // the script throws a normal error, resolve. For now just resolve. | 71 // the script throws a normal error, resolve. For now just resolve. |
72 m_workletGlobalScope->script()->evaluate(ScriptSourceCode(scriptLoader->
script(), scriptLoader->url())); | 72 m_workletGlobalScope->scriptController()->evaluate(ScriptSourceCode(scri
ptLoader->script(), scriptLoader->url())); |
73 resolver->resolve(); | 73 resolver->resolve(); |
74 } | 74 } |
75 | 75 |
76 size_t index = m_scriptLoaders.find(scriptLoader); | 76 size_t index = m_scriptLoaders.find(scriptLoader); |
77 | 77 |
78 ASSERT(index != kNotFound); | 78 ASSERT(index != kNotFound); |
79 ASSERT(m_resolvers[index] == resolver); | 79 ASSERT(m_resolvers[index] == resolver); |
80 | 80 |
81 m_scriptLoaders.remove(index); | 81 m_scriptLoaders.remove(index); |
82 m_resolvers.remove(index); | 82 m_resolvers.remove(index); |
83 } | 83 } |
84 | 84 |
85 void Worklet::stop() | 85 void Worklet::stop() |
86 { | 86 { |
87 m_workletGlobalScope->script()->willScheduleExecutionTermination(); | 87 m_workletGlobalScope->scriptController()->willScheduleExecutionTermination()
; |
88 | 88 |
89 for (auto scriptLoader : m_scriptLoaders) { | 89 for (auto scriptLoader : m_scriptLoaders) { |
90 scriptLoader->cancel(); | 90 scriptLoader->cancel(); |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 DEFINE_TRACE(Worklet) | 94 DEFINE_TRACE(Worklet) |
95 { | 95 { |
96 visitor->trace(m_resolvers); | 96 visitor->trace(m_resolvers); |
97 visitor->trace(m_workletGlobalScope); | 97 visitor->trace(m_workletGlobalScope); |
98 ActiveDOMObject::trace(visitor); | 98 ActiveDOMObject::trace(visitor); |
99 } | 99 } |
100 | 100 |
101 } // namespace blink | 101 } // namespace blink |
OLD | NEW |