Changeset 222980 in webkit


Ignore:
Timestamp:
Oct 6, 2017 9:20:04 AM (6 years ago)
Author:
beidson@apple.com
Message:

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

Reviewed by Andy Estes.

Source/WebCore:

No new tests (Covered by changes to existing tests).

When the Storage process is running the "Update" algorithm and a ServiceWorker script file needs to be fetched, this patch:

  • Messages back to the WebContent process that started the register/update job
  • Executes a FetchLoad in that script context for the script
  • Sends the results back to the Storage process

We don't do anything with the results yet.

Soon.

  • WebCore.xcodeproj/project.pbxproj:
  • workers/WorkerScriptLoader.cpp:

(WebCore::WorkerScriptLoader::didFail):

  • workers/WorkerScriptLoader.h:

(WebCore::WorkerScriptLoader::error const):

  • workers/WorkerScriptLoaderClient.h:

(WebCore::WorkerScriptLoaderClient::~WorkerScriptLoaderClient):
(WebCore::WorkerScriptLoaderClient::didReceiveResponse): Deleted.
(WebCore::WorkerScriptLoaderClient::notifyFinished): Deleted.

  • workers/service/ServiceWorkerContainer.cpp:

(WebCore::ServiceWorkerContainer::startScriptFetchForJob):
(WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
(WebCore::ServiceWorkerContainer::jobFailedLoadingScript):

  • workers/service/ServiceWorkerContainer.h:
  • workers/service/ServiceWorkerFetchResult.h: Copied from Source/WebCore/workers/service/server/SWClientConnection.h.

(WebCore::ServiceWorkerFetchResult::encode const):
(WebCore::ServiceWorkerFetchResult::decode):

  • workers/service/ServiceWorkerJob.cpp:

(WebCore::ServiceWorkerJob::startScriptFetch):
(WebCore::ServiceWorkerJob::fetchScriptWithContext):
(WebCore::ServiceWorkerJob::didReceiveResponse):
(WebCore::ServiceWorkerJob::notifyFinished):

  • workers/service/ServiceWorkerJob.h:
  • workers/service/ServiceWorkerJobClient.h:
  • workers/service/server/SWClientConnection.cpp:

(WebCore::SWClientConnection::finishedFetchingScript):
(WebCore::SWClientConnection::failedFetchingScript):
(WebCore::SWClientConnection::startScriptFetchForServer):

  • workers/service/server/SWClientConnection.h:
  • workers/service/server/SWServer.cpp:

(WebCore::SWServer::Connection::finishFetchingScriptInServer):
(WebCore::SWServer::startScriptFetch):
(WebCore::SWServer::scriptFetchFinished):

  • workers/service/server/SWServer.h:
  • workers/service/server/SWServerRegistration.cpp:

(WebCore::SWServerRegistration::scriptFetchFinished):
(WebCore::SWServerRegistration::runUpdateJob):
(WebCore::SWServerRegistration::startScriptFetchFromMainThread):
(WebCore::SWServerRegistration::startScriptFetchForCurrentJob):

  • workers/service/server/SWServerRegistration.h:

Source/WebKit:

  • StorageProcess/ServiceWorker/WebSWServerConnection.cpp:

(WebKit::WebSWServerConnection::startScriptFetchInClient):

  • StorageProcess/ServiceWorker/WebSWServerConnection.h:
  • StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
  • WebProcess/Storage/WebSWClientConnection.cpp:

(WebKit::WebSWClientConnection::finishFetchingScriptInServer):

  • WebProcess/Storage/WebSWClientConnection.h:
  • WebProcess/Storage/WebSWClientConnection.messages.in:

LayoutTests:

  • http/tests/workers/service/basic-register-exceptions-expected.txt:
  • http/tests/workers/service/basic-register-expected.txt:
  • http/tests/workers/service/resources/basic-register-exceptions.js:
  • http/tests/workers/service/resources/basic-register.js:
  • http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
Location:
trunk
Files:
29 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222979 r222980  
     12017-10-06  Brady Eidson  <beidson@apple.com>
     2
     3        Add (entirely incorrect) fetching of ServiceWorker scripts.
     4        https://bugs.webkit.org/show_bug.cgi?id=176179
     5
     6        Reviewed by Andy Estes.
     7
     8        * http/tests/workers/service/basic-register-exceptions-expected.txt:
     9        * http/tests/workers/service/basic-register-expected.txt:
     10        * http/tests/workers/service/resources/basic-register-exceptions.js:
     11        * http/tests/workers/service/resources/basic-register.js:
     12        * http/tests/workers/service/resources/registration-task-queue-scheduling-1.js:
     13
    1142017-10-06  Ryan Haddad  <ryanhaddad@apple.com>
    215
  • trunk/LayoutTests/http/tests/workers/service/basic-register-exceptions-expected.txt

    r221392 r222980  
    1 CONSOLE MESSAGE: line 10: Registration failed with error: TypeError: serviceWorker.register() cannot be called with an empty script URL
    2 CONSOLE MESSAGE: line 20: Registration failed with error: TypeError: serviceWorker.register() must be called with a valid relative script URL
    3 CONSOLE MESSAGE: line 30: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose protocol is either HTTP or HTTPS
    4 CONSOLE MESSAGE: line 40: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose path does not contain '%2f' or '%5c'
    5 CONSOLE MESSAGE: line 50: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS
    6 CONSOLE MESSAGE: line 60: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() cannot have a path that contains '%2f' or '%5c'
    7 CONSOLE MESSAGE: line 70: Registration failed with error: SecurityError: Script origin does not match the registering client's origin
    8 CONSOLE MESSAGE: line 81: Registration failed with error: SecurityError: Scope origin does not match the registering client's origin
     1CONSOLE MESSAGE: line 20: Registration failed with error: TypeError: serviceWorker.register() cannot be called with an empty script URL
     2CONSOLE MESSAGE: line 30: Registration failed with error: TypeError: serviceWorker.register() must be called with a valid relative script URL
     3CONSOLE MESSAGE: line 40: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose protocol is either HTTP or HTTPS
     4CONSOLE MESSAGE: line 50: Registration failed with error: TypeError: serviceWorker.register() must be called with a script URL whose path does not contain '%2f' or '%5c'
     5CONSOLE MESSAGE: line 60: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() must be either HTTP or HTTPS
     6CONSOLE MESSAGE: line 70: Registration failed with error: TypeError: Scope URL provided to serviceWorker.register() cannot have a path that contains '%2f' or '%5c'
     7CONSOLE MESSAGE: line 10: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/image-mime-type.php fetched with 0 characters, but we're not using the result yet
     8CONSOLE MESSAGE: line 80: Registration failed with error: SecurityError: Script origin does not match the registering client's origin
     9CONSOLE MESSAGE: line 91: Registration failed with error: SecurityError: Scope origin does not match the registering client's origin
    910
  • trunk/LayoutTests/http/tests/workers/service/basic-register-expected.txt

    r221699 r222980  
    1 CONSOLE MESSAGE: line 11: Registration failed with error: UnknownError: serviceWorker job scheduling is not yet implemented
     1CONSOLE 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 characters, but we're not using the result yet
     2CONSOLE MESSAGE: line 21: Registration failed with error: UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker-doesnt-exist.js fetched with 0 characters, but we're not using the result yet
    23
  • trunk/LayoutTests/http/tests/workers/service/resources/basic-register-exceptions.js

    r221392 r222980  
    33    finishSWTest();
    44}
     5
     6navigator.serviceWorker.register("image-mime-type.php", { })
     7.then(function(r) {
     8        console.log("Registered! (unexpectedly)");
     9}, function(e) {
     10        console.log("Registration failed with error: " + e);
     11})
     12.catch(function(e) {
     13        console.log("Exception registering: " + e);
     14});
    515
    616navigator.serviceWorker.register("", { })
  • trunk/LayoutTests/http/tests/workers/service/resources/basic-register.js

    r221699 r222980  
    55
    66navigator.serviceWorker.register("resources/empty-worker.js", { })
     7.then(function(r) {
     8        console.log("Registered!");
     9}, function(e) {
     10        console.log("Registration failed with error: " + e);
     11})
     12.catch(function(e) {
     13        console.log("Exception registering: " + e);
     14});
     15
     16navigator.serviceWorker.register("resources/empty-worker-doesnt-exist.js", { })
    717.then(function(r) {
    818        console.log("Registered!");
  • trunk/LayoutTests/http/tests/workers/service/resources/registration-task-queue-scheduling-1.js

    r221699 r222980  
    4949                done();
    5050        }, function(e) {
    51                 if (e+"" != "UnknownError: serviceWorker job scheduling is not yet implemented") {
    52                         alert("Unexpected error received from server");
     51                if (e+"" != "UnknownError: Script URL http://127.0.0.1:8000/workers/service/resources/empty-worker.js fetched with 41 characters, but we're not using the result yet") {
     52                        alert("Unexpected error received from server: " + e);
    5353                        finishSWTest();
    5454                }
  • trunk/Source/WebCore/ChangeLog

    r222975 r222980  
     12017-10-06  Brady Eidson  <beidson@apple.com>
     2
     3        Add (entirely incorrect) fetching of ServiceWorker scripts.
     4        https://bugs.webkit.org/show_bug.cgi?id=176179
     5
     6        Reviewed by Andy Estes.
     7
     8        No new tests (Covered by changes to existing tests).
     9
     10        When the Storage process is running the "Update" algorithm and a ServiceWorker script file needs to be fetched, this patch:
     11          - Messages back to the WebContent process that started the register/update job
     12          - Executes a FetchLoad in that script context for the script
     13          - Sends the results back to the Storage process
     14
     15        We don't do anything with the results yet.
     16
     17        Soon.
     18
     19        * WebCore.xcodeproj/project.pbxproj:
     20
     21        * workers/WorkerScriptLoader.cpp:
     22        (WebCore::WorkerScriptLoader::didFail):
     23        * workers/WorkerScriptLoader.h:
     24        (WebCore::WorkerScriptLoader::error const):
     25
     26        * workers/WorkerScriptLoaderClient.h:
     27        (WebCore::WorkerScriptLoaderClient::~WorkerScriptLoaderClient):
     28        (WebCore::WorkerScriptLoaderClient::didReceiveResponse): Deleted.
     29        (WebCore::WorkerScriptLoaderClient::notifyFinished): Deleted.
     30
     31        * workers/service/ServiceWorkerContainer.cpp:
     32        (WebCore::ServiceWorkerContainer::startScriptFetchForJob):
     33        (WebCore::ServiceWorkerContainer::jobFinishedLoadingScript):
     34        (WebCore::ServiceWorkerContainer::jobFailedLoadingScript):
     35        * workers/service/ServiceWorkerContainer.h:
     36
     37        * workers/service/ServiceWorkerFetchResult.h: Copied from Source/WebCore/workers/service/server/SWClientConnection.h.
     38        (WebCore::ServiceWorkerFetchResult::encode const):
     39        (WebCore::ServiceWorkerFetchResult::decode):
     40
     41        * workers/service/ServiceWorkerJob.cpp:
     42        (WebCore::ServiceWorkerJob::startScriptFetch):
     43        (WebCore::ServiceWorkerJob::fetchScriptWithContext):
     44        (WebCore::ServiceWorkerJob::didReceiveResponse):
     45        (WebCore::ServiceWorkerJob::notifyFinished):
     46        * workers/service/ServiceWorkerJob.h:
     47        * workers/service/ServiceWorkerJobClient.h:
     48
     49        * workers/service/server/SWClientConnection.cpp:
     50        (WebCore::SWClientConnection::finishedFetchingScript):
     51        (WebCore::SWClientConnection::failedFetchingScript):
     52        (WebCore::SWClientConnection::startScriptFetchForServer):
     53        * workers/service/server/SWClientConnection.h:
     54
     55        * workers/service/server/SWServer.cpp:
     56        (WebCore::SWServer::Connection::finishFetchingScriptInServer):
     57        (WebCore::SWServer::startScriptFetch):
     58        (WebCore::SWServer::scriptFetchFinished):
     59        * workers/service/server/SWServer.h:
     60
     61        * workers/service/server/SWServerRegistration.cpp:
     62        (WebCore::SWServerRegistration::scriptFetchFinished):
     63        (WebCore::SWServerRegistration::runUpdateJob):
     64        (WebCore::SWServerRegistration::startScriptFetchFromMainThread):
     65        (WebCore::SWServerRegistration::startScriptFetchForCurrentJob):
     66        * workers/service/server/SWServerRegistration.h:
     67
    1682017-10-06  Zan Dobersek  <zdobersek@igalia.com>
    269
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r222946 r222980  
    13211321                2E94F43C119207DA00B7F75D /* JSFileReader.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E94F43A119207DA00B7F75D /* JSFileReader.h */; };
    13221322                2E9B5D8F1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 2E9B5D8E1B66A94E008C6A24 /* WheelEventDeltaFilterMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1323                 2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; };
     1323                2EA768040FE7126400AB9C8A /* WorkerScriptLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EA768030FE7126400AB9C8A /* WorkerScriptLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
    13241324                2EB4BCD2121F03E300EC4885 /* BlobResourceHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2EB4BCD0121F03E300EC4885 /* BlobResourceHandle.cpp */; };
    13251325                2EB4BCD3121F03E300EC4885 /* BlobResourceHandle.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EB4BCD1121F03E300EC4885 /* BlobResourceHandle.h */; };
     
    23442344                517A534E1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */; };
    23452345                517A534F1F54A8BA00DCDC0A /* ServiceWorkerRegistrationData.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2346                517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B61C89912600A7E715 /* FetchLoaderClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2347                517A535A1F5889EF00DCDC0A /* FetchLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 4147E2B51C89912600A7E715 /* FetchLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2348                517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */ = {isa = PBXBuildFile; fileRef = 41CF8BE51D46222000707DC9 /* FetchBodyConsumer.h */; settings = {ATTRIBUTES = (Private, ); }; };
     2349                517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */; settings = {ATTRIBUTES = (Private, ); }; };
    23462350                517A63C31B74318700E7DCDC /* KeyedDecoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */; };
    23472351                517A63C41B74318B00E7DCDC /* KeyedEncoderCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A63C11B74317E00E7DCDC /* KeyedEncoderCF.cpp */; };
     
    47034707                A7D20F63107F406900A80392 /* JSWebGLActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F61107F406900A80392 /* JSWebGLActiveInfo.h */; };
    47044708                A7D20F6D107F438B00A80392 /* WebGLActiveInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D20F6B107F438B00A80392 /* WebGLActiveInfo.h */; };
    4705                 A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */; };
     4709                A7D6B3490F61104500B79FD1 /* WorkerScriptLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = A7D6B3470F61104500B79FD1 /* WorkerScriptLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47064710                A7D6B34A0F61104500B79FD1 /* WorkerScriptLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D6B3480F61104500B79FD1 /* WorkerScriptLoader.cpp */; };
    47074711                A7DBF8DD1276919C006B6008 /* TextCheckingHelper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7DBF8DB1276919C006B6008 /* TextCheckingHelper.cpp */; };
     
    1026010264                517A534B1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ServiceWorkerRegistrationData.cpp; sourceTree = "<group>"; };
    1026110265                517A534C1F549D4A00DCDC0A /* ServiceWorkerRegistrationData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerRegistrationData.h; sourceTree = "<group>"; };
     10266                517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServiceWorkerFetchResult.h; sourceTree = "<group>"; };
    1026210267                517A63BF1B74317E00E7DCDC /* KeyedDecoderCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyedDecoderCF.cpp; sourceTree = "<group>"; };
    1026310268                517A63C01B74317E00E7DCDC /* KeyedDecoderCF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyedDecoderCF.h; sourceTree = "<group>"; };
     
    1917319178                                51F175571F3EBC0C00C74950 /* ServiceWorkerContainer.h */,
    1917419179                                51F175561F3EBC0C00C74950 /* ServiceWorkerContainer.idl */,
     19180                                517A535C1F5899F200DCDC0A /* ServiceWorkerFetchResult.h */,
    1917519181                                51F175551F3EBC0C00C74950 /* ServiceWorkerGlobalScope.cpp */,
    1917619182                                51F175541F3EBC0C00C74950 /* ServiceWorkerGlobalScope.h */,
     
    2814628152                                977B3867122883E900B81FF8 /* HTMLDocumentParser.h in Headers */,
    2814728153                                93F198E608245E59001E9ABC /* HTMLElement.h in Headers */,
     28154                                517A53581F5889E800DCDC0A /* FetchLoaderClient.h in Headers */,
    2814828155                                A17C81230F2A5CF7005DAAEB /* HTMLElementFactory.h in Headers */,
    2814928156                                977B37241228721700B81FF8 /* HTMLElementStack.h in Headers */,
     
    2932229329                                37C738EF1EDBD71B003F2B0B /* MathMLUnknownElement.h in Headers */,
    2932329330                                439046EA12DA25E812AF80AC /* MathOperator.h in Headers */,
     29331                                517A535B1F588A4C00DCDC0A /* FetchBodyConsumer.h in Headers */,
    2932429332                                49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
    2932529333                                49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */,
     
    2947729485                                A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */,
    2947829486                                628D214C12131ED10055DCFC /* NetworkingContext.h in Headers */,
     29487                                517A535D1F5899FE00DCDC0A /* ServiceWorkerFetchResult.h in Headers */,
    2947929488                                8A81BF8511DCFD9000DA2B98 /* NetworkLoadMetrics.h in Headers */,
    2948029489                                59C27F07138D28CF0079B7E2 /* NetworkResourcesData.h in Headers */,
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r219276 r222980  
    165165}
    166166
    167 void WorkerScriptLoader::didFail(const ResourceError&)
     167void WorkerScriptLoader::didFail(const ResourceError& error)
    168168{
     169    m_error = error;
    169170    notifyError();
    170171}
  • trunk/Source/WebCore/workers/WorkerScriptLoader.h

    r212993 r222980  
    2727#pragma once
    2828
    29 #include "URL.h"
     29#include "ResourceError.h"
    3030#include "ResourceRequest.h"
    3131#include "ThreadableLoader.h"
    3232#include "ThreadableLoaderClient.h"
     33#include "URL.h"
    3334#include <memory>
    3435#include <wtf/FastMalloc.h>
     
    3940namespace WebCore {
    4041
    41     class ResourceResponse;
    42     class ScriptExecutionContext;
    43     class TextResourceDecoder;
    44     class WorkerScriptLoaderClient;
     42class ResourceResponse;
     43class ScriptExecutionContext;
     44class TextResourceDecoder;
     45class WorkerScriptLoaderClient;
    4546
    46     class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public ThreadableLoaderClient {
    47         WTF_MAKE_FAST_ALLOCATED;
    48     public:
    49         static Ref<WorkerScriptLoader> create()
    50         {
    51             return adoptRef(*new WorkerScriptLoader);
    52         }
     47class WorkerScriptLoader : public RefCounted<WorkerScriptLoader>, public ThreadableLoaderClient {
     48    WTF_MAKE_FAST_ALLOCATED;
     49public:
     50    static Ref<WorkerScriptLoader> create()
     51    {
     52        return adoptRef(*new WorkerScriptLoader);
     53    }
    5354
    54         void loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
    55         void loadAsynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient*);
     55    void loadSynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier);
     56    void loadAsynchronously(ScriptExecutionContext*, const URL&, FetchOptions::Mode, ContentSecurityPolicyEnforcement, const String& initiatorIdentifier, WorkerScriptLoaderClient*);
    5657
    57         void notifyError();
     58    void notifyError();
    5859
    59         String script();
    60         const URL& url() const { return m_url; }
    61         const URL& responseURL() const;
    62         bool failed() const { return m_failed; }
    63         unsigned long identifier() const { return m_identifier; }
     60    String script();
     61    const URL& url() const { return m_url; }
     62    const URL& responseURL() const;
     63    bool failed() const { return m_failed; }
     64    unsigned long identifier() const { return m_identifier; }
     65    const ResourceError& error() const { return m_error; }
    6466
    65         void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override;
    66         void didReceiveData(const char* data, int dataLength) override;
    67         void didFinishLoading(unsigned long identifier) override;
    68         void didFail(const ResourceError&) override;
     67    void didReceiveResponse(unsigned long identifier, const ResourceResponse&) override;
     68    void didReceiveData(const char* data, int dataLength) override;
     69    void didFinishLoading(unsigned long identifier) override;
     70    void didFail(const ResourceError&) override;
    6971
    70     private:
    71         friend class WTF::RefCounted<WorkerScriptLoader>;
     72private:
     73    friend class WTF::RefCounted<WorkerScriptLoader>;
    7274
    73         WorkerScriptLoader();
    74         ~WorkerScriptLoader();
     75    WorkerScriptLoader();
     76    ~WorkerScriptLoader();
    7577
    76         std::unique_ptr<ResourceRequest> createResourceRequest(const String& initiatorIdentifier);
    77         void notifyFinished();
     78    std::unique_ptr<ResourceRequest> createResourceRequest(const String& initiatorIdentifier);
     79    void notifyFinished();
    7880
    79         WorkerScriptLoaderClient* m_client { nullptr };
    80         RefPtr<ThreadableLoader> m_threadableLoader;
    81         String m_responseEncoding;       
    82         RefPtr<TextResourceDecoder> m_decoder;
    83         StringBuilder m_script;
    84         URL m_url;
    85         URL m_responseURL;
    86         unsigned long m_identifier { 0 };
    87         bool m_failed { false };
    88         bool m_finishing { false };
    89     };
     81    WorkerScriptLoaderClient* m_client { nullptr };
     82    RefPtr<ThreadableLoader> m_threadableLoader;
     83    String m_responseEncoding;
     84    RefPtr<TextResourceDecoder> m_decoder;
     85    StringBuilder m_script;
     86    URL m_url;
     87    URL m_responseURL;
     88    unsigned long m_identifier { 0 };
     89    bool m_failed { false };
     90    bool m_finishing { false };
     91    ResourceError m_error;
     92};
    9093
    9194} // namespace WebCore
  • trunk/Source/WebCore/workers/WorkerScriptLoaderClient.h

    r207546 r222980  
    2929namespace WebCore {
    3030
    31     class ResourceResponse;
     31class ResourceResponse;
    3232
    33     class WorkerScriptLoaderClient {
    34     public:
    35         virtual void didReceiveResponse(unsigned long /*identifier*/, const ResourceResponse&) { }
     33class WorkerScriptLoaderClient {
     34public:
     35    virtual void didReceiveResponse(unsigned long identifier, const ResourceResponse&) = 0;
     36    virtual void notifyFinished() = 0;
    3637
    37         // FIXME: notifyFinished() is not currently guaranteed to be invoked if used from worker context and the worker shuts down in the middle of an operation.
    38         // This will cause leaks when we support nested workers.
    39         virtual void notifyFinished() { }
    40 
    41     protected:
    42         virtual ~WorkerScriptLoaderClient() { }
    43     };
     38protected:
     39    virtual ~WorkerScriptLoaderClient() { }
     40};
    4441
    4542} // namespace WebCore
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp

    r221699 r222980  
    3333#include "JSDOMPromiseDeferred.h"
    3434#include "JSServiceWorkerRegistration.h"
     35#include "Logging.h"
    3536#include "NavigatorBase.h"
     37#include "ResourceError.h"
    3638#include "ScopeGuard.h"
    3739#include "ScriptExecutionContext.h"
     
    182184}
    183185
     186void ServiceWorkerContainer::startScriptFetchForJob(ServiceWorkerJob& job)
     187{
     188    LOG(ServiceWorker, "SeviceWorkerContainer %p starting script fetch for job %" PRIu64, this, job.data().identifier());
     189
     190    auto* context = scriptExecutionContext();
     191    if (!context) {
     192        LOG_ERROR("ServiceWorkerContainer::jobResolvedWithRegistration called but the container's ScriptExecutionContext is gone");
     193        m_swConnection->failedFetchingScript(job, { errorDomainWebKitInternal, 0, job.data().scriptURL, ASCIILiteral("Attempt to fetch service worker script with no ScriptExecutionContext") });
     194        jobDidFinish(job);
     195        return;
     196    }
     197
     198    job.fetchScriptWithContext(*context);
     199}
     200
     201void ServiceWorkerContainer::jobFinishedLoadingScript(ServiceWorkerJob& job, const String& script)
     202{
     203    LOG(ServiceWorker, "SeviceWorkerContainer %p finished fetching script for job %" PRIu64, this, job.data().identifier());
     204
     205    m_swConnection->finishedFetchingScript(job, script);
     206}
     207
     208void ServiceWorkerContainer::jobFailedLoadingScript(ServiceWorkerJob& job, const ResourceError& error)
     209{
     210    LOG(ServiceWorker, "SeviceWorkerContainer %p failed fetching script for job %" PRIu64, this, job.data().identifier());
     211
     212    m_swConnection->failedFetchingScript(job, error);
     213}
     214
    184215void ServiceWorkerContainer::jobDidFinish(ServiceWorkerJob& job)
    185216{
  • trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h

    r221699 r222980  
    7474    void jobFailedWithException(ServiceWorkerJob&, const Exception&) final;
    7575    void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) final;
     76    void startScriptFetchForJob(ServiceWorkerJob&) final;
     77    void jobFinishedLoadingScript(ServiceWorkerJob&, const String&) final;
     78    void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) final;
     79
    7680    void jobDidFinish(ServiceWorkerJob&);
    7781
  • trunk/Source/WebCore/workers/service/ServiceWorkerFetchResult.h

    r222979 r222980  
    2828#if ENABLE(SERVICE_WORKER)
    2929
    30 #include "ServiceWorkerJob.h"
    31 #include <wtf/HashMap.h>
    32 #include <wtf/ThreadSafeRefCounted.h>
     30#include "ResourceError.h"
     31#include "ServiceWorkerRegistrationKey.h"
    3332
    3433namespace WebCore {
    3534
    36 struct ExceptionData;
    37 struct ServiceWorkerRegistrationData;
     35struct ServiceWorkerFetchResult {
     36    uint64_t jobIdentifier;
     37    uint64_t connectionIdentifier;
     38    ServiceWorkerRegistrationKey registrationKey;
     39    String script;
     40    ResourceError scriptError;
    3841
    39 class SWClientConnection : public ThreadSafeRefCounted<SWClientConnection> {
    40 public:
    41     WEBCORE_EXPORT SWClientConnection();
    42     WEBCORE_EXPORT virtual ~SWClientConnection();
     42    template<class Encoder> void encode(Encoder&) const;
     43    template<class Decoder> static bool decode(Decoder&, ServiceWorkerFetchResult&);
     44};
    4345
    44     void scheduleJob(ServiceWorkerJob&);
     46template<class Encoder>
     47void ServiceWorkerFetchResult::encode(Encoder& encoder) const
     48{
     49    encoder << jobIdentifier << connectionIdentifier << registrationKey << script << scriptError;
     50}
    4551
    46     virtual uint64_t identifier() const = 0;
     52template<class Decoder>
     53bool ServiceWorkerFetchResult::decode(Decoder& decoder, ServiceWorkerFetchResult& result)
     54{
     55    if (!decoder.decode(result.jobIdentifier))
     56        return false;
     57    if (!decoder.decode(result.connectionIdentifier))
     58        return false;
     59   
     60    auto registrationKey = ServiceWorkerRegistrationKey::decode(decoder);
     61    if (!registrationKey)
     62        return false;
     63    std::swap(*registrationKey, result.registrationKey);
    4764
    48 protected:
    49     WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
    50     WEBCORE_EXPORT void jobResolvedInServer(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&);
     65    if (!decoder.decode(result.script))
     66        return false;
     67    if (!decoder.decode(result.scriptError))
     68        return false;
    5169
    52 private:
    53     virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
    54 
    55     HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
    56 };
     70    return true;
     71}
    5772
    5873} // namespace WebCore
  • trunk/Source/WebCore/workers/service/ServiceWorkerJob.cpp

    r221699 r222980  
    3030
    3131#include "JSDOMPromiseDeferred.h"
     32#include "ResourceError.h"
     33#include "ResourceResponse.h"
    3234#include "ServiceWorkerJobData.h"
    3335#include "ServiceWorkerRegistration.h"
     
    6567}
    6668
     69void ServiceWorkerJob::startScriptFetch()
     70{
     71    ASSERT(currentThread() == m_creationThread);
     72    ASSERT(!m_completed);
     73
     74    m_client->startScriptFetchForJob(*this);
     75}
     76
     77void ServiceWorkerJob::fetchScriptWithContext(ScriptExecutionContext& context)
     78{
     79    ASSERT(currentThread() == m_creationThread);
     80    ASSERT(!m_completed);
     81
     82    // FIXME: WorkerScriptLoader is the wrong loader class to use here, but there's nothing else better right now.
     83    m_scriptLoader = WorkerScriptLoader::create();
     84    m_scriptLoader->loadAsynchronously(&context, m_jobData.scriptURL, FetchOptions::Mode::SameOrigin, ContentSecurityPolicyEnforcement::DoNotEnforce, "serviceWorkerScriptLoad:", this);
     85}
     86
     87void ServiceWorkerJob::didReceiveResponse(unsigned long, const ResourceResponse& response)
     88{
     89    ASSERT(currentThread() == m_creationThread);
     90    ASSERT(!m_completed);
     91    ASSERT(m_scriptLoader);
     92
     93    m_lastResponse = response;
     94}
     95
     96void ServiceWorkerJob::notifyFinished()
     97{
     98    ASSERT(currentThread() == m_creationThread);
     99    ASSERT(m_scriptLoader);
     100   
     101    if (!m_scriptLoader->failed())
     102        m_client->jobFinishedLoadingScript(*this, m_scriptLoader->script());
     103    else
     104        m_client->jobFailedLoadingScript(*this, m_scriptLoader->error());
     105
     106    m_scriptLoader = nullptr;
     107}
     108
    67109} // namespace WebCore
    68110
  • trunk/Source/WebCore/workers/service/ServiceWorkerJob.h

    r221699 r222980  
    2828#if ENABLE(SERVICE_WORKER)
    2929
     30#include "ResourceResponse.h"
    3031#include "ServiceWorkerJobClient.h"
    3132#include "ServiceWorkerJobData.h"
     33#include "WorkerScriptLoader.h"
     34#include "WorkerScriptLoaderClient.h"
    3235#include <wtf/RefPtr.h>
    3336#include <wtf/RunLoop.h>
     
    3942class DeferredPromise;
    4043class Exception;
     44class ScriptExecutionContext;
    4145enum class ServiceWorkerJobType;
    4246struct ServiceWorkerRegistrationData;
    4347
    44 class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob> {
     48class ServiceWorkerJob : public ThreadSafeRefCounted<ServiceWorkerJob>, public WorkerScriptLoaderClient {
    4549public:
    4650    static Ref<ServiceWorkerJob> create(ServiceWorkerJobClient& client, Ref<DeferredPromise>&& promise, ServiceWorkerJobData&& jobData)
     
    5357    void failedWithException(const Exception&);
    5458    void resolvedWithRegistration(const ServiceWorkerRegistrationData&);
     59    void startScriptFetch();
    5560
    5661    ServiceWorkerJobData data() const { return m_jobData; }
    5762    DeferredPromise& promise() { return m_promise.get(); }
    5863
     64    void fetchScriptWithContext(ScriptExecutionContext&);
     65
    5966private:
    6067    ServiceWorkerJob(ServiceWorkerJobClient&, Ref<DeferredPromise>&&, ServiceWorkerJobData&&);
     68
     69    // WorkerScriptLoaderClient
     70    void didReceiveResponse(unsigned long identifier, const ResourceResponse&) final;
     71    void notifyFinished() final;
    6172
    6273    Ref<ServiceWorkerJobClient> m_client;
     
    6778
    6879    Ref<RunLoop> m_runLoop { RunLoop::current() };
     80    RefPtr<WorkerScriptLoader> m_scriptLoader;
     81    ResourceResponse m_lastResponse;
    6982
    7083#if !ASSERT_DISABLED
  • trunk/Source/WebCore/workers/service/ServiceWorkerJobClient.h

    r221699 r222980  
    3131
    3232class Exception;
     33class ResourceError;
    3334class ServiceWorkerJob;
     35class SharedBuffer;
    3436struct ServiceWorkerRegistrationData;
    3537
     
    4042    virtual void jobFailedWithException(ServiceWorkerJob&, const Exception&) = 0;
    4143    virtual void jobResolvedWithRegistration(ServiceWorkerJob&, const ServiceWorkerRegistrationData&) = 0;
     44    virtual void startScriptFetchForJob(ServiceWorkerJob&) = 0;
     45    virtual void jobFinishedLoadingScript(ServiceWorkerJob&, const String&) = 0;
     46    virtual void jobFailedLoadingScript(ServiceWorkerJob&, const ResourceError&) = 0;
    4247
    4348    virtual uint64_t connectionIdentifier() = 0;
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.cpp

    r221699 r222980  
    3030
    3131#include "ExceptionData.h"
     32#include "ServiceWorkerFetchResult.h"
    3233#include "ServiceWorkerJobData.h"
    3334
     
    4849
    4950    scheduleJobInServer(job.data());
     51}
     52
     53void SWClientConnection::finishedFetchingScript(ServiceWorkerJob& job, const String& script)
     54{
     55    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
     56
     57    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), script, { } });
     58}
     59
     60void SWClientConnection::failedFetchingScript(ServiceWorkerJob& job, const ResourceError& error)
     61{
     62    ASSERT(m_scheduledJobs.get(job.data().identifier()) == &job);
     63
     64    finishFetchingScriptInServer({ job.data().identifier(), job.data().connectionIdentifier(), job.data().registrationKey(), { }, error });
    5065}
    5166
     
    7287}
    7388
     89void SWClientConnection::startScriptFetchForServer(uint64_t jobIdentifier)
     90{
     91    auto job = m_scheduledJobs.get(jobIdentifier);
     92    if (!job) {
     93        LOG_ERROR("Job %" PRIu64 " instructed to start fetch from server, but job was not found", jobIdentifier);
     94
     95        // FIXME: Should message back to the server here to signal failure to fetch,
     96        // but we currently need the registration key to do so, and don't have it here.
     97        // In the future we'll refactor to have a global, cross-process job identifier that can be used to overcome this.
     98
     99        return;
     100    }
     101
     102    job->startScriptFetch();
     103}
     104
    74105} // namespace WebCore
    75106
  • trunk/Source/WebCore/workers/service/server/SWClientConnection.h

    r221699 r222980  
    3434namespace WebCore {
    3535
     36class ResourceError;
     37class SharedBuffer;
    3638struct ExceptionData;
     39struct ServiceWorkerFetchResult;
    3740struct ServiceWorkerRegistrationData;
    3841
     
    4346
    4447    void scheduleJob(ServiceWorkerJob&);
     48    void finishedFetchingScript(ServiceWorkerJob&, const String&);
     49    void failedFetchingScript(ServiceWorkerJob&, const ResourceError&);
    4550
    4651    virtual uint64_t identifier() const = 0;
     
    4954    WEBCORE_EXPORT void jobRejectedInServer(uint64_t jobIdentifier, const ExceptionData&);
    5055    WEBCORE_EXPORT void jobResolvedInServer(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&);
     56    WEBCORE_EXPORT void startScriptFetchForServer(uint64_t jobIdentifier);
    5157
    5258private:
    5359    virtual void scheduleJobInServer(const ServiceWorkerJobData&) = 0;
     60    virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
    5461
    5562    HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_scheduledJobs;
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r221699 r222980  
    3333#include "Logging.h"
    3434#include "SWServerRegistration.h"
     35#include "ServiceWorkerFetchResult.h"
    3536#include "ServiceWorkerJobData.h"
    3637#include <wtf/text/WTFString.h>
     
    7374}
    7475
     76void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
     77{
     78    m_server.scriptFetchFinished(result);
     79}
     80
    7581SWServer::SWServer()
    7682{
     
    111117
    112118    connection->resolveJobInClient(jobData.identifier(), registrationData);
     119}
     120
     121void SWServer::startScriptFetch(const ServiceWorkerJobData& jobData)
     122{
     123    LOG(ServiceWorker, "Server issuing startScriptFetch for current job %" PRIu64 "-%" PRIu64 " in client", jobData.connectionIdentifier(), jobData.identifier());
     124    auto* connection = m_connections.get(jobData.connectionIdentifier());
     125    if (!connection)
     126        return;
     127
     128    connection->startScriptFetchInClient(jobData.identifier());
     129}
     130
     131void SWServer::scriptFetchFinished(const ServiceWorkerFetchResult& result)
     132{
     133    LOG(ServiceWorker, "Server handling scriptFetchFinished for current job %" PRIu64 "-%" PRIu64 " in client", result.connectionIdentifier, result.jobIdentifier);
     134
     135    ASSERT(m_connections.contains(result.connectionIdentifier));
     136
     137    auto registration = m_registrations.get(result.registrationKey);
     138    if (!registration)
     139        return;
     140
     141    registration->scriptFetchFinished(result);
    113142}
    114143
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r221699 r222980  
    4444class SWServerRegistration;
    4545struct ExceptionData;
     46struct ServiceWorkerFetchResult;
    4647struct ServiceWorkerRegistrationData;
    4748
     
    5859
    5960        WEBCORE_EXPORT void scheduleJobInServer(const ServiceWorkerJobData&);
     61        WEBCORE_EXPORT void finishFetchingScriptInServer(const ServiceWorkerFetchResult&);
    6062
    6163    private:
    6264        virtual void rejectJobInClient(uint64_t jobIdentifier, const ExceptionData&) = 0;
    6365        virtual void resolveJobInClient(uint64_t jobIdentifier, const ServiceWorkerRegistrationData&) = 0;
     66        virtual void startScriptFetchInClient(uint64_t jobIdentifier) = 0;
    6467
    6568        SWServer& m_server;
     
    7275    void rejectJob(const ServiceWorkerJobData&, const ExceptionData&);
    7376    void resolveJob(const ServiceWorkerJobData&, const ServiceWorkerRegistrationData&);
     77    void startScriptFetch(const ServiceWorkerJobData&);
     78
    7479    void postTask(CrossThreadTask&&);
    7580    void postTaskReply(CrossThreadTask&&);
     
    8186    void taskThreadEntryPoint();
    8287    void handleTaskRepliesOnMainThread();
     88
     89    void scriptFetchFinished(const ServiceWorkerFetchResult&);
    8390
    8491    HashMap<uint64_t, Connection*> m_connections;
  • trunk/Source/WebCore/workers/service/server/SWServerRegistration.cpp

    r221699 r222980  
    3333#include "SWServerWorker.h"
    3434#include "SecurityOrigin.h"
     35#include "ServiceWorkerFetchResult.h"
    3536#include "ServiceWorkerRegistrationData.h"
    3637#include "WorkerType.h"
     
    6263    if (!m_jobTimer.isActive())
    6364        m_jobTimer.startOneShot(0_s);
     65}
     66
     67void SWServerRegistration::scriptFetchFinished(const ServiceWorkerFetchResult& result)
     68{
     69    ASSERT(m_currentJob && m_currentJob->identifier() == result.jobIdentifier);
     70
     71    // FIXME: We fetched the script contents but don't do anything with them yet.
     72    // These errors are for testing the current state of the feature.
     73
     74    String message;
     75    if (result.scriptError.isNull())
     76        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetched with ", String::number(result.script.length()), " characters, but we're not using the result yet");
     77    else
     78        message = makeString("Script URL ", m_currentJob->scriptURL.string(), " fetch resulted in error: ", result.scriptError.localizedDescription());
     79
     80    rejectCurrentJob(ExceptionData { UnknownError, message });
    6481}
    6582
     
    150167        return rejectWithExceptionOnMainThread(ExceptionData { TypeError, ASCIILiteral("Cannot update a service worker with a requested script URL whose newest worker has a different script URL") });
    151168
    152     // FIXME: At this point we are ready to actually fetch the script for the worker in the registering context.
    153     // For now we're still hard coding the same rejection we have so far.
    154     rejectWithExceptionOnMainThread(ExceptionData { UnknownError, ASCIILiteral("serviceWorker job scheduling is not yet implemented") });
     169    startScriptFetchFromMainThread();
    155170}
    156171
     
    167182}
    168183
     184void SWServerRegistration::startScriptFetchFromMainThread()
     185{
     186    ASSERT(!isMainThread());
     187    m_server.postTaskReply(createCrossThreadTask(*this, &SWServerRegistration::startScriptFetchForCurrentJob));
     188}
     189
    169190void SWServerRegistration::rejectCurrentJob(const ExceptionData& exceptionData)
    170191{
     
    185206
    186207    finishCurrentJob();
     208}
     209
     210void SWServerRegistration::startScriptFetchForCurrentJob()
     211{
     212    ASSERT(isMainThread());
     213    ASSERT(m_currentJob);
     214
     215    m_server.startScriptFetch(*m_currentJob);
    187216}
    188217
  • trunk/Source/WebCore/workers/service/server/SWServerRegistration.h

    r221699 r222980  
    3939class SWServerWorker;
    4040struct ExceptionData;
     41struct ServiceWorkerFetchResult;
    4142
    4243class SWServerRegistration : public ThreadSafeIdentified<SWServerRegistration> {
     
    4748
    4849    void enqueueJob(const ServiceWorkerJobData&);
     50    void scriptFetchFinished(const ServiceWorkerFetchResult&);
    4951
    5052    ServiceWorkerRegistrationData data() const;
     
    5557    void rejectCurrentJob(const ExceptionData&);
    5658    void resolveCurrentJob(const ServiceWorkerRegistrationData&);
     59    void startScriptFetchForCurrentJob();
    5760    void finishCurrentJob();
    5861
     
    6265    void rejectWithExceptionOnMainThread(const ExceptionData&);
    6366    void resolveWithRegistrationOnMainThread();
     67    void startScriptFetchFromMainThread();
    6468    bool isEmpty();
    6569    SWServerWorker* getNewestWorker();
  • trunk/Source/WebKit/ChangeLog

    r222967 r222980  
     12017-10-06  Brady Eidson  <beidson@apple.com>
     2
     3        Add (entirely incorrect) fetching of ServiceWorker scripts.
     4        https://bugs.webkit.org/show_bug.cgi?id=176179
     5
     6        Reviewed by Andy Estes.
     7
     8        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
     9        (WebKit::WebSWServerConnection::startScriptFetchInClient):
     10        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
     11        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
     12
     13        * WebProcess/Storage/WebSWClientConnection.cpp:
     14        (WebKit::WebSWClientConnection::finishFetchingScriptInServer):
     15        * WebProcess/Storage/WebSWClientConnection.h:
     16        * WebProcess/Storage/WebSWClientConnection.messages.in:
     17
    1182017-10-05  Carlos Garcia Campos  <cgarcia@igalia.com>
    219
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp

    r221699 r222980  
    2929#if ENABLE(SERVICE_WORKER)
    3030
     31#include "DataReference.h"
    3132#include "Logging.h"
    3233#include "StorageToWebProcessConnectionMessages.h"
     
    7172}
    7273
     74void WebSWServerConnection::startScriptFetchInClient(uint64_t jobIdentifier)
     75{
     76    send(Messages::WebSWClientConnection::StartScriptFetchForServer(jobIdentifier));
     77}
     78
    7379} // namespace WebKit
    7480
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h

    r221699 r222980  
    5252    void rejectJobInClient(uint64_t jobIdentifier, const WebCore::ExceptionData&) final;
    5353    void resolveJobInClient(uint64_t jobIdentifier, const WebCore::ServiceWorkerRegistrationData&) final;
     54    void startScriptFetchInClient(uint64_t jobIdentifier) final;
    5455
    5556    IPC::Connection* messageSenderConnection() final { return m_connection.ptr(); }
  • trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in

    r221699 r222980  
    2626    # When possible, these messages can be implemented directly by WebCore::SWClientConnection
    2727    ScheduleJobInServer(struct WebCore::ServiceWorkerJobData jobData)
     28    FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
    2829}
    2930
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp

    r221699 r222980  
    3131#include "Logging.h"
    3232#include "StorageToWebProcessConnectionMessages.h"
     33#include "WebCoreArgumentCoders.h"
    3334#include "WebSWServerConnectionMessages.h"
     35#include <WebCore/ServiceWorkerFetchResult.h>
    3436#include <WebCore/ServiceWorkerJobData.h>
    3537
     
    5759}
    5860
     61void WebSWClientConnection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
     62{
     63    send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result));
     64}
     65
    5966} // namespace WebKit
    6067
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h

    r221699 r222980  
    4949
    5050    void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
     51    void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
    5152
    5253    void disconnectedFromWebProcess();
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.messages.in

    r221699 r222980  
    2727    JobRejectedInServer(uint64_t identifier, struct WebCore::ExceptionData exception)
    2828    JobResolvedInServer(uint64_t identifier, struct WebCore::ServiceWorkerRegistrationData registration)
     29    StartScriptFetchForServer(uint64_t jobIdentifier)
    2930}
    3031
Note: See TracChangeset for help on using the changeset viewer.