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

Side by Side Diff: third_party/WebKit/Source/modules/worklet/Worklet.cpp

Issue 2029163002: Worklets - Change inheritance heirarchy of WorkletGlobalScope (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase. Created 4 years, 6 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 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"
9 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
10 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h"
11 #include "core/dom/DOMException.h" 10 #include "core/dom/DOMException.h"
12 #include "core/dom/ExceptionCode.h" 11 #include "core/dom/ExceptionCode.h"
13 #include "core/inspector/InspectorInstrumentation.h" 12 #include "core/inspector/InspectorInstrumentation.h"
14 #include "modules/worklet/WorkletGlobalScope.h" 13 #include "core/workers/WorkletGlobalScopeProxy.h"
15 14
16 namespace blink { 15 namespace blink {
17 16
18 Worklet::Worklet(ExecutionContext* executionContext) 17 Worklet::Worklet(ExecutionContext* executionContext)
19 : ActiveDOMObject(executionContext) 18 : ActiveDOMObject(executionContext)
20 { 19 {
21 } 20 }
22 21
23 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url) 22 ScriptPromise Worklet::import(ScriptState* scriptState, const String& url)
24 { 23 {
(...skipping 30 matching lines...) Expand all
55 } 54 }
56 55
57 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver) 56 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver)
58 { 57 {
59 if (scriptLoader->failed()) { 58 if (scriptLoader->failed()) {
60 resolver->reject(DOMException::create(NetworkError)); 59 resolver->reject(DOMException::create(NetworkError));
61 } else { 60 } else {
62 // TODO(ikilpatrick): Worklets don't have the same error behaviour 61 // TODO(ikilpatrick): Worklets don't have the same error behaviour
63 // as workers, etc. For a SyntaxError we should reject, however if 62 // as workers, etc. For a SyntaxError we should reject, however if
64 // the script throws a normal error, resolve. For now just resolve. 63 // the script throws a normal error, resolve. For now just resolve.
65 workletGlobalScope()->scriptController()->evaluate(ScriptSourceCode(scri ptLoader->script(), scriptLoader->url())); 64 workletGlobalScopeProxy()->evaluateScript(scriptLoader->script(), script Loader->url());
66 InspectorInstrumentation::scriptImported(workletGlobalScope(), scriptLoa der->identifier(), scriptLoader->script()); 65 InspectorInstrumentation::scriptImported(getExecutionContext(), scriptLo ader->identifier(), scriptLoader->script());
67 resolver->resolve(); 66 resolver->resolve();
68 } 67 }
69 68
70 size_t index = m_scriptLoaders.find(scriptLoader); 69 size_t index = m_scriptLoaders.find(scriptLoader);
71 70
72 ASSERT(index != kNotFound); 71 ASSERT(index != kNotFound);
73 ASSERT(m_resolvers[index] == resolver); 72 ASSERT(m_resolvers[index] == resolver);
74 73
75 m_scriptLoaders.remove(index); 74 m_scriptLoaders.remove(index);
76 m_resolvers.remove(index); 75 m_resolvers.remove(index);
77 } 76 }
78 77
79 void Worklet::stop() 78 void Worklet::stop()
80 { 79 {
81 workletGlobalScope()->dispose(); 80 workletGlobalScopeProxy()->terminateWorkletGlobalScope();
82 81
83 for (auto scriptLoader : m_scriptLoaders) { 82 for (auto scriptLoader : m_scriptLoaders) {
84 scriptLoader->cancel(); 83 scriptLoader->cancel();
85 } 84 }
86 } 85 }
87 86
88 DEFINE_TRACE(Worklet) 87 DEFINE_TRACE(Worklet)
89 { 88 {
90 visitor->trace(m_resolvers); 89 visitor->trace(m_resolvers);
91 ActiveDOMObject::trace(visitor); 90 ActiveDOMObject::trace(visitor);
92 } 91 }
93 92
94 } // namespace blink 93 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/Worklet.h ('k') | third_party/WebKit/Source/modules/worklet/WorkletGlobalScope.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698