Skip to content
Permalink
Browse files
Avoid constructing a service worker RegistrationStore for private ses…
…sions

https://bugs.webkit.org/show_bug.cgi?id=184463
<rdar://problem/36613948>

Reviewed by Youenn Fablet.

Avoid constructing a service worker RegistrationStore for private sessions since there
is no need for persistence and the registrationDatabaseDirectory is the empty string in
such cases.

Source/WebCore:

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::removeRegistration):
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clear):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::didFinishActivation):
* workers/service/server/SWServer.h:

Source/WebKit:

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::initializeWebsiteDataStore):


Canonical link: https://commits.webkit.org/200025@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230500 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Apr 10, 2018
1 parent 76a5f02 commit 11e1dd6b1e9d4eaded33044ded81a5f6670d8159
@@ -1,3 +1,23 @@
2018-04-10 Chris Dumez <cdumez@apple.com>

Avoid constructing a service worker RegistrationStore for private sessions
https://bugs.webkit.org/show_bug.cgi?id=184463
<rdar://problem/36613948>

Reviewed by Youenn Fablet.

Avoid constructing a service worker RegistrationStore for private sessions since there
is no need for persistence and the registrationDatabaseDirectory is the empty string in
such cases.

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::removeRegistration):
(WebCore::SWServer::clearAll):
(WebCore::SWServer::clear):
(WebCore::SWServer::SWServer):
(WebCore::SWServer::didFinishActivation):
* workers/service/server/SWServer.h:

2018-04-10 Chris Dumez <cdumez@apple.com>

Unreviewed build fix.
@@ -165,7 +165,8 @@ void SWServer::removeRegistration(const ServiceWorkerRegistrationKey& key)
ASSERT_UNUSED(wasRemoved, wasRemoved);

m_originStore->remove(topOrigin);
m_registrationStore.removeRegistration(*registration);
if (m_registrationStore)
m_registrationStore->removeRegistration(*registration);
}

Vector<ServiceWorkerRegistrationData> SWServer::getRegistrations(const SecurityOriginData& topOrigin, const URL& clientURL)
@@ -202,7 +203,8 @@ void SWServer::clearAll(CompletionHandler<void()>&& completionHandler)
ASSERT(m_registrationsByID.isEmpty());
m_pendingContextDatas.clear();
m_originStore->clearAll();
m_registrationStore.clearAll(WTFMove(completionHandler));
if (m_registrationStore)
m_registrationStore->clearAll(WTFMove(completionHandler));
}

void SWServer::clear(const SecurityOriginData& securityOrigin, CompletionHandler<void()>&& completionHandler)
@@ -240,7 +242,8 @@ void SWServer::clear(const SecurityOriginData& securityOrigin, CompletionHandler
for (auto* registration : registrationsToRemove)
registration->clear();

m_registrationStore.flushChanges(WTFMove(completionHandler));
if (m_registrationStore)
m_registrationStore->flushChanges(WTFMove(completionHandler));
}

void SWServer::Connection::finishFetchingScriptInServer(const ServiceWorkerFetchResult& result)
@@ -271,9 +274,14 @@ void SWServer::Connection::syncTerminateWorker(ServiceWorkerIdentifier identifie

SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore, String&& registrationDatabaseDirectory, PAL::SessionID sessionID)
: m_originStore(WTFMove(originStore))
, m_registrationStore(*this, WTFMove(registrationDatabaseDirectory))
, m_sessionID(sessionID)
{
ASSERT(!registrationDatabaseDirectory.isEmpty() || m_sessionID.isEphemeral());
if (!m_sessionID.isEphemeral())
m_registrationStore = std::make_unique<RegistrationStore>(*this, WTFMove(registrationDatabaseDirectory));
else
registrationStoreImportComplete();

UNUSED_PARAM(registrationDatabaseDirectory);
allServers().add(this);
}
@@ -406,7 +414,8 @@ void SWServer::didFinishActivation(SWServerWorker& worker)
if (!registration)
return;

m_registrationStore.updateRegistration(worker.contextData());
if (m_registrationStore)
m_registrationStore->updateRegistration(worker.contextData());
registration->didFinishActivation(worker.identifier());
}

@@ -29,7 +29,6 @@

#include "ClientOrigin.h"
#include "DocumentIdentifier.h"
#include "RegistrationStore.h"
#include "SWServerWorker.h"
#include "SecurityOriginData.h"
#include "ServiceWorkerClientData.h"
@@ -49,6 +48,7 @@

namespace WebCore {

class RegistrationStore;
class SWOriginStore;
class SWServerJobQueue;
class SWServerRegistration;
@@ -228,7 +228,7 @@ class SWServer {
HashMap<ServiceWorkerClientIdentifier, ServiceWorkerRegistrationIdentifier> m_clientToControllingRegistration;

UniqueRef<SWOriginStore> m_originStore;
RegistrationStore m_registrationStore;
std::unique_ptr<RegistrationStore> m_registrationStore;
HashMap<SecurityOriginData, Vector<ServiceWorkerContextData>> m_pendingContextDatas;
HashMap<SecurityOriginData, HashMap<ServiceWorkerIdentifier, Vector<RunServiceWorkerCallback>>> m_serviceWorkerRunRequests;
PAL::SessionID m_sessionID;
@@ -27,6 +27,7 @@

#if ENABLE(SERVICE_WORKER)

#include "ContentSecurityPolicyResponseHeaders.h"
#include "ServiceWorkerClientData.h"
#include "ServiceWorkerData.h"
#include "ServiceWorkerIdentifier.h"
@@ -1,3 +1,18 @@
2018-04-10 Chris Dumez <cdumez@apple.com>

Avoid constructing a service worker RegistrationStore for private sessions
https://bugs.webkit.org/show_bug.cgi?id=184463
<rdar://problem/36613948>

Reviewed by Youenn Fablet.

Avoid constructing a service worker RegistrationStore for private sessions since there
is no need for persistence and the registrationDatabaseDirectory is the empty string in
such cases.

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::initializeWebsiteDataStore):

2018-04-10 Andy Estes <aestes@apple.com>

[iOS] Navigate to URL and page number annotations in WKPDFView
@@ -194,7 +194,8 @@ void StorageProcess::initializeWebsiteDataStore(const StorageProcessCreationPara
});
if (addResult.isNewEntry) {
SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.indexedDatabaseDirectory));
if (!parameters.indexedDatabaseDirectory.isEmpty())
postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.indexedDatabaseDirectory));
}
#endif
#if ENABLE(SERVICE_WORKER)
@@ -206,7 +207,8 @@ void StorageProcess::initializeWebsiteDataStore(const StorageProcessCreationPara
});
if (addResult.isNewEntry) {
SandboxExtension::consumePermanently(parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.serviceWorkerRegistrationDirectory));
if (!parameters.serviceWorkerRegistrationDirectory.isEmpty())
postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.serviceWorkerRegistrationDirectory));
}

for (auto& scheme : parameters.urlSchemesServiceWorkersCanHandle)

0 comments on commit 11e1dd6

Please sign in to comment.