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

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

Issue 2017703002: Notify InspectorInstrumentation on successfully imported Worklet's script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/Worklet.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 25 matching lines...) Expand all
36 ScriptPromise promise = resolver->promise(); 36 ScriptPromise promise = resolver->promise();
37 37
38 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow 38 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow
39 // module loading support. For now just fetch a 'classic' script. 39 // module loading support. For now just fetch a 'classic' script.
40 40
41 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks 41 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks
42 // (resolving the promise) before we return it. 42 // (resolving the promise) before we return it.
43 m_scriptLoaders.append(WorkerScriptLoader::create()); 43 m_scriptLoaders.append(WorkerScriptLoader::create());
44 m_scriptLoaders.last()->loadAsynchronously(*getExecutionContext(), scriptURL , DenyCrossOriginRequests, 44 m_scriptLoaders.last()->loadAsynchronously(*getExecutionContext(), scriptURL , DenyCrossOriginRequests,
45 getExecutionContext()->securityContext().addressSpace(), 45 getExecutionContext()->securityContext().addressSpace(),
46 bind(&Worklet::onResponse, this), 46 bind(&Worklet::onResponse, this, m_scriptLoaders.last().get()),
47 bind(&Worklet::onFinished, this, m_scriptLoaders.last().get(), resolver) ); 47 bind(&Worklet::onFinished, this, m_scriptLoaders.last().get(), resolver) );
48 48
49 return promise; 49 return promise;
50 } 50 }
51 51
52 void Worklet::onResponse() 52 void Worklet::onResponse(WorkerScriptLoader* scriptLoader)
53 { 53 {
54 // TODO(ikilpatrick): Add devtools instrumentation on worklet script 54 InspectorInstrumentation::didReceiveScriptResponse(getExecutionContext(), sc riptLoader->identifier());
55 // resource loading.
56 } 55 }
57 56
58 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver) 57 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver * resolver)
59 { 58 {
60 if (scriptLoader->failed()) { 59 if (scriptLoader->failed()) {
61 resolver->reject(DOMException::create(NetworkError)); 60 resolver->reject(DOMException::create(NetworkError));
62 } else { 61 } else {
63 // TODO(ikilpatrick): Worklets don't have the same error behaviour 62 // TODO(ikilpatrick): Worklets don't have the same error behaviour
64 // as workers, etc. For a SyntaxError we should reject, however if 63 // as workers, etc. For a SyntaxError we should reject, however if
65 // the script throws a normal error, resolve. For now just resolve. 64 // the script throws a normal error, resolve. For now just resolve.
(...skipping 20 matching lines...) Expand all
86 } 85 }
87 } 86 }
88 87
89 DEFINE_TRACE(Worklet) 88 DEFINE_TRACE(Worklet)
90 { 89 {
91 visitor->trace(m_resolvers); 90 visitor->trace(m_resolvers);
92 ActiveDOMObject::trace(visitor); 91 ActiveDOMObject::trace(visitor);
93 } 92 }
94 93
95 } // namespace blink 94 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/Worklet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698