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

Unified Diff: third_party/WebKit/Source/core/workers/WorkletScriptLoader.h

Issue 2657823002: Worklet: Straighten layering of worklet script loading (Closed)
Patch Set: Created 3 years, 11 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
Index: third_party/WebKit/Source/core/workers/WorkletScriptLoader.h
diff --git a/third_party/WebKit/Source/core/workers/WorkletScriptLoader.h b/third_party/WebKit/Source/core/workers/WorkletScriptLoader.h
index 6291fff7eefc8931ce245327acc12b595dca6d1c..7660823936b9905b25c32f3dd83f37037d21fc1d 100644
--- a/third_party/WebKit/Source/core/workers/WorkletScriptLoader.h
+++ b/third_party/WebKit/Source/core/workers/WorkletScriptLoader.h
@@ -5,17 +5,19 @@
#ifndef WorkletScriptLoader_h
#define WorkletScriptLoader_h
-#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "core/loader/resource/ScriptResource.h"
#include "platform/loader/fetch/ResourceClient.h"
#include "platform/loader/fetch/ResourceOwner.h"
namespace blink {
-class Worklet;
+class LocalFrame;
+class ResourceFetcher;
-// Class that is responsible for processing {@code resource} that is associated
-// with worklet's import promise.
+// This class is responsible for fetching and loading a worklet script as a
+// classic script. A client of this class receives notifications via Client
+// interface.
+// TODO(nhiroki): Switch to module script loading (https://crbug.com/627945)
class WorkletScriptLoader final
: public GarbageCollectedFinalized<WorkletScriptLoader>,
public ResourceOwner<ScriptResource, ScriptResourceClient> {
@@ -23,38 +25,38 @@ class WorkletScriptLoader final
WTF_MAKE_NONCOPYABLE(WorkletScriptLoader);
public:
- static WorkletScriptLoader* create(
- ScriptPromiseResolver* scriptPromiseResolver,
- Worklet* worklet,
- ScriptResource* resource) {
- return new WorkletScriptLoader(scriptPromiseResolver, worklet, resource);
+ class Client : public GarbageCollectedMixin {
+ public:
+ // Called when cancel() is called.
+ virtual void notifyCanceled(WorkletScriptLoader*) = 0;
+
+ // Called when a resource fetching is completed.
+ virtual void notifyFinished(WorkletScriptLoader*) = 0;
+ };
+
+ static WorkletScriptLoader* create(LocalFrame* frame, Client* client) {
+ return new WorkletScriptLoader(frame, client);
}
~WorkletScriptLoader() override = default;
- // Cancels loading of {@code m_resource}.
- //
- // Typically it gets called when WorkletScriptLoader's host is about to be
- // disposed off.
+ // Fetches an URL and loads it as a classic script.
+ bool fetchScript(const String& scriptURL);
+
+ // Cancels loading a resource.
void cancel();
DECLARE_TRACE();
private:
- // Default constructor.
- //
- // @param resolver Promise resolver that is used to reject/resolve the promise
- // on ScriptResourceClient::notifyFinished event.
- // @param host Host that needs be notified when the resource is downloaded.
- // @param resource that needs to be downloaded.
- WorkletScriptLoader(ScriptPromiseResolver*, Worklet* host, ScriptResource*);
+ WorkletScriptLoader(LocalFrame*, Client*);
// ResourceClient
void notifyFinished(Resource*) final;
String debugName() const final { return "WorkletLoader"; }
- Member<ScriptPromiseResolver> m_resolver;
- Member<Worklet> m_host;
+ Member<ResourceFetcher> m_fetcher;
+ Member<Client> m_client;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698