Index: third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp |
diff --git a/third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp b/third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8559adcbc47f5a7975eca6506c97d71a71fe28ef |
--- /dev/null |
+++ b/third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp |
@@ -0,0 +1,42 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "modules/worklet/WorkletScriptLoader.h" |
+ |
+#include "bindings/core/v8/ScriptSourceCode.h" |
+#include "core/dom/DOMException.h" |
+#include "core/dom/ExceptionCode.h" |
+#include "core/workers/WorkletGlobalScopeProxy.h" |
+#include "modules/worklet/Worklet.h" |
+ |
+namespace blink { |
+ |
+WorkletScriptLoader::WorkletScriptLoader(ScriptPromiseResolver* resolver, WorkletGlobalScopeProxy* workletGlobalScopeProxy, |
+ Worklet* worklet) |
+ : m_resolver(resolver) |
+ , m_host(worklet), |
+ , m_workletGlobalScopeProxy(workletGlobalScopeProxy) |
+{ |
+} |
+ |
+void WorkletScriptLoader::notifyFinished(Resource* resource) |
+{ |
+ if (resource->errorOccurred()) { |
+ m_resolver->reject(DOMException::create(NetworkError)); |
+ } else { |
+ DCHECK(resource->isLoaded()); |
+ m_workletGlobalScopeProxy->evaluateScript(ScriptSourceCode(toScriptResource(resource))); |
+ m_resolver->resolve(); |
+ } |
+ m_host->notifyFinished(resource); |
+} |
+ |
+DEFINE_TRACE(WorkletScriptLoader) |
+{ |
+ visitor->trace(m_resolver); |
+ visitor->trace(m_host); |
+ ScriptResourceClient::trace(visitor); |
+} |
+ |
+} // namespace blink |