Add (entirely incorrect) fetching of ServiceWorker scripts.
[WebKit-https.git] / Source / WebCore / workers / service / ServiceWorkerJob.h
index d97ac1a..77d2183 100644 (file)
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "ResourceResponse.h"
 #include "ServiceWorkerJobClient.h"
 #include "ServiceWorkerJobData.h"
+#include "WorkerScriptLoader.h"
+#include "WorkerScriptLoaderClient.h"
 #include <wtf/RefPtr.h>
 #include <wtf/RunLoop.h>
 #include <wtf/ThreadSafeRefCounted.h>
@@ -38,10 +41,11 @@ namespace WebCore {
 
 class DeferredPromise;
 class Exception;
+class ScriptExecutionContext;
 enum class ServiceWorkerJobType;
 struct ServiceWorkerRegistrationData;
 
-class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob> {
+class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public WorkerScriptLoaderClient {
 public:
     static Ref<ServiceWorkerJob> create(ServiceWorkerJobClient& client, Ref<DeferredPromise>&& promise, ServiceWorkerJobData&& jobData)
     {
@@ -52,13 +56,20 @@ public:
 
     void failedWithException(const Exception&);
     void resolvedWithRegistration(const ServiceWorkerRegistrationData&);
+    void startScriptFetch();
 
     ServiceWorkerJobData data() const { return m_jobData; }
     DeferredPromise& promise() { return m_promise.get(); }
 
+    void fetchScriptWithContext(ScriptExecutionContext&);
+
 private:
     ServiceWorkerJob(ServiceWorkerJobClient&, Ref<DeferredPromise>&&, ServiceWorkerJobData&&);
 
+    // WorkerScriptLoaderClient
+    void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
+    void notifyFinished() final;
+
     Ref<ServiceWorkerJobClient> m_client;
     ServiceWorkerJobData m_jobData;
     Ref<DeferredPromise> m_promise;
@@ -66,6 +77,8 @@ private:
     bool m_completed { false };
 
     Ref<RunLoop> m_runLoop { RunLoop::current() };
+    RefPtr<WorkerScriptLoader> m_scriptLoader;
+    ResourceResponse m_lastResponse;
 
 #if !ASSERT_DISABLED
     ThreadIdentifier m_creationThread { currentThread() };