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

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

Issue 1745253002: [Worklets] Add basic debugging to main thread worklets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix non-oilpan build. Created 4 years, 9 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" 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"
11 #include "core/dom/DOMException.h" 11 #include "core/dom/DOMException.h"
12 #include "core/dom/ExceptionCode.h" 12 #include "core/dom/ExceptionCode.h"
13 #include "core/inspector/InspectorInstrumentation.h"
13 #include "modules/worklet/WorkletGlobalScope.h" 14 #include "modules/worklet/WorkletGlobalScope.h"
14 15
15 namespace blink { 16 namespace blink {
16 17
17 // static 18 // static
18 Worklet* Worklet::create(LocalFrame* frame, ExecutionContext* executionContext) 19 Worklet* Worklet::create(LocalFrame* frame, ExecutionContext* executionContext)
19 { 20 {
20 Worklet* worklet = new Worklet(frame, executionContext); 21 Worklet* worklet = new Worklet(frame, executionContext);
21 worklet->suspendIfNeeded(); 22 worklet->suspendIfNeeded();
22 return worklet; 23 return worklet;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 66
66 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver) 67 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver)
67 { 68 {
68 if (scriptLoader->failed()) { 69 if (scriptLoader->failed()) {
69 resolver->reject(DOMException::create(NetworkError)); 70 resolver->reject(DOMException::create(NetworkError));
70 } else { 71 } else {
71 // TODO(ikilpatrick): Worklets don't have the same error behaviour 72 // TODO(ikilpatrick): Worklets don't have the same error behaviour
72 // as workers, etc. For a SyntaxError we should reject, however if 73 // as workers, etc. For a SyntaxError we should reject, however if
73 // the script throws a normal error, resolve. For now just resolve. 74 // the script throws a normal error, resolve. For now just resolve.
74 m_workletGlobalScope->scriptController()->evaluate(ScriptSourceCode(scri ptLoader->script(), scriptLoader->url())); 75 m_workletGlobalScope->scriptController()->evaluate(ScriptSourceCode(scri ptLoader->script(), scriptLoader->url()));
76 InspectorInstrumentation::scriptImported(m_workletGlobalScope.get(), scr iptLoader->identifier(), scriptLoader->script());
75 resolver->resolve(); 77 resolver->resolve();
76 } 78 }
77 79
78 size_t index = m_scriptLoaders.find(scriptLoader); 80 size_t index = m_scriptLoaders.find(scriptLoader);
79 81
80 ASSERT(index != kNotFound); 82 ASSERT(index != kNotFound);
81 ASSERT(m_resolvers[index] == resolver); 83 ASSERT(m_resolvers[index] == resolver);
82 84
83 m_scriptLoaders.remove(index); 85 m_scriptLoaders.remove(index);
84 m_resolvers.remove(index); 86 m_resolvers.remove(index);
85 } 87 }
86 88
87 void Worklet::stop() 89 void Worklet::stop()
88 { 90 {
89 m_workletGlobalScope->scriptController()->willScheduleExecutionTermination() ; 91 m_workletGlobalScope->scriptController()->willScheduleExecutionTermination() ;
90 92
91 for (auto scriptLoader : m_scriptLoaders) { 93 for (auto scriptLoader : m_scriptLoaders) {
92 scriptLoader->cancel(); 94 scriptLoader->cancel();
93 } 95 }
94 } 96 }
95 97
96 DEFINE_TRACE(Worklet) 98 DEFINE_TRACE(Worklet)
97 { 99 {
98 visitor->trace(m_resolvers); 100 visitor->trace(m_resolvers);
99 visitor->trace(m_workletGlobalScope); 101 visitor->trace(m_workletGlobalScope);
100 ActiveDOMObject::trace(visitor); 102 ActiveDOMObject::trace(visitor);
101 } 103 }
102 104
103 } // namespace blink 105 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698