OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "modules/worklet/WorkletScriptLoader.h" |
| 6 |
| 7 #include "core/dom/DOMException.h" |
| 8 #include "core/dom/ExceptionCode.h" |
| 9 #include "modules/worklet/Worklet.h" |
| 10 |
| 11 namespace blink { |
| 12 |
| 13 WorkletScriptLoader::WorkletScriptLoader(ScriptPromiseResolver* resolver, Workle
t* worklet, ScriptResource* resource) |
| 14 : m_resolver(resolver) |
| 15 , m_host(worklet) |
| 16 { |
| 17 setResource(resource); |
| 18 } |
| 19 |
| 20 void WorkletScriptLoader::notifyFinished(Resource* resource) |
| 21 { |
| 22 DCHECK(this->resource() == resource); |
| 23 |
| 24 m_host->notifyFinished(resource); |
| 25 if (resource->errorOccurred()) { |
| 26 m_resolver->reject(DOMException::create(NetworkError)); |
| 27 } else { |
| 28 DCHECK(resource->isLoaded()); |
| 29 m_resolver->resolve(); |
| 30 } |
| 31 clearResource(); |
| 32 } |
| 33 |
| 34 DEFINE_TRACE(WorkletScriptLoader) |
| 35 { |
| 36 visitor->trace(m_resolver); |
| 37 visitor->trace(m_host); |
| 38 ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor); |
| 39 } |
| 40 |
| 41 } // namespace blink |
OLD | NEW |