Unreviewed, rolling out r221461.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 20:40:01 +0000 (20:40 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Sep 2017 20:40:01 +0000 (20:40 +0000)
The LayoutTest added with this change crashes under
GuardMalloc.

Reverted changeset:

"Add (entirely incorrect) fetching of ServiceWorker scripts."
https://bugs.webkit.org/show_bug.cgi?id=176179
http://trac.webkit.org/changeset/221461

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221699 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/ChangeLog
LayoutTests/http/tests/workers/service/basic-register-expected.txt
LayoutTests/http/tests/workers/service/resources/basic-register.js
LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/workers/service/ServiceWorkerContainer.cpp
Source/WebCore/workers/service/ServiceWorkerContainer.h
Source/WebCore/workers/service/ServiceWorkerFetchResult.h [deleted file]
Source/WebCore/workers/service/ServiceWorkerJob.cpp
Source/WebCore/workers/service/ServiceWorkerJob.h
Source/WebCore/workers/service/ServiceWorkerJobClient.h
Source/WebCore/workers/service/server/SWClientConnection.cpp
Source/WebCore/workers/service/server/SWClientConnection.h
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebCore/workers/service/server/SWServerRegistration.cpp
Source/WebCore/workers/service/server/SWServerRegistration.h
Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h
Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in
Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp
Source/WebKit/WebProcess/Storage/WebSWClientConnection.h
Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in

index ac2e5ed..836b481 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-06  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r221461.
+
+        The LayoutTest added with this change crashes under
+        GuardMalloc.
+
+        Reverted changeset:
+
+        "Add (entirely incorrect) fetching of ServiceWorker scripts."
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+        http://trac.webkit.org/changeset/221461
+
 2017-09-06  Devin Rousso  <webkit@devinrousso.com>
 
         Web Inspector: Support overloaded CanvasRenderingContext2D actions with identical parameter counts
index 0aedf70..c018e45 100644 (file)
@@ -1,3 +1,2 @@
-CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 bytes, but we're not using the result yet
-CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker-doesnt-exist.js fetch resulted in error: ServiceWorker script network fetch failed with HTTP status code 404
+CONSOLE MESSAGE: line 11: Registration failed with error: UnknownError: serviceWorker job scheduling is not yet implemented
 
index 3a1e63b..e7516fe 100644 (file)
@@ -6,16 +6,6 @@ function done()
 navigator.serviceWorker.register("resources/empty-worker.js", { })
 .then(function(r) {
        console.log("Registered!");
-}, function(e) {
-       console.log("Registration failed with error: " + e);
-})
-.catch(function(e) {
-       console.log("Exception registering: " + e);
-});
-
-navigator.serviceWorker.register("resources/empty-worker-doesnt-exist.js", { })
-.then(function(r) {
-       console.log("Registered!");
        done();
 }, function(e) {
        console.log("Registration failed with error: " + e);
index 8e3e02d..127a3db 100644 (file)
@@ -48,8 +48,8 @@ for (var i = 0; i < 1000; ++i) {
                console.log("Original window resolved successfully (unexpected)")
                done();
        }, function(e) {
-               if (e+"" != "UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 bytes, but we're not using the result yet") {
-                       alert("Unexpected error received from server: " + e);
+               if (e+"" != "UnknownError: serviceWorker job scheduling is not yet implemented") {
+                       alert("Unexpected error received from server");
                        finishSWTest();
                }
                
index 31cff43..dd183f1 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-06  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r221461.
+
+        The LayoutTest added with this change crashes under
+        GuardMalloc.
+
+        Reverted changeset:
+
+        "Add (entirely incorrect) fetching of ServiceWorker scripts."
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+        http://trac.webkit.org/changeset/221461
+
 2017-09-06  Devin Rousso  <webkit@devinrousso.com>
 
         Web Inspector: Support overloaded CanvasRenderingContext2D actions with identical parameter counts
index b422223..8ac0c03 100644 (file)
                517A53461F50C17F00DCDC0A /* SWServerWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53421F50C16100DCDC0A /* SWServerWorker.h */; settings = {ATTRIBUTES = (Private, ); }; };
                517A534E1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */; };
                517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
                517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
                517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
                517A63C51B74318F00E7DCDC /* KeyedDecoderCF.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */; settings = {ATTRIBUTES = (Private, ); }; };
                517A53431F50C16100DCDC0A /* SWServerWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SWServerWorker.cpp; sourceTree = "<group>"; };
                517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerRegistrationData.cpp; sourceTree = "<group>"; };
                517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerRegistrationData.h; sourceTree = "<group>"; };
-               517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetchResult.h; sourceTree = "<group>"; };
                517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedDecoderCF.cpp; sourceTree = "<group>"; };
                517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
                517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedEncoderCF.cpp; sourceTree = "<group>"; };
                                51F175581F3EBC0C00C74950 /* ServiceWorkerContainer.cpp */,
                                51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */,
                                51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
-                               517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
                                51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
                                51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
                                51F175531F3EBC0C00C74950 /* ServiceWorkerGlobalScope.idl */,
index c569bed..5c1ecdf 100644 (file)
@@ -32,9 +32,7 @@
 #include "IDLTypes.h"
 #include "JSDOMPromiseDeferred.h"
 #include "JSServiceWorkerRegistration.h"
-#include "Logging.h"
 #include "NavigatorBase.h"
-#include "ResourceError.h"
 #include "ScopeGuard.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
@@ -183,35 +181,6 @@ void ServiceWorkerContainer::jobResolvedWithRegistration(ServiceWorkerJob& job,
     job.promise().resolve<IDLInterface<ServiceWorkerRegistration>>(registration.get());
 }
 
-void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
-{
-    LOG(ServiceWorker, "SeviceWorkerContainer %p starting script fetch for job %" PRIu64, this, job.data().identifier());
-
-    auto* context = scriptExecutionContext();
-    if (!context) {
-        LOG_ERROR("ServiceWorkerContainer::jobResolvedWithRegistration called but the container's ScriptExecutionContext is gone");
-        m_swConnection->failedFetchingScript(job, { errorDomainWebKitInternal, 0, job.data().scriptURL, ASCIILiteral("Attempt to fetch service worker script with no ScriptExecutionContext") });
-        jobDidFinish(job);
-        return;
-    }
-
-    job.fetchScriptWithContext(*context);
-}
-
-void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, Ref<SharedBuffer>&& data)
-{
-    LOG(ServiceWorker, "SeviceWorkerContainer %p finished fetching script for job %" PRIu64, this, job.data().identifier());
-
-    m_swConnection->finishedFetchingScript(job, data.get());
-}
-
-void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const ResourceError& error)
-{
-    LOG(ServiceWorker, "SeviceWorkerContainer %p failed fetching script for job %" PRIu64, this, job.data().identifier());
-
-    m_swConnection->failedFetchingScript(job, error);
-}
-
 void ServiceWorkerContainer::jobDidFinish(ServiceWorkerJob& job)
 {
     auto taken = m_jobMap.take(job.data().identifier());
index e646b4c..ecdfd14 100644 (file)
@@ -73,10 +73,6 @@ private:
 
     void jobFailedWithException(ServiceWorkerJob&, const Exception&) final;
     void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) final;
-    void startScriptFetchForJob(ServiceWorkerJob&) final;
-    void jobFinishedLoadingScript(ServiceWorkerJob&, Ref<SharedBuffer>&&) final;
-    void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) final;
-
     void jobDidFinish(ServiceWorkerJob&);
 
     uint64_t connectionIdentifier() final;
diff --git a/Source/WebCore/workers/service/ServiceWorkerFetchResult.h b/Source/WebCore/workers/service/ServiceWorkerFetchResult.h
deleted file mode 100644 (file)
index 2a93a47..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(SERVICE_WORKER)
-
-#include "ResourceError.h"
-#include "ServiceWorkerRegistrationKey.h"
-#include <wtf/Vector.h>
-
-namespace WebCore {
-
-struct ServiceWorkerFetchResult {
-    uint64_t jobIdentifier;
-    uint64_t connectionIdentifier;
-    ServiceWorkerRegistrationKey registrationKey;
-    Vector<uint8_t> scriptData;
-    ResourceError scriptError;
-
-    template<class Encoder> void encode(Encoder&) const;
-    template<class Decoder> static bool decode(Decoder&, ServiceWorkerFetchResult&);
-};
-
-template<class Encoder>
-void ServiceWorkerFetchResult::encode(Encoder& encoder) const
-{
-    encoder << jobIdentifier << connectionIdentifier << registrationKey << scriptData << scriptError;
-}
-
-template<class Decoder>
-bool ServiceWorkerFetchResult::decode(Decoder& decoder, ServiceWorkerFetchResult& result)
-{
-    if (!decoder.decode(result.jobIdentifier))
-        return false;
-    if (!decoder.decode(result.connectionIdentifier))
-        return false;
-    if (!decoder.decode(result.registrationKey))
-        return false;
-    if (!decoder.decode(result.scriptData))
-        return false;
-    if (!decoder.decode(result.scriptError))
-        return false;
-
-    return true;
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SERVICE_WORKER)
index b41eaa0..49fb08e 100644 (file)
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "FetchHeaders.h"
-#include "FetchLoader.h"
-#include "FetchRequest.h"
 #include "JSDOMPromiseDeferred.h"
-#include "ResourceError.h"
-#include "ResourceResponse.h"
 #include "ServiceWorkerJobData.h"
 #include "ServiceWorkerRegistration.h"
 
@@ -69,80 +64,6 @@ void ServiceWorkerJob::resolvedWithRegistration(const ServiceWorkerRegistrationD
     m_client->jobResolvedWithRegistration(*this, data);
 }
 
-void ServiceWorkerJob::startScriptFetch()
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-
-    m_client->startScriptFetchForJob(*this);
-}
-
-void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context)
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-
-    m_fetchLoader = std::make_unique<FetchLoader>(*this, nullptr);
-
-    // FIXME: This Fetch request is set up incorrectly and without proper care.
-    // The ServiceWorkers spec specifics many details to apply here.
-
-    auto fetchHeaders = FetchHeaders::create();
-    auto referrer = m_jobData.clientCreationURL.string();
-    auto fetchRequest = FetchRequest::create(context, std::nullopt, WTFMove(fetchHeaders), { m_jobData.scriptURL }, { }, WTFMove(referrer));
-
-    m_fetchLoader->start(context, fetchRequest);
-}
-
-void ServiceWorkerJob::didReceiveResponse(const ResourceResponse& response)
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
-    ASSERT(!m_scriptData);
-
-    m_lastResponse = response;
-
-    if (response.httpStatusCode() < 200 || response.httpStatusCode() > 399) {
-        auto message = makeString(ASCIILiteral("ServiceWorker script network fetch failed with HTTP status code "), String::number(response.httpStatusCode()));
-        didFail({ errorDomainWebKitInternal, 0, m_lastResponse.url(), message });
-    }
-}
-
-void ServiceWorkerJob::didReceiveData(const char* data, size_t size)
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
-
-    if (!m_scriptData)
-        m_scriptData = SharedBuffer::create();
-
-    m_scriptData->get().append(data, size);
-}
-
-void ServiceWorkerJob::didSucceed()
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
-
-    if (!m_scriptData)
-        m_scriptData = SharedBuffer::create();
-    m_client->jobFinishedLoadingScript(*this, WTFMove(*m_scriptData));
-    m_fetchLoader = nullptr;
-}
-
-void ServiceWorkerJob::didFail(const ResourceError& error)
-{
-    ASSERT(currentThread() == m_creationThread);
-    ASSERT(!m_completed);
-    ASSERT(m_fetchLoader);
-
-    m_client->jobFailedLoadingScript(*this, error);
-    m_fetchLoader = nullptr;
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index 71f6779..d97ac1a 100644 (file)
@@ -27,9 +27,6 @@
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "FetchLoader.h"
-#include "FetchLoaderClient.h"
-#include "ResourceResponse.h"
 #include "ServiceWorkerJobClient.h"
 #include "ServiceWorkerJobData.h"
 #include <wtf/RefPtr.h>
@@ -41,11 +38,10 @@ namespace WebCore {
 
 class DeferredPromise;
 class Exception;
-class ScriptExecutionContext;
 enum class ServiceWorkerJobType;
 struct ServiceWorkerRegistrationData;
 
-class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public FetchLoaderClient {
+class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob> {
 public:
     static Ref<ServiceWorkerJob> create(ServiceWorkerJobClient& client, Ref<DeferredPromise>&& promise, ServiceWorkerJobData&& jobData)
     {
@@ -56,22 +52,13 @@ 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&&);
 
-    // FetchLoaderClient
-    void didReceiveResponse(const ResourceResponse&) final;
-    void didReceiveData(const char*, size_t) final;
-    void didSucceed() final;
-    void didFail(const ResourceError&) final;
-
     Ref<ServiceWorkerJobClient> m_client;
     ServiceWorkerJobData m_jobData;
     Ref<DeferredPromise> m_promise;
@@ -79,9 +66,6 @@ private:
     bool m_completed { false };
 
     Ref<RunLoop> m_runLoop { RunLoop::current() };
-    std::unique_ptr<FetchLoader> m_fetchLoader;
-    ResourceResponse m_lastResponse;
-    std::optional<Ref<SharedBuffer>> m_scriptData;
 
 #if !ASSERT_DISABLED
     ThreadIdentifier m_creationThread { currentThread() };
index 8e5b44e..6280f0c 100644 (file)
@@ -30,9 +30,7 @@
 namespace WebCore {
 
 class Exception;
-class ResourceError;
 class ServiceWorkerJob;
-class SharedBuffer;
 struct ServiceWorkerRegistrationData;
 
 class ServiceWorkerJobClient {
@@ -41,9 +39,6 @@ public:
 
     virtual void jobFailedWithException(ServiceWorkerJob&, const Exception&) = 0;
     virtual void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) = 0;
-    virtual void startScriptFetchForJob(ServiceWorkerJob&) = 0;
-    virtual void jobFinishedLoadingScript(ServiceWorkerJob&, Ref<SharedBuffer>&&) = 0;
-    virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) = 0;
 
     virtual uint64_t connectionIdentifier() = 0;
 
index 8d94477..4702bbb 100644 (file)
@@ -29,7 +29,6 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "ExceptionData.h"
-#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
 
 namespace WebCore {
@@ -50,22 +49,6 @@ void SWClientConnection::scheduleJob(ServiceWorkerJob& job)
     scheduleJobInServer(job.data());
 }
 
-void SWClientConnection::finishedFetchingScript(ServiceWorkerJob& job, SharedBuffer& data)
-{
-    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
-
-    Vector<uint8_t> vector;
-    vector.append(reinterpret_cast<const uint8_t *>(data.data()), data.size());
-    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), vector, { } });
-}
-
-void SWClientConnection::failedFetchingScript(ServiceWorkerJob& job, const ResourceError& error)
-{
-    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
-
-    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), { }, error });
-}
-
 void SWClientConnection::jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData& exceptionData)
 {
     auto job = m_scheduledJobs.take(jobIdentifier);
@@ -88,22 +71,6 @@ void SWClientConnection::jobResolvedInServer(uint64_t jobIdentifier, const Servi
     job->resolvedWithRegistration(registrationData);
 }
 
-void SWClientConnection::startScriptFetchForServer(uint64_t jobIdentifier)
-{
-    auto job = m_scheduledJobs.get(jobIdentifier);
-    if (!job) {
-        LOG_ERROR("Job %" PRIu64 " instructed to start fetch from server, but job was not found", jobIdentifier);
-
-        // FIXME: Should message back to the server here to signal failure to fetch,
-        // but we currently need the registration key to do so, and don't have it here.
-        // In the future we'll refactor to have a global, cross-process job identifier that can be used to overcome this.
-
-        return;
-    }
-
-    job->startScriptFetch();
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)
index 3b854eb..b91e042 100644 (file)
 
 namespace WebCore {
 
-class ResourceError;
-class SharedBuffer;
 struct ExceptionData;
-struct ServiceWorkerFetchResult;
 struct ServiceWorkerRegistrationData;
 
 class SWClientConnection : public ThreadSafeRefCounted<SWClientConnection> {
@@ -45,19 +42,15 @@ public:
     WEBCORE_EXPORT virtual ~SWClientConnection();
 
     void scheduleJob(ServiceWorkerJob&);
-    void finishedFetchingScript(ServiceWorkerJob&, SharedBuffer&);
-    void failedFetchingScript(ServiceWorkerJob&, const ResourceError&);
 
     virtual uint64_t identifier() const = 0;
 
 protected:
     WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
     WEBCORE_EXPORT void jobResolvedInServer(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&);
-    WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
 
 private:
     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
-    virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
 
     HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
 };
index 6f81ab2..4019340 100644 (file)
@@ -32,7 +32,6 @@
 #include "ExceptionData.h"
 #include "Logging.h"
 #include "SWServerRegistration.h"
-#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerJobData.h"
 #include <wtf/text/WTFString.h>
 
@@ -73,11 +72,6 @@ void SWServer::Connection::scheduleJobInServer(const ServiceWorkerJobData& jobDa
     m_server.scheduleJob(jobData);
 }
 
-void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
-{
-    m_server.scriptFetchFinished(result);
-}
-
 SWServer::SWServer()
 {
     m_taskThread = Thread::create(ASCIILiteral("ServiceWorker Task Thread"), [this] {
@@ -118,29 +112,6 @@ void SWServer::resolveJob(const ServiceWorkerJobData& jobData, const ServiceWork
     connection->resolveJobInClient(jobData.identifier(), registrationData);
 }
 
-void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
-{
-    LOG(ServiceWorker, "Server issuing startScriptFetch for current job %" PRIu64 "-%" PRIu64 " in client", jobData.connectionIdentifier(), jobData.identifier());
-    auto* connection = m_connections.get(jobData.connectionIdentifier());
-    if (!connection)
-        return;
-
-    connection->startScriptFetchInClient(jobData.identifier());
-}
-
-void SWServer::scriptFetchFinished(const ServiceWorkerFetchResult& result)
-{
-    LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier);
-
-    ASSERT(m_connections.contains(result.connectionIdentifier));
-
-    auto registration = m_registrations.get(result.registrationKey);
-    if (!registration)
-        return;
-
-    registration->scriptFetchFinished(result);
-}
-
 void SWServer::taskThreadEntryPoint()
 {
     ASSERT(!isMainThread());
index a1fc5d3..9bd40f7 100644 (file)
@@ -43,7 +43,6 @@ namespace WebCore {
 
 class SWServerRegistration;
 struct ExceptionData;
-struct ServiceWorkerFetchResult;
 struct ServiceWorkerRegistrationData;
 
 class SWServer {
@@ -58,12 +57,10 @@ public:
         SWServer& server() { return m_server; }
 
         WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
-        WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
 
     private:
         virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
         virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
-        virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
 
         SWServer& m_server;
     };
@@ -74,8 +71,6 @@ public:
     void scheduleJob(const ServiceWorkerJobData&);
     void rejectJob(const ServiceWorkerJobData&, const ExceptionData&);
     void resolveJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&);
-    void startScriptFetch(const ServiceWorkerJobData&);
-
     void postTask(CrossThreadTask&&);
     void postTaskReply(CrossThreadTask&&);
 
@@ -86,8 +81,6 @@ private:
     void taskThreadEntryPoint();
     void handleTaskRepliesOnMainThread();
 
-    void scriptFetchFinished(const ServiceWorkerFetchResult&);
-
     HashMap<uint64_t, Connection*> m_connections;
     HashMap<ServiceWorkerRegistrationKey, std::unique_ptr<SWServerRegistration>> m_registrations;
 
index 7432afa..1052b9b 100644 (file)
@@ -32,7 +32,6 @@
 #include "SWServer.h"
 #include "SWServerWorker.h"
 #include "SecurityOrigin.h"
-#include "ServiceWorkerFetchResult.h"
 #include "ServiceWorkerRegistrationData.h"
 #include "WorkerType.h"
 
@@ -64,22 +63,6 @@ void SWServerRegistration::enqueueJob(const ServiceWorkerJobData& jobData)
         m_jobTimer.startOneShot(0_s);
 }
 
-void SWServerRegistration::scriptFetchFinished(const ServiceWorkerFetchResult& result)
-{
-    ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);
-
-    // FIXME: We fetched the script contents but don't do anything with them yet.
-    // These errors are for testing the current state of the feature.
-
-    String message;
-    if (result.scriptError.isNull())
-        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetched with ", String::number(result.scriptData.size()), " bytes, but we're not using the result yet");
-    else
-        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription());
-
-    rejectCurrentJob(ExceptionData { UnknownError, message });
-}
-
 void SWServerRegistration::startNextJob()
 {
     ASSERT(isMainThread());
@@ -166,7 +149,9 @@ void SWServerRegistration::runUpdateJob(const ServiceWorkerJobData& job)
     if (newestWorker && !equalIgnoringFragmentIdentifier(job.scriptURL, newestWorker->scriptURL()))
         return rejectWithExceptionOnMainThread(ExceptionData { TypeError, ASCIILiteral("Cannot update a service worker with a requested script URL whose newest worker has a different script URL") });
 
-    startScriptFetchFromMainThread();
+    // FIXME: At this point we are ready to actually fetch the script for the worker in the registering context.
+    // For now we're still hard coding the same rejection we have so far.
+    rejectWithExceptionOnMainThread(ExceptionData { UnknownError, ASCIILiteral("serviceWorker job scheduling is not yet implemented") });
 }
 
 void SWServerRegistration::rejectWithExceptionOnMainThread(const ExceptionData& exception)
@@ -181,12 +166,6 @@ void SWServerRegistration::resolveWithRegistrationOnMainThread()
     m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::resolveCurrentJob, data()));
 }
 
-void SWServerRegistration::startScriptFetchFromMainThread()
-{
-    ASSERT(!isMainThread());
-    m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::startScriptFetchForCurrentJob));
-}
-
 void SWServerRegistration::rejectCurrentJob(const ExceptionData& exceptionData)
 {
     ASSERT(isMainThread());
@@ -207,14 +186,6 @@ void SWServerRegistration::resolveCurrentJob(const ServiceWorkerRegistrationData
     finishCurrentJob();
 }
 
-void SWServerRegistration::startScriptFetchForCurrentJob()
-{
-    ASSERT(isMainThread());
-    ASSERT(m_currentJob);
-
-    m_server.startScriptFetch(*m_currentJob);
-}
-
 void SWServerRegistration::finishCurrentJob()
 {
     ASSERT(m_currentJob);
index f768546..9b6eabf 100644 (file)
@@ -38,7 +38,6 @@ namespace WebCore {
 class SWServer;
 class SWServerWorker;
 struct ExceptionData;
-struct ServiceWorkerFetchResult;
 
 class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
 public:
@@ -47,7 +46,6 @@ public:
     ~SWServerRegistration();
 
     void enqueueJob(const ServiceWorkerJobData&);
-    void scriptFetchFinished(const ServiceWorkerFetchResult&);
 
     ServiceWorkerRegistrationData data() const;
 
@@ -56,7 +54,6 @@ private:
     void startNextJob();
     void rejectCurrentJob(const ExceptionData&);
     void resolveCurrentJob(const ServiceWorkerRegistrationData&);
-    void startScriptFetchForCurrentJob();
     void finishCurrentJob();
 
     void runRegisterJob(const ServiceWorkerJobData&);
@@ -64,7 +61,6 @@ private:
 
     void rejectWithExceptionOnMainThread(const ExceptionData&);
     void resolveWithRegistrationOnMainThread();
-    void startScriptFetchFromMainThread();
     bool isEmpty();
     SWServerWorker* getNewestWorker();
 
index 90fe264..d1f8470 100644 (file)
@@ -1,3 +1,16 @@
+2017-09-06  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, rolling out r221461.
+
+        The LayoutTest added with this change crashes under
+        GuardMalloc.
+
+        Reverted changeset:
+
+        "Add (entirely incorrect) fetching of ServiceWorker scripts."
+        https://bugs.webkit.org/show_bug.cgi?id=176179
+        http://trac.webkit.org/changeset/221461
+
 2017-09-06  Alex Christensen  <achristensen@webkit.org>
 
         Add modern decoders for POD types
index d8e6c24..da215f1 100644 (file)
@@ -28,7 +28,6 @@
 
 #if ENABLE(SERVICE_WORKER)
 
-#include "DataReference.h"
 #include "Logging.h"
 #include "StorageToWebProcessConnectionMessages.h"
 #include "WebProcess.h"
@@ -71,11 +70,6 @@ void WebSWServerConnection::resolveJobInClient(uint64_t jobIdentifier, const Ser
     send(Messages::WebSWClientConnection::JobResolvedInServer(jobIdentifier, registrationData));
 }
 
-void WebSWServerConnection::startScriptFetchInClient(uint64_t jobIdentifier)
-{
-    send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
-}
-
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)
index b3ce76c..c879251 100644 (file)
@@ -51,7 +51,6 @@ private:
     // Implement SWServer::Connection
     void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
     void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
-    void startScriptFetchInClient(uint64_t jobIdentifier) final;
 
     IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
     uint64_t messageSenderDestinationID() final { return identifier(); }
index e4cfb96..0571c4d 100644 (file)
@@ -25,7 +25,6 @@
 messages -> WebSWServerConnection {
     # When possible, these messages can be implemented directly by WebCore::SWClientConnection
     ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
-    FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
 }
 
 #endif // ENABLE(SERVICE_WORKER)
index bb3db6b..182649a 100644 (file)
@@ -30,9 +30,7 @@
 
 #include "Logging.h"
 #include "StorageToWebProcessConnectionMessages.h"
-#include "WebCoreArgumentCoders.h"
 #include "WebSWServerConnectionMessages.h"
-#include <WebCore/ServiceWorkerFetchResult.h>
 #include <WebCore/ServiceWorkerJobData.h>
 
 using namespace PAL;
@@ -58,11 +56,6 @@ void WebSWClientConnection::scheduleJobInServer(const ServiceWorkerJobData& jobD
     send(Messages::WebSWServerConnection::ScheduleJobInServer(jobData));
 }
 
-void WebSWClientConnection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
-{
-    send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result));
-}
-
 } // namespace WebKit
 
 #endif // ENABLE(SERVICE_WORKER)
index 44af779..51de4bb 100644 (file)
@@ -48,7 +48,6 @@ public:
     uint64_t identifier() const final { return m_identifier; }
 
     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
-    void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
 
     void disconnectedFromWebProcess();
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
index 40f7730..adef99a 100644 (file)
@@ -26,7 +26,6 @@ messages -> WebSWClientConnection {
     # When possible, these messages can be implemented directly by WebCore::SWServer::Connection
     JobRejectedInServer(uint64_t identifier, struct WebCore::ExceptionData exception)
     JobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
-    StartScriptFetchForServer(uint64_t jobIdentifier)
 }
 
 #endif // ENABLE(SERVICE_WORKER)