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

Unified Diff: third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp

Issue 2178223002: Refactor Worklet class to use ScriptResource (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: synced to the head Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..7db4b8fbefd3dfd6db0b6c6584e6cc0d51363f2e
--- /dev/null
+++ b/third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.cpp
@@ -0,0 +1,50 @@
+// 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 "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.h"
+#include "core/fetch/ResourceLoader.h"
+#include "modules/worklet/Worklet.h"
+
+namespace blink {
+
+WorkletScriptLoader::WorkletScriptLoader(ScriptPromiseResolver* resolver, Worklet* worklet, ScriptResource* resource)
+ : m_resolver(resolver)
+ , m_host(worklet)
+{
+ setResource(resource);
+}
+
+void WorkletScriptLoader::cancel()
+{
+ if (resource()) {
+ resource()->loader()->cancel();
+ clearResource();
+ }
+}
+
+void WorkletScriptLoader::notifyFinished(Resource* resource)
+{
+ DCHECK(this->resource() == resource);
+
+ m_host->notifyFinished(this);
+ if (resource->errorOccurred()) {
+ m_resolver->reject(DOMException::create(NetworkError));
+ } else {
+ DCHECK(resource->isLoaded());
+ m_resolver->resolve();
+ }
+ clearResource();
+}
+
+DEFINE_TRACE(WorkletScriptLoader)
+{
+ visitor->trace(m_resolver);
+ visitor->trace(m_host);
+ ResourceOwner<ScriptResource, ScriptResourceClient>::trace(visitor);
+}
+
+} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/modules/worklet/WorkletScriptLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698