| 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 "core/fetch/ResourceLoader.h" | |
| 10 #include "modules/worklet/Worklet.h" | |
| 11 | |
| 12 namespace blink { | |
| 13 | |
| 14 WorkletScriptLoader::WorkletScriptLoader(ScriptPromiseResolver* resolver, Workle
t* worklet, ScriptResource* resource) | |
| 15 : m_resolver(resolver) | |
| 16 , m_host(worklet) | |
| 17 { | |
| 18 setResource(resource); | |
| 19 } | |
| 20 | |
| 21 void WorkletScriptLoader::cancel() | |
| 22 { | |
| 23 if (resource()) { | |
| 24 resource()->loader()->cancel(); | |
| 25 clearResource(); | |
| 26 } | |
| 27 } | |
| 28 | |
| 29 void WorkletScriptLoader::notifyFinished(Resource* resource) | |
| 30 { | |
| 31 DCHECK(this->resource() == resource); | |
| 32 | |
| 33 m_host->notifyFinished(this); | |
| 34 if (resource->errorOccurred()) { | |
| 35 m_resolver->reject(DOMException::create(NetworkError)); | |
| 36 } else { | |
| 37 DCHECK(resource->isLoaded()); | |
| 38 m_resolver->resolve(); | |
| 39 } | |
| 40 clearResource(); | |
| 41 } | |
| 42 | |
| 43 DEFINE_TRACE(WorkletScriptLoader) | |
| 44 { | |
| 45 visitor->trace(m_resolver); | |
| 46 visitor->trace(m_host); | |
| 47 ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor); | |
| 48 } | |
| 49 | |
| 50 } // namespace blink | |
| OLD | NEW |