Changeset 246184 in webkit


Ignore:
Timestamp:
Jun 6, 2019 6:28:54 PM (5 years ago)
Author:
youenn@apple.com
Message:

Allow WebKitTestRunner to terminate network process after it finishes service worker file operations
https://bugs.webkit.org/show_bug.cgi?id=198584

Reviewed by Geoffrey Garen.

Source/WebCore:

Add a promise-based internal API to store service worker registrations on disk.
Covered by updated test.

  • testing/Internals.cpp:

(WebCore::Internals::storeRegistrationsOnDisk):

  • testing/Internals.h:
  • testing/Internals.idl:
  • workers/service/SWClientConnection.h:

(WebCore::SWClientConnection::storeRegistrationsOnDiskForTesting):

  • workers/service/server/RegistrationStore.cpp:

(WebCore::RegistrationStore::startSuspension):
(WebCore::RegistrationStore::closeDatabase):

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

(WebCore::SWServer::Connection::storeRegistrationsOnDisk):

  • workers/service/server/SWServer.h:

Source/WebKit:

Add IPC binding to new internal API.

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

(WebKit::WebSWClientConnection::storeRegistrationsOnDiskForTesting):

  • WebProcess/Storage/WebSWClientConnection.h:

LayoutTests:

  • http/wpt/service-workers/service-worker-networkprocess-crash.html:
Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r246183 r246184  
     12019-06-06  Youenn Fablet  <youenn@apple.com>
     2
     3        Allow WebKitTestRunner to terminate network process after it finishes service worker file operations
     4        https://bugs.webkit.org/show_bug.cgi?id=198584
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * http/wpt/service-workers/service-worker-networkprocess-crash.html:
     9
    1102019-06-06  Commit Queue  <commit-queue@webkit.org>
    211
  • trunk/LayoutTests/http/wpt/service-workers/service-worker-networkprocess-crash.html

    r246089 r246184  
    4646
    4747promise_test(async (test) => {
     48    if (window.internals)
     49        await internals.storeRegistrationsOnDisk();
     50
    4851    if (window.testRunner && window.testRunner.terminateNetworkProcess)
    4952        testRunner.terminateNetworkProcess();
  • trunk/Source/WebCore/ChangeLog

    r246182 r246184  
     12019-06-06  Youenn Fablet  <youenn@apple.com>
     2
     3        Allow WebKitTestRunner to terminate network process after it finishes service worker file operations
     4        https://bugs.webkit.org/show_bug.cgi?id=198584
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add a promise-based internal API to store service worker registrations on disk.
     9        Covered by updated test.
     10
     11        * testing/Internals.cpp:
     12        (WebCore::Internals::storeRegistrationsOnDisk):
     13        * testing/Internals.h:
     14        * testing/Internals.idl:
     15        * workers/service/SWClientConnection.h:
     16        (WebCore::SWClientConnection::storeRegistrationsOnDiskForTesting):
     17        * workers/service/server/RegistrationStore.cpp:
     18        (WebCore::RegistrationStore::startSuspension):
     19        (WebCore::RegistrationStore::closeDatabase):
     20        * workers/service/server/RegistrationStore.h:
     21        * workers/service/server/SWServer.cpp:
     22        (WebCore::SWServer::Connection::storeRegistrationsOnDisk):
     23        * workers/service/server/SWServer.h:
     24
    1252019-06-06  Brent Fulgham  <bfulgham@apple.com>
    226
  • trunk/Source/WebCore/testing/Internals.cpp

    r246056 r246184  
    47974797}
    47984798
     4799void Internals::storeRegistrationsOnDisk(DOMPromiseDeferred<void>&& promise)
     4800{
     4801#if ENABLE(SERVICE_WORKER)
     4802    if (!contextDocument())
     4803        return;
     4804
     4805    auto& connection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(contextDocument()->sessionID());
     4806    connection.storeRegistrationsOnDiskForTesting([promise = WTFMove(promise)]() mutable {
     4807        promise.resolve();
     4808    });
     4809#endif
     4810}
     4811
    47994812void Internals::clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&& promise)
    48004813{
  • trunk/Source/WebCore/testing/Internals.h

    r246056 r246184  
    719719    bool audioSessionActive() const;
    720720
     721    void storeRegistrationsOnDisk(DOMPromiseDeferred<void>&&);
     722
    721723    void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
    722724    void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
  • trunk/Source/WebCore/testing/Internals.idl

    r246056 r246184  
    693693
    694694    DOMString serviceWorkerClientIdentifier(Document document);
     695    Promise<void> storeRegistrationsOnDisk();
    695696
    696697    Promise<void> clearCacheStorageMemoryRepresentation();
  • trunk/Source/WebCore/workers/service/SWClientConnection.h

    r245299 r246184  
    8989    virtual void updateThrottleState() = 0;
    9090
     91    virtual void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback) { callback(); }
     92
    9193protected:
    9294    WEBCORE_EXPORT SWClientConnection();
  • trunk/Source/WebCore/workers/service/server/RegistrationStore.cpp

    r244097 r246184  
    8888{
    8989    m_isSuspended = true;
     90    closeDatabase(WTFMove(completionHandler));
     91}
     92
     93void RegistrationStore::closeDatabase(CompletionHandler<void()>&& completionHandler)
     94{
    9095    m_database->close(WTFMove(completionHandler));
    9196}
  • trunk/Source/WebCore/workers/service/server/RegistrationStore.h

    r244097 r246184  
    4949    ~RegistrationStore();
    5050
    51     void clearAll(WTF::CompletionHandler<void()>&&);
    52     void flushChanges(WTF::CompletionHandler<void()>&&);
     51    void clearAll(CompletionHandler<void()>&&);
     52    void flushChanges(CompletionHandler<void()>&&);
    5353
    54     void startSuspension(WTF::CompletionHandler<void()>&&);
     54    void closeDatabase(CompletionHandler<void()>&&);
     55    void startSuspension(CompletionHandler<void()>&&);
    5556    void endSuspension();
    5657
  • trunk/Source/WebCore/workers/service/server/SWServer.cpp

    r245748 r246184  
    879879}
    880880
     881void SWServer::Connection::storeRegistrationsOnDisk(CompletionHandler<void()>&& callback)
     882{
     883    if (!m_server.m_registrationStore) {
     884        callback();
     885        return;
     886    }
     887    m_server.m_registrationStore->closeDatabase(WTFMove(callback));
     888}
     889
    881890void SWServer::Connection::resolveRegistrationReadyRequests(SWServerRegistration& registration)
    882891{
  • trunk/Source/WebCore/workers/service/server/SWServer.h

    r245299 r246184  
    102102        WEBCORE_EXPORT void whenRegistrationReady(uint64_t registrationReadyRequestIdentifier, const SecurityOriginData& topOrigin, const URL& clientURL);
    103103
     104        WEBCORE_EXPORT void storeRegistrationsOnDisk(CompletionHandler<void()>&&);
     105
    104106    private:
    105107        // Messages to the client WebProcess
  • trunk/Source/WebKit/ChangeLog

    r246183 r246184  
     12019-06-06  Youenn Fablet  <youenn@apple.com>
     2
     3        Allow WebKitTestRunner to terminate network process after it finishes service worker file operations
     4        https://bugs.webkit.org/show_bug.cgi?id=198584
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Add IPC binding to new internal API.
     9
     10        * NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in:
     11        * WebProcess/Storage/WebSWClientConnection.cpp:
     12        (WebKit::WebSWClientConnection::storeRegistrationsOnDiskForTesting):
     13        * WebProcess/Storage/WebSWClientConnection.h:
     14
    1152019-06-06  Commit Queue  <commit-queue@webkit.org>
    216
  • trunk/Source/WebKit/NetworkProcess/ServiceWorker/WebSWServerConnection.messages.in

    r245299 r246184  
    4747
    4848    SetThrottleState(bool isThrottleable)
     49    StoreRegistrationsOnDisk() -> () Async
    4950}
    5051
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp

    r245913 r246184  
    270270}
    271271
     272void WebSWClientConnection::storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback)
     273{
     274    initializeConnectionIfNeeded();
     275    sendWithAsyncReply(Messages::WebSWServerConnection::StoreRegistrationsOnDisk { }, WTFMove(callback));
     276}
     277
    272278} // namespace WebKit
    273279
  • trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h

    r245873 r246184  
    9494    void updateThrottleState() final;
    9595    bool isThrottleable() const final { return m_isThrottleable; }
     96    void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&&) final;
    9697
    9798    void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);
Note: See TracChangeset for help on using the changeset viewer.