| 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/V8Binding.h" | 8 #include "bindings/core/v8/V8Binding.h" |
| 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" | 9 #include "bindings/core/v8/WorkerOrWorkletScriptController.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 ScriptPromise promise = resolver->promise(); | 35 ScriptPromise promise = resolver->promise(); |
| 36 | 36 |
| 37 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow | 37 // TODO(ikilpatrick): WorkerScriptLoader will need to be extended to allow |
| 38 // module loading support. For now just fetch a 'classic' script. | 38 // module loading support. For now just fetch a 'classic' script. |
| 39 | 39 |
| 40 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks | 40 // NOTE: WorkerScriptLoader may synchronously invoke its callbacks |
| 41 // (resolving the promise) before we return it. | 41 // (resolving the promise) before we return it. |
| 42 m_scriptLoaders.append(WorkerScriptLoader::create()); | 42 m_scriptLoaders.append(WorkerScriptLoader::create()); |
| 43 m_scriptLoaders.last()->loadAsynchronously(*getExecutionContext(), scriptURL
, DenyCrossOriginRequests, | 43 m_scriptLoaders.last()->loadAsynchronously(*getExecutionContext(), scriptURL
, DenyCrossOriginRequests, |
| 44 getExecutionContext()->securityContext().addressSpace(), | 44 getExecutionContext()->securityContext().addressSpace(), |
| 45 bind(&Worklet::onResponse, wrapPersistent(this), m_scriptLoaders.last().
get()), | 45 bind(&Worklet::onResponse, wrapPersistent(this), WTF::unretained(m_scrip
tLoaders.last().get())), |
| 46 bind(&Worklet::onFinished, wrapPersistent(this), m_scriptLoaders.last().
get(), wrapPersistent(resolver))); | 46 bind(&Worklet::onFinished, wrapPersistent(this), WTF::unretained(m_scrip
tLoaders.last().get()), wrapPersistent(resolver))); |
| 47 | 47 |
| 48 return promise; | 48 return promise; |
| 49 } | 49 } |
| 50 | 50 |
| 51 void Worklet::onResponse(WorkerScriptLoader* scriptLoader) | 51 void Worklet::onResponse(WorkerScriptLoader* scriptLoader) |
| 52 { | 52 { |
| 53 InspectorInstrumentation::didReceiveScriptResponse(getExecutionContext(), sc
riptLoader->identifier()); | 53 InspectorInstrumentation::didReceiveScriptResponse(getExecutionContext(), sc
riptLoader->identifier()); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver
* resolver) | 56 void Worklet::onFinished(WorkerScriptLoader* scriptLoader, ScriptPromiseResolver
* resolver) |
| (...skipping 27 matching lines...) Expand all Loading... |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 DEFINE_TRACE(Worklet) | 87 DEFINE_TRACE(Worklet) |
| 88 { | 88 { |
| 89 visitor->trace(m_resolvers); | 89 visitor->trace(m_resolvers); |
| 90 ActiveDOMObject::trace(visitor); | 90 ActiveDOMObject::trace(visitor); |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |