Title: [251439] trunk
Revision
251439
Author
[email protected]
Date
2019-10-22 10:09:59 -0700 (Tue, 22 Oct 2019)

Log Message

Remove mayHaveServiceWorkerRegisteredForOrigin
https://bugs.webkit.org/show_bug.cgi?id=203055

Patch by youenn fablet <[email protected]> on 2019-10-22
Reviewed by Alex Christensen.

Source/WebCore:

Remove ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin and existingServiceWorkerConnection since they are no longer useful.
Creation of a service worker connection no longer requires any additional IPC once network connection is created.
Covered by existing tests.

* dom/Document.cpp:
(WebCore::Document::resume):
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::matchRegistration):
(WebCore::DocumentLoader::commitData):
* testing/Internals.cpp:
(WebCore::Internals::terminateServiceWorker):
* testing/Internals.h:
* testing/Internals.idl:
* workers/service/SWClientConnection.h:
* workers/service/ServiceWorkerProvider.cpp:
* workers/service/ServiceWorkerProvider.h:
* workers/service/WorkerSWClientConnection.cpp:
* workers/service/WorkerSWClientConnection.h:

Source/WebKit:

This optimization was used for ensuring we would not create a storage process when no service worker registration is stored on disk.
Now that we do not have a storage process and we are doing registration matching direclty in network process, we can safely remove that optimization.
We also move the throttle state handling in WK2 layer. This allows us to not create a network process connection to update throttle state until
there is a network process connection. This allows continuing passing an API test checking network process connections after crashes.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode const):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
(WebKit::WebProcessPool::updateServiceWorkerUserAgent):
* UIProcess/WebProcessPool.h:
* WebProcess/Network/NetworkProcessConnection.h:
* WebProcess/Storage/WebSWClientConnection.h:
* WebProcess/Storage/WebServiceWorkerProvider.cpp:
(WebKit::WebServiceWorkerProvider::serviceWorkerConnection):
(WebKit::WebServiceWorkerProvider::updateThrottleState):
* WebProcess/Storage/WebServiceWorkerProvider.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_textAutoSizingAdjustmentTimer):
(WebKit::WebPage::updateThrottleState):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
Remove obsolete test.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (251438 => 251439)


--- trunk/Source/WebCore/ChangeLog	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/ChangeLog	2019-10-22 17:09:59 UTC (rev 251439)
@@ -1,3 +1,29 @@
+2019-10-22  youenn fablet  <[email protected]>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        Remove ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin and existingServiceWorkerConnection since they are no longer useful.
+        Creation of a service worker connection no longer requires any additional IPC once network connection is created.
+        Covered by existing tests.
+
+        * dom/Document.cpp:
+        (WebCore::Document::resume):
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::matchRegistration):
+        (WebCore::DocumentLoader::commitData):
+        * testing/Internals.cpp:
+        (WebCore::Internals::terminateServiceWorker):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+        * workers/service/SWClientConnection.h:
+        * workers/service/ServiceWorkerProvider.cpp:
+        * workers/service/ServiceWorkerProvider.h:
+        * workers/service/WorkerSWClientConnection.cpp:
+        * workers/service/WorkerSWClientConnection.h:
+
 2019-10-21  Simon Fraser  <[email protected]>
 
         wpt/css/css-images/gradient/color-stops-parsing.html crashes

Modified: trunk/Source/WebCore/dom/Document.cpp (251438 => 251439)


--- trunk/Source/WebCore/dom/Document.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -5237,7 +5237,7 @@
 
 #if ENABLE(SERVICE_WORKER)
     if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled() && reason == ReasonForSuspension::BackForwardCache)
-        setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingServiceWorkerConnection());
+        setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection());
 #endif
 }
 

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (251438 => 251439)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -505,8 +505,7 @@
     }
 
     auto origin = (!m_frame->isMainFrame() && m_frame->document()) ? m_frame->document()->topOrigin().data() : SecurityOriginData::fromURL(url);
-    auto& provider = ServiceWorkerProvider::singleton();
-    if (!provider.mayHaveServiceWorkerRegisteredForOrigin(origin)) {
+    if (!ServiceWorkerProvider::singleton().serviceWorkerConnection().mayHaveServiceWorkerRegisteredForOrigin(origin)) {
         callback(WTF::nullopt);
         return;
     }
@@ -1061,7 +1060,7 @@
             }
 
             if (m_frame->document()->activeServiceWorker() || LegacySchemeRegistry::canServiceWorkersHandleURLScheme(m_frame->document()->url().protocol().toStringWithoutCopying()))
-                m_frame->document()->setServiceWorkerConnection(ServiceWorkerProvider::singleton().existingServiceWorkerConnection());
+                m_frame->document()->setServiceWorkerConnection(&ServiceWorkerProvider::singleton().serviceWorkerConnection());
 
             // We currently unregister the temporary service worker client since we now registered the real document.
             // FIXME: We should make the real document use the temporary client identifier.

Modified: trunk/Source/WebCore/testing/Internals.cpp (251438 => 251439)


--- trunk/Source/WebCore/testing/Internals.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/testing/Internals.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -5026,14 +5026,6 @@
 
     ServiceWorkerProvider::singleton().serviceWorkerConnection().syncTerminateWorker(worker.identifier());
 }
-
-bool Internals::hasServiceWorkerConnection()
-{
-    if (!contextDocument())
-        return false;
-
-    return ServiceWorkerProvider::singleton().existingServiceWorkerConnection();
-}
 #endif
 
 #if ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/testing/Internals.h (251438 => 251439)


--- trunk/Source/WebCore/testing/Internals.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/testing/Internals.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -765,7 +765,6 @@
     using HasRegistrationPromise = DOMPromiseDeferred<IDLBoolean>;
     void hasServiceWorkerRegistration(const String& clientURL, HasRegistrationPromise&&);
     void terminateServiceWorker(ServiceWorker&);
-    bool hasServiceWorkerConnection();
 #endif
 
 #if ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/testing/Internals.idl (251438 => 251439)


--- trunk/Source/WebCore/testing/Internals.idl	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/testing/Internals.idl	2019-10-22 17:09:59 UTC (rev 251439)
@@ -756,7 +756,6 @@
 
     [Conditional=SERVICE_WORKER] Promise<boolean> hasServiceWorkerRegistration(DOMString scopeURL);
     [Conditional=SERVICE_WORKER] void terminateServiceWorker(ServiceWorker worker);
-    [Conditional=SERVICE_WORKER] boolean hasServiceWorkerConnection();
 
     [CallWith=Document, Conditional=APPLE_PAY] readonly attribute MockPaymentCoordinator mockPaymentCoordinator;
 

Modified: trunk/Source/WebCore/workers/service/SWClientConnection.h (251438 => 251439)


--- trunk/Source/WebCore/workers/service/SWClientConnection.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/workers/service/SWClientConnection.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -85,9 +85,6 @@
 
     virtual void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) = 0;
 
-    virtual bool isThrottleable() const = 0;
-    virtual void updateThrottleState() = 0;
-
     virtual void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&& callback) { callback(); }
 
 protected:

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp (251438 => 251439)


--- trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerProvider.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -54,15 +54,6 @@
     sharedProvider = &newProvider;
 }
 
-bool ServiceWorkerProvider::mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData& origin)
-{
-    auto* connection = existingServiceWorkerConnection();
-    if (!connection)
-        return m_mayHaveRegisteredServiceWorkers;
-
-    return connection->mayHaveServiceWorkerRegisteredForOrigin(origin);
-}
-
 void ServiceWorkerProvider::registerServiceWorkerClients()
 {
     setMayHaveRegisteredServiceWorkers();

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h (251438 => 251439)


--- trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerProvider.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -40,8 +40,6 @@
     static ServiceWorkerProvider& singleton();
     static void setSharedProvider(ServiceWorkerProvider&);
 
-    bool mayHaveServiceWorkerRegisteredForOrigin(const SecurityOriginData&);
-    virtual SWClientConnection* existingServiceWorkerConnection() = 0;
     virtual SWClientConnection& serviceWorkerConnection() = 0;
 
     void registerServiceWorkerClients();

Modified: trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp (251438 => 251439)


--- trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/workers/service/WorkerSWClientConnection.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -184,15 +184,6 @@
     });
 }
 
-bool WorkerSWClientConnection::isThrottleable() const
-{
-    return true;
-}
-
-void WorkerSWClientConnection::updateThrottleState()
-{
-}
-
 void WorkerSWClientConnection::scheduleJob(DocumentOrWorkerIdentifier identifier, const ServiceWorkerJobData& data)
 {
     callOnMainThread([identifier, data = "" mutable {

Modified: trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h (251438 => 251439)


--- trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebCore/workers/service/WorkerSWClientConnection.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -55,8 +55,6 @@
     void registerServiceWorkerClient(const SecurityOrigin& topOrigin, const ServiceWorkerClientData&, const Optional<ServiceWorkerRegistrationIdentifier>&, const String& userAgent) final;
     void unregisterServiceWorkerClient(DocumentIdentifier) final;
     void finishFetchingScriptInServer(const ServiceWorkerFetchResult&) final;
-    bool isThrottleable() const final;
-    void updateThrottleState() final;
     void scheduleJobInServer(const ServiceWorkerJobData&) final;
     void scheduleJob(DocumentOrWorkerIdentifier, const ServiceWorkerJobData&) final;
 

Modified: trunk/Source/WebKit/ChangeLog (251438 => 251439)


--- trunk/Source/WebKit/ChangeLog	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/ChangeLog	2019-10-22 17:09:59 UTC (rev 251439)
@@ -1,3 +1,35 @@
+2019-10-22  youenn fablet  <[email protected]>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        This optimization was used for ensuring we would not create a storage process when no service worker registration is stored on disk.
+        Now that we do not have a storage process and we are doing registration matching direclty in network process, we can safely remove that optimization.
+        We also move the throttle state handling in WK2 layer. This allows us to not create a network process connection to update throttle state until
+        there is a network process connection. This allows continuing passing an API test checking network process connections after crashes.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode const):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::establishWorkerContextConnectionToNetworkProcess):
+        (WebKit::WebProcessPool::updateServiceWorkerUserAgent):
+        * UIProcess/WebProcessPool.h:
+        * WebProcess/Network/NetworkProcessConnection.h:
+        * WebProcess/Storage/WebSWClientConnection.h:
+        * WebProcess/Storage/WebServiceWorkerProvider.cpp:
+        (WebKit::WebServiceWorkerProvider::serviceWorkerConnection):
+        (WebKit::WebServiceWorkerProvider::updateThrottleState):
+        * WebProcess/Storage/WebServiceWorkerProvider.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_textAutoSizingAdjustmentTimer):
+        (WebKit::WebPage::updateThrottleState):
+
 2019-10-22  Yury Semikhatsky  <[email protected]>
 
         [GTK] Web Inspector: add an option for disabling minification and concatenation of inspector UI in release build

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp (251438 => 251439)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -117,9 +117,6 @@
 #if ENABLE(APPLICATION_MANIFEST)
     encoder << applicationManifest;
 #endif
-#if ENABLE(SERVICE_WORKER)
-    encoder << hasRegisteredServiceWorkers;
-#endif
     encoder << needsFontAttributes;
     encoder << iceCandidateFilteringEnabled;
     encoder << enumeratingAllNetworkInterfacesEnabled;
@@ -343,11 +340,6 @@
         return WTF::nullopt;
     parameters.applicationManifest = WTFMove(*applicationManifest);
 #endif
-#if ENABLE(SERVICE_WORKER)
-    if (!decoder.decode(parameters.hasRegisteredServiceWorkers))
-        return WTF::nullopt;
-#endif
-
     if (!decoder.decode(parameters.needsFontAttributes))
         return WTF::nullopt;
 

Modified: trunk/Source/WebKit/Shared/WebPageCreationParameters.h (251438 => 251439)


--- trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/Shared/WebPageCreationParameters.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -182,10 +182,6 @@
     Optional<WebCore::ApplicationManifest> applicationManifest;
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    bool hasRegisteredServiceWorkers { true };
-#endif
-
     bool needsFontAttributes { false };
 
     // WebRTC members.

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (251438 => 251439)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -7384,10 +7384,6 @@
     parameters.applicationManifest = m_configuration->applicationManifest() ? Optional<WebCore::ApplicationManifest>(m_configuration->applicationManifest()->applicationManifest()) : WTF::nullopt;
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    parameters.hasRegisteredServiceWorkers = process.processPool().mayHaveRegisteredServiceWorkers(process.websiteDataStore());
-#endif
-
     parameters.needsFontAttributes = m_needsFontAttributes;
     parameters.backgroundColor = m_backgroundColor;
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (251438 => 251439)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -691,8 +691,6 @@
 {
     ASSERT_UNUSED(proxy, &proxy == m_networkProcess.get());
 
-    m_mayHaveRegisteredServiceWorkers.clear();
-
     auto* websiteDataStore = WebsiteDataStore::existingNonDefaultDataStoreForSessionID(sessionID);
 
     if (!websiteDataStore) {
@@ -1264,21 +1262,6 @@
     for (auto* serviceWorkerProcess : m_serviceWorkerProcesses.values())
         serviceWorkerProcess->setServiceWorkerUserAgent(m_serviceWorkerUserAgent);
 }
-
-bool WebProcessPool::mayHaveRegisteredServiceWorkers(const WebsiteDataStore& store)
-{
-    if (!m_serviceWorkerProcesses.isEmpty())
-        return true;
-
-    String serviceWorkerRegistrationDirectory = store.resolvedServiceWorkerRegistrationDirectory();
-    if (serviceWorkerRegistrationDirectory.isEmpty())
-        serviceWorkerRegistrationDirectory = WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
-
-    return m_mayHaveRegisteredServiceWorkers.ensure(serviceWorkerRegistrationDirectory, [&] {
-        // FIXME: Make this computation on a background thread.
-        return FileSystem::fileExists(WebCore::serviceWorkerRegistrationDatabaseFilename(serviceWorkerRegistrationDirectory));
-    }).iterator->value;
-}
 #endif
 
 void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxyIdentifier pageID, WebsiteDataStore& dataStore)

Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (251438 => 251439)


--- trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -393,7 +393,6 @@
     void setAllowsAnySSLCertificateForServiceWorker(bool allows) { m_allowsAnySSLCertificateForServiceWorker = allows; }
     bool allowsAnySSLCertificateForServiceWorker() const { return m_allowsAnySSLCertificateForServiceWorker; }
     void updateServiceWorkerUserAgent(const String& userAgent);
-    bool mayHaveRegisteredServiceWorkers(const WebsiteDataStore&);
 #endif
 
 #if PLATFORM(COCOA)
@@ -612,7 +611,6 @@
     bool m_allowsAnySSLCertificateForServiceWorker { false };
     String m_serviceWorkerUserAgent;
     Optional<WebPreferencesStore> m_serviceWorkerPreferences;
-    HashMap<String, bool> m_mayHaveRegisteredServiceWorkers;
 #endif
 
     Ref<WebPageGroup> m_defaultPageGroup;

Modified: trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h (251438 => 251439)


--- trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/WebProcess/Network/NetworkProcessConnection.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -72,7 +72,6 @@
 #endif
 
 #if ENABLE(SERVICE_WORKER)
-    WebSWClientConnection* existingServiceWorkerConnection() { return m_swConnection.get(); }
     WebSWClientConnection& serviceWorkerConnection();
 #endif
 

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (251438 => 251439)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -64,6 +64,9 @@
 
     void syncTerminateWorker(WebCore::ServiceWorkerIdentifier) final;
 
+    bool isThrottleable() const { return m_isThrottleable; }
+    void updateThrottleState();
+
 private:
     WebSWClientConnection();
 
@@ -84,8 +87,6 @@
     void getRegistrations(WebCore::SecurityOriginData&& topOrigin, const URL& clientURL, GetRegistrationsCallback&&) final;
 
     void didResolveRegistrationPromise(const WebCore::ServiceWorkerRegistrationKey&) final;
-    void updateThrottleState() final;
-    bool isThrottleable() const final { return m_isThrottleable; }
     void storeRegistrationsOnDiskForTesting(CompletionHandler<void()>&&) final;
 
     void scheduleStorageJob(const WebCore::ServiceWorkerJobData&);

Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp (251438 => 251439)


--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -55,15 +55,18 @@
 
 WebCore::SWClientConnection& WebServiceWorkerProvider::serviceWorkerConnection()
 {
+    ASSERT(RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled());
     return WebProcess::singleton().ensureNetworkProcessConnection().serviceWorkerConnection();
 }
 
-WebCore::SWClientConnection* WebServiceWorkerProvider::existingServiceWorkerConnection()
+void WebServiceWorkerProvider::updateThrottleState(bool isThrottleable)
 {
     auto* networkProcessConnection = WebProcess::singleton().existingNetworkProcessConnection();
     if (!networkProcessConnection)
-        return nullptr;
-    return networkProcessConnection->existingServiceWorkerConnection();
+        return;
+    auto& connection = networkProcessConnection->serviceWorkerConnection();
+    if (isThrottleable != connection.isThrottleable())
+        connection.updateThrottleState();
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h (251438 => 251439)


--- trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/WebProcess/Storage/WebServiceWorkerProvider.h	2019-10-22 17:09:59 UTC (rev 251439)
@@ -41,12 +41,12 @@
     static WebServiceWorkerProvider& singleton();
 
     void didReceiveServiceWorkerClientRegistrationMatch(IPC::Connection&, IPC::Decoder&);
+    void updateThrottleState(bool isThrottleable);
 
 private:
     friend NeverDestroyed<WebServiceWorkerProvider>;
     WebServiceWorkerProvider();
 
-    WebCore::SWClientConnection* existingServiceWorkerConnection() final;
     WebCore::SWClientConnection& serviceWorkerConnection() final;
 }; // class WebServiceWorkerProvider
 

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (251438 => 251439)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2019-10-22 17:09:59 UTC (rev 251439)
@@ -119,6 +119,7 @@
 #include "WebProcessPoolMessages.h"
 #include "WebProcessProxyMessages.h"
 #include "WebProgressTrackerClient.h"
+#include "WebServiceWorkerProvider.h"
 #include "WebSocketProvider.h"
 #include "WebSpeechSynthesisClient.h"
 #include "WebStorageNamespaceProvider.h"
@@ -217,7 +218,6 @@
 #include <WebCore/SWClientConnection.h>
 #include <WebCore/ScriptController.h>
 #include <WebCore/SerializedScriptValue.h>
-#include <WebCore/ServiceWorkerProvider.h>
 #include <WebCore/Settings.h>
 #include <WebCore/ShadowRoot.h>
 #include <WebCore/SharedBuffer.h>
@@ -651,11 +651,6 @@
     WebCore::setAdditionalSupportedImageTypes(parameters.additionalSupportedImageTypes);
 #endif
 
-#if ENABLE(SERVICE_WORKER)
-    if (parameters.hasRegisteredServiceWorkers)
-        ServiceWorkerProvider::singleton().setMayHaveRegisteredServiceWorkers();
-#endif
-
     m_needsFontAttributes = parameters.needsFontAttributes;
 
 #if ENABLE(WEB_RTC)
@@ -792,12 +787,11 @@
         m_userActivity.start();
 
 #if ENABLE(SERVICE_WORKER)
-    RunLoop::main().dispatch([isThrottleable] {
-        if (auto* connection = ServiceWorkerProvider::singleton().existingServiceWorkerConnection()) {
-            if (isThrottleable != connection->isThrottleable())
-                connection->updateThrottleState();
-        }
-    });
+    if (RuntimeEnabledFeatures::sharedFeatures().serviceWorkerEnabled()) {
+        RunLoop::main().dispatch([isThrottleable] {
+            WebServiceWorkerProvider::singleton().updateThrottleState(isThrottleable);
+        });
+    }
 #endif
 }
 

Modified: trunk/Tools/ChangeLog (251438 => 251439)


--- trunk/Tools/ChangeLog	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Tools/ChangeLog	2019-10-22 17:09:59 UTC (rev 251439)
@@ -1,3 +1,13 @@
+2019-10-22  youenn fablet  <[email protected]>
+
+        Remove mayHaveServiceWorkerRegisteredForOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=203055
+
+        Reviewed by Alex Christensen.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
+        Remove obsolete test.
+
 2019-10-22  Antti Koivisto  <[email protected]>
 
         operator==(Vector, Vector) should work with different inline capacities

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm (251438 => 251439)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm	2019-10-22 17:04:42 UTC (rev 251438)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm	2019-10-22 17:09:59 UTC (rev 251439)
@@ -866,8 +866,7 @@
 
 static const char* regularPageWithConnectionBytes = R"SWRESOURCE(
 <script>
-var result = window.internals.hasServiceWorkerConnection() ? "PASS" : "FAIL";
-window.webkit.messageHandlers.regularPage.postMessage(result);
+window.webkit.messageHandlers.regularPage.postMessage("PASS");
 </script>
 )SWRESOURCE";
 
@@ -1052,84 +1051,6 @@
     done = false;
 }
 
-TEST(ServiceWorkers, HasServiceWorkerRegistrationBit)
-{
-    [WKWebsiteDataStore _allowWebsiteDataRecordsForAllOrigins];
-
-    RetainPtr<WKWebViewConfiguration> configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    setConfigurationInjectedBundlePath(configuration.get());
-
-    done = false;
-
-    [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    [[configuration websiteDataStore] fetchDataRecordsOfTypes:[NSSet setWithObject:WKWebsiteDataTypeServiceWorkerRegistrations] completionHandler:^(NSArray<WKWebsiteDataRecord *> *websiteDataRecords) {
-
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    RetainPtr<SWMessageHandler> messageHandler = adoptNS([[SWMessageHandler alloc] init]);
-    [[configuration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
-    RetainPtr<RegularPageMessageHandler> regularPageMessageHandler = adoptNS([[RegularPageMessageHandler alloc] init]);
-    [[configuration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
-
-    ServiceWorkerTCPServer server({
-        { "text/html", mainBytesWithScope },
-        { "application/_javascript_", scriptBytes },
-    }, {
-        { "text/html", regularPageWithConnectionBytes },
-    }, {
-        { "text/html", regularPageWithConnectionBytes }
-    });
-
-    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
-
-    // Load a page that registers a service worker.
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-    webView = nullptr;
-
-    // Now that a sw is registered, let's create a new configuration and try loading a regular page
-    RetainPtr<WKWebViewConfiguration> newConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
-    setConfigurationInjectedBundlePath(newConfiguration.get());
-
-    [[newConfiguration userContentController] addScriptMessageHandler:messageHandler.get() name:@"sw"];
-    [[newConfiguration userContentController] addScriptMessageHandler:regularPageMessageHandler.get() name:@"regularPage"];
-
-    newConfiguration.get().websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
-    [newConfiguration.get().websiteDataStore _setServiceWorkerRegistrationDirectory: @"~/nonexistingfolder"];
-
-    webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    // Let's use the web site data store that has service worker and load a page.
-    newConfiguration.get().websiteDataStore = [configuration websiteDataStore];
-
-    webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:newConfiguration.get()]);
-    EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
-    [webView loadRequest:server.request()];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-
-    // Make sure that loading the simple page did not start the service worker process.
-    EXPECT_EQ(2u, webView.get().configuration.processPool._webProcessCountIgnoringPrewarmed);
-
-    [[configuration websiteDataStore] removeDataOfTypes:[WKWebsiteDataStore allWebsiteDataTypes] modifiedSince:[NSDate distantPast] completionHandler:^() {
-        done = true;
-    }];
-    TestWebKitAPI::Util::run(&done);
-    done = false;
-}
-
 static const char* readCacheBytes = R"SWRESOURCE(
 <script>
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to