Get a directory path to SWServers for storing ServiceWorker registrations.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 21:50:31 +0000 (21:50 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Dec 2017 21:50:31 +0000 (21:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=180362

Reviewed by Chris Dumez.

Source/WebCore:

No new tests (No observable behavior change yet).

* workers/service/server/SWServer.cpp:
(WebCore::SWServer::SWServer):
* workers/service/server/SWServer.h:

Source/WebKit:

This gets all of the plumbing in place for specifying a ServiceWorker registration storage path
in a particular WebsiteDataStore.

* Shared/Storage/StorageProcessCreationParameters.cpp:
(WebKit::StorageProcessCreationParameters::encode const):
(WebKit::StorageProcessCreationParameters::decode):
* Shared/Storage/StorageProcessCreationParameters.h:

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

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::createWithLegacyOptions):
(API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration):
(API::ProcessPoolConfiguration::ProcessPoolConfiguration):
* UIProcess/API/APIProcessPoolConfiguration.h:

* UIProcess/API/APIWebsiteDataStore.h:
* UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
(API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):
* UIProcess/API/glib/APIWebsiteDataStoreGLib.cpp:
(API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):

* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory):
(WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
* UIProcess/WebProcessPool.h:

* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary):
(WebKit::WebsiteDataStore::storageProcessParameters):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::resolvedServiceWorkerRegistrationDirectory const):

* UIProcess/gtk/WebProcessPoolGtk.cpp:
(WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):

* UIProcess/wpe/WebProcessPoolWPE.cpp:
(WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):

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

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/workers/service/server/SWServer.cpp
Source/WebCore/workers/service/server/SWServer.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/Storage/StorageProcessCreationParameters.cpp
Source/WebKit/Shared/Storage/StorageProcessCreationParameters.h
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp
Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h
Source/WebKit/UIProcess/API/APIWebsiteDataStore.h
Source/WebKit/UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm
Source/WebKit/UIProcess/API/glib/APIWebsiteDataStoreGLib.cpp
Source/WebKit/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit/UIProcess/WebProcessPool.cpp
Source/WebKit/UIProcess/WebProcessPool.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/UIProcess/gtk/WebProcessPoolGtk.cpp
Source/WebKit/UIProcess/wpe/WebProcessPoolWPE.cpp

index 5598c29..acf1eb6 100644 (file)
@@ -1,3 +1,16 @@
+2017-12-04  Brady Eidson  <beidson@apple.com>
+
+        Get a directory path to SWServers for storing ServiceWorker registrations.
+        https://bugs.webkit.org/show_bug.cgi?id=180362
+
+        Reviewed by Chris Dumez.
+
+        No new tests (No observable behavior change yet).
+
+        * workers/service/server/SWServer.cpp:
+        (WebCore::SWServer::SWServer):
+        * workers/service/server/SWServer.h:
+
 2017-12-04  Devin Rousso  <webkit@devinrousso.com>
 
         Web Inspector: provide method for recording CanvasRenderingContext2D from JavaScript
index ca51549..ed44bcc 100644 (file)
@@ -204,9 +204,10 @@ void SWServer::Connection::syncTerminateWorker(ServiceWorkerIdentifier identifie
         m_server.syncTerminateWorker(*worker);
 }
 
-SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore)
+SWServer::SWServer(UniqueRef<SWOriginStore>&& originStore, const String& registrationDatabaseDirectory)
     : m_originStore(WTFMove(originStore))
 {
+    UNUSED_PARAM(registrationDatabaseDirectory);
     allServers().add(this);
     m_taskThread = Thread::create(ASCIILiteral("ServiceWorker Task Thread"), [this] {
         taskThreadEntryPoint();
index 9a15cb0..1564043 100644 (file)
@@ -105,7 +105,7 @@ public:
         Identifier m_identifier;
     };
 
-    WEBCORE_EXPORT explicit SWServer(UniqueRef<SWOriginStore>&&);
+    WEBCORE_EXPORT explicit SWServer(UniqueRef<SWOriginStore>&&, const String& registrationDatabaseDirectory);
     WEBCORE_EXPORT ~SWServer();
 
     WEBCORE_EXPORT void clearAll();
index 5ff0bea..552d614 100644 (file)
@@ -1,3 +1,54 @@
+2017-12-04  Brady Eidson  <beidson@apple.com>
+
+        Get a directory path to SWServers for storing ServiceWorker registrations.
+        https://bugs.webkit.org/show_bug.cgi?id=180362
+
+        Reviewed by Chris Dumez.
+
+        This gets all of the plumbing in place for specifying a ServiceWorker registration storage path
+        in a particular WebsiteDataStore.
+
+        * Shared/Storage/StorageProcessCreationParameters.cpp:
+        (WebKit::StorageProcessCreationParameters::encode const):
+        (WebKit::StorageProcessCreationParameters::decode):
+        * Shared/Storage/StorageProcessCreationParameters.h:
+
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::initializeWebsiteDataStore):
+        (WebKit::StorageProcess::swServerForSession):
+        * StorageProcess/StorageProcess.h:
+
+        * UIProcess/API/APIProcessPoolConfiguration.cpp:
+        (API::ProcessPoolConfiguration::createWithLegacyOptions):
+        (API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration):
+        (API::ProcessPoolConfiguration::ProcessPoolConfiguration):
+        * UIProcess/API/APIProcessPoolConfiguration.h:
+
+        * UIProcess/API/APIWebsiteDataStore.h:
+        * UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
+        (API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):
+        * UIProcess/API/glib/APIWebsiteDataStoreGLib.cpp:
+        (API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):
+
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory):
+        (WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
+        * UIProcess/WebProcessPool.h:
+
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::resolveDirectoriesIfNecessary):
+        (WebKit::WebsiteDataStore::storageProcessParameters):
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        (WebKit::WebsiteDataStore::resolvedServiceWorkerRegistrationDirectory const):
+
+        * UIProcess/gtk/WebProcessPoolGtk.cpp:
+        (WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):
+
+        * UIProcess/wpe/WebProcessPoolWPE.cpp:
+        (WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory):
+
 2017-12-04  Frederic Wang  <fwang@igalia.com>
 
         Make ScrollingTreeNode::enclosingFrameNode return the node itself for frame nodes
index 4fe3407..8e654f3 100644 (file)
@@ -36,23 +36,31 @@ StorageProcessCreationParameters::StorageProcessCreationParameters()
 
 void StorageProcessCreationParameters::encode(IPC::Encoder& encoder) const
 {
-#if ENABLE(INDEXED_DATABASE)
     encoder << sessionID;
-    encoder << indexedDatabaseDirectory;
-    encoder << indexedDatabaseDirectoryExtensionHandle;
+#if ENABLE(INDEXED_DATABASE)
+    encoder << indexedDatabaseDirectory << indexedDatabaseDirectoryExtensionHandle;
+#endif
+#if ENABLE(SERVICE_WORKER)
+    encoder << serviceWorkerRegistrationDirectory << serviceWorkerRegistrationDirectoryExtensionHandle;
 #endif
 }
 
 bool StorageProcessCreationParameters::decode(IPC::Decoder& decoder, StorageProcessCreationParameters& result)
 {
-#if ENABLE(INDEXED_DATABASE)
     if (!decoder.decode(result.sessionID))
         return false;
+#if ENABLE(INDEXED_DATABASE)
     if (!decoder.decode(result.indexedDatabaseDirectory))
         return false;
     if (!decoder.decode(result.indexedDatabaseDirectoryExtensionHandle))
         return false;
 #endif
+#if ENABLE(SERVICE_WORKER)
+    if (!decoder.decode(result.serviceWorkerRegistrationDirectory))
+        return false;
+    if (!decoder.decode(result.serviceWorkerRegistrationDirectoryExtensionHandle))
+        return false;
+#endif
 
     return true;
 }
index 41c195f..f60b503 100644 (file)
@@ -49,6 +49,11 @@ struct StorageProcessCreationParameters {
     String indexedDatabaseDirectory;
     SandboxExtension::Handle indexedDatabaseDirectoryExtensionHandle;
 #endif
+
+#if ENABLE(SERVICE_WORKER)
+    String serviceWorkerRegistrationDirectory;
+    SandboxExtension::Handle serviceWorkerRegistrationDirectoryExtensionHandle;
+#endif
 };
 
 } // namespace WebKit
index 6e7d064..ad9590e 100644 (file)
@@ -143,14 +143,22 @@ void StorageProcess::initializeWebsiteDataStore(const StorageProcessCreationPara
     // IMPORTANT: Do not change the directory structure for indexed databases on disk without first consulting a reviewer from Apple (<rdar://problem/17454712>)
     // *********
 
-    auto addResult = m_idbDatabasePaths.add(parameters.sessionID, String());
-    if (!addResult.isNewEntry)
-        return;
-
-    addResult.iterator->value = parameters.indexedDatabaseDirectory;
-    SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
-
-    postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.indexedDatabaseDirectory));
+    auto addResult = m_idbDatabasePaths.ensure(parameters.sessionID, [path = parameters.indexedDatabaseDirectory] {
+        return path;
+    });
+    if (addResult.isNewEntry) {
+        SandboxExtension::consumePermanently(parameters.indexedDatabaseDirectoryExtensionHandle);
+        postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.indexedDatabaseDirectory));
+    }
+#endif
+#if ENABLE(SERVICE_WORKER)
+    addResult = m_swDatabasePaths.ensure(parameters.sessionID, [path = parameters.serviceWorkerRegistrationDirectory] {
+        return path;
+    });
+    if (addResult.isNewEntry) {
+        SandboxExtension::consumePermanently(parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
+        postStorageTask(createCrossThreadTask(*this, &StorageProcess::ensurePathExists, parameters.serviceWorkerRegistrationDirectory));
+    }
 #endif
 }
 
@@ -371,10 +379,17 @@ void StorageProcess::didGetSandboxExtensionsForBlobFiles(uint64_t requestID, San
 SWServer& StorageProcess::swServerForSession(PAL::SessionID sessionID)
 {
     auto result = m_swServers.add(sessionID, nullptr);
-    if (result.isNewEntry)
-        result.iterator->value = std::make_unique<SWServer>(makeUniqueRef<WebSWOriginStore>());
+    if (!result.isNewEntry) {
+        ASSERT(result.iterator->value);
+        return *result.iterator->value;
+    }
+
+    auto path = m_swDatabasePaths.get(sessionID);
+    // There should already be a registered path for this PAL::SessionID.
+    // If there's not, then where did this PAL::SessionID come from?
+    ASSERT(!path.isEmpty());
 
-    ASSERT(result.iterator->value);
+    result.iterator->value = std::make_unique<SWServer>(makeUniqueRef<WebSWOriginStore>(), path);
     return *result.iterator->value;
 }
 
index 81587b0..171c7a6 100644 (file)
@@ -161,6 +161,7 @@ private:
 
     RefPtr<WebSWServerToContextConnection> m_serverToContextConnection;
     bool m_waitingForServerToContextProcessConnection { false };
+    HashMap<PAL::SessionID, String> m_swDatabasePaths;
     HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
     HashMap<WebCore::SWServerConnectionIdentifier, WebSWServerConnection*> m_swServerConnections;
 #endif
index e969406..239a5d9 100644 (file)
@@ -49,6 +49,7 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::createWithLegacyOptions(
     configuration->m_diskCacheDirectory = WebKit::WebProcessPool::legacyPlatformDefaultNetworkCacheDirectory();
     configuration->m_mediaCacheDirectory = WebKit::WebProcessPool::legacyPlatformDefaultMediaCacheDirectory();
     configuration->m_indexedDBDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory();
+    configuration->m_serviceWorkerRegistrationDirectory = WebKit::WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory();
     configuration->m_localStorageDirectory = WebKit::WebProcessPool::legacyPlatformDefaultLocalStorageDirectory();
     configuration->m_mediaKeysStorageDirectory = WebKit::WebProcessPool::legacyPlatformDefaultMediaKeysStorageDirectory();
     configuration->m_webSQLDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultWebSQLDatabaseDirectory();
@@ -66,6 +67,7 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::createWithWebsiteDataSto
     configuration->m_diskCacheDirectory = legacyConfiguration.networkCacheDirectory;
     configuration->m_mediaCacheDirectory = legacyConfiguration.mediaCacheDirectory;
     configuration->m_indexedDBDatabaseDirectory = WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory();
+    configuration->m_serviceWorkerRegistrationDirectory = WebKit::WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory();
     configuration->m_localStorageDirectory = legacyConfiguration.localStorageDirectory;
     configuration->m_mediaKeysStorageDirectory = legacyConfiguration.mediaKeysStorageDirectory;
     configuration->m_resourceLoadStatisticsDirectory = legacyConfiguration.resourceLoadStatisticsDirectory;
@@ -80,6 +82,7 @@ ProcessPoolConfiguration::ProcessPoolConfiguration()
     , m_diskCacheDirectory(WebsiteDataStore::defaultNetworkCacheDirectory())
     , m_mediaCacheDirectory(WebsiteDataStore::defaultMediaCacheDirectory())
     , m_indexedDBDatabaseDirectory(WebsiteDataStore::defaultIndexedDBDatabaseDirectory())
+    , m_serviceWorkerRegistrationDirectory(WebsiteDataStore::defaultServiceWorkerRegistrationDirectory())
     , m_localStorageDirectory(WebsiteDataStore::defaultLocalStorageDirectory())
     , m_webSQLDatabaseDirectory(WebsiteDataStore::defaultWebSQLDatabaseDirectory())
     , m_mediaKeysStorageDirectory(WebsiteDataStore::defaultMediaKeysStorageDirectory())
index 196c2dd..e0abc01 100644 (file)
@@ -76,6 +76,9 @@ public:
     const WTF::String& indexedDBDatabaseDirectory() const { return m_indexedDBDatabaseDirectory; }
     void setIndexedDBDatabaseDirectory(const WTF::String& indexedDBDatabaseDirectory) { m_indexedDBDatabaseDirectory = indexedDBDatabaseDirectory; }
 
+    const WTF::String& serviceWorkerRegistrationDirectory() const { return m_serviceWorkerRegistrationDirectory; }
+    void setServiceWorkerRegistrationDirectory(const WTF::String& directory) { m_serviceWorkerRegistrationDirectory = directory; }
+    
     const WTF::String& injectedBundlePath() const { return m_injectedBundlePath; }
     void setInjectedBundlePath(const WTF::String& injectedBundlePath) { m_injectedBundlePath = injectedBundlePath; }
 
@@ -148,6 +151,7 @@ private:
     WTF::String m_diskCacheDirectory;
     WTF::String m_mediaCacheDirectory;
     WTF::String m_indexedDBDatabaseDirectory;
+    WTF::String m_serviceWorkerRegistrationDirectory;
     WTF::String m_injectedBundlePath;
     WTF::String m_localStorageDirectory;
     WTF::String m_webSQLDatabaseDirectory;
index ae24659..fb5d527 100644 (file)
@@ -58,6 +58,7 @@ public:
     static String defaultMediaCacheDirectory();
 
     static String defaultIndexedDBDatabaseDirectory();
+    static String defaultServiceWorkerRegistrationDirectory();
     static String defaultLocalStorageDirectory();
     static String defaultMediaKeysStorageDirectory();
     static String defaultWebSQLDatabaseDirectory();
index 3fbd1b4..e92fc3c 100644 (file)
@@ -72,6 +72,11 @@ String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
     return websiteDataDirectoryFileSystemRepresentation("IndexedDB");
 }
 
+String WebsiteDataStore::defaultServiceWorkerRegistrationDirectory()
+{
+    return websiteDataDirectoryFileSystemRepresentation("ServiceWorkers");
+}
+
 String WebsiteDataStore::defaultLocalStorageDirectory()
 {
     return websiteDataDirectoryFileSystemRepresentation("LocalStorage");
index 466c0cf..eb024bb 100644 (file)
@@ -58,6 +58,12 @@ String WebsiteDataStore::defaultIndexedDBDatabaseDirectory()
     return websiteDataDirectoryFileSystemRepresentation(BASE_DIRECTORY G_DIR_SEPARATOR_S "databases" G_DIR_SEPARATOR_S "indexeddb");
 }
 
+String WebsiteDataStore::defaultServiceWorkerRegistrationDirectory()
+{
+    // FIXME: Implement
+    return { };
+}
+
 String WebsiteDataStore::defaultLocalStorageDirectory()
 {
     return websiteDataDirectoryFileSystemRepresentation(BASE_DIRECTORY G_DIR_SEPARATOR_S "localstorage");
index 123c3d2..c5e2d6c 100644 (file)
@@ -62,6 +62,7 @@
 using namespace WebCore;
 
 NSString *WebDatabaseDirectoryDefaultsKey = @"WebDatabaseDirectory";
+NSString *WebServiceWorkerRegistrationDirectoryDefaultsKey = @"WebServiceWorkerRegistrationDirectory";
 NSString *WebKitLocalCacheDefaultsKey = @"WebKitLocalCache";
 NSString *WebStorageDirectoryDefaultsKey = @"WebKitLocalStorageDatabasePathPreferenceKey";
 NSString *WebKitJSCJITEnabledDefaultsKey = @"WebKitJSCJITEnabledDefaultsKey";
@@ -389,6 +390,16 @@ String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
     return FileSystem::pathByAppendingComponent(legacyPlatformDefaultWebSQLDatabaseDirectory(), "___IndexedDB");
 }
 
+String WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory()
+{
+    registerUserDefaultsIfNeeded();
+
+    NSString *directory = [[NSUserDefaults standardUserDefaults] objectForKey:WebServiceWorkerRegistrationDirectoryDefaultsKey];
+    if (!directory || ![directory isKindOfClass:[NSString class]])
+        directory = @"~/Library/WebKit/ServiceWorkers";
+    return stringByResolvingSymlinksInPath([directory stringByStandardizingPath]);
+}
+
 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
 {
     registerUserDefaultsIfNeeded();
index 45c012f..ac7cbbc 100644 (file)
@@ -559,6 +559,12 @@ void WebProcessPool::ensureStorageProcessAndWebsiteDataStore(WebsiteDataStore* r
             SandboxExtension::createHandleForReadWriteDirectory(parameters.indexedDatabaseDirectory, parameters.indexedDatabaseDirectoryExtensionHandle);
         }
 #endif
+#if ENABLE(SERVICE_WORKER)
+        if (parameters.serviceWorkerRegistrationDirectory.isEmpty()) {
+            parameters.serviceWorkerRegistrationDirectory = m_configuration->serviceWorkerRegistrationDirectory();
+            SandboxExtension::createHandleForReadWriteDirectory(parameters.serviceWorkerRegistrationDirectory, parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
+        }
+#endif
 
         m_storageProcess = StorageProcessProxy::create(*this);
         m_storageProcess->send(Messages::StorageProcess::InitializeWebsiteDataStore(parameters), 0);
index 41aa3c3..5f14501 100644 (file)
@@ -390,6 +390,7 @@ public:
     // FIXME: Move these to API::WebsiteDataStore.
     static String legacyPlatformDefaultLocalStorageDirectory();
     static String legacyPlatformDefaultIndexedDBDatabaseDirectory();
+    static String legacyPlatformDefaultServiceWorkerRegistrationDirectory();
     static String legacyPlatformDefaultWebSQLDatabaseDirectory();
     static String legacyPlatformDefaultMediaKeysStorageDirectory();
     static String legacyPlatformDefaultMediaCacheDirectory();
index 583dec9..361869e 100644 (file)
@@ -113,13 +113,12 @@ void WebsiteDataStore::resolveDirectoriesIfNecessary()
         m_resolvedConfiguration.mediaKeysStorageDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration.mediaKeysStorageDirectory);
     if (!m_configuration.webSQLDatabaseDirectory.isEmpty())
         m_resolvedConfiguration.webSQLDatabaseDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration.webSQLDatabaseDirectory);
-
     if (!m_configuration.indexedDBDatabaseDirectory.isEmpty())
         m_resolvedConfiguration.indexedDBDatabaseDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration.indexedDBDatabaseDirectory);
-
+    if (!m_configuration.serviceWorkerRegistrationDirectory.isEmpty())
+        m_resolvedConfiguration.serviceWorkerRegistrationDirectory = resolveAndCreateReadWriteDirectoryForSandboxExtension(m_configuration.serviceWorkerRegistrationDirectory);
     if (!m_configuration.javaScriptConfigurationDirectory.isEmpty())
         m_resolvedConfiguration.javaScriptConfigurationDirectory = resolvePathForSandboxExtension(m_configuration.javaScriptConfigurationDirectory);
-
     if (!m_configuration.cacheStorageDirectory.isEmpty() && m_resolvedConfiguration.cacheStorageDirectory.isEmpty())
         m_resolvedConfiguration.cacheStorageDirectory = resolvePathForSandboxExtension(m_configuration.cacheStorageDirectory);
 
@@ -1376,6 +1375,11 @@ StorageProcessCreationParameters WebsiteDataStore::storageProcessParameters()
     if (!parameters.indexedDatabaseDirectory.isEmpty())
         SandboxExtension::createHandleForReadWriteDirectory(parameters.indexedDatabaseDirectory, parameters.indexedDatabaseDirectoryExtensionHandle);
 #endif
+#if ENABLE(SERVICE_WORKER)
+    parameters.serviceWorkerRegistrationDirectory = resolvedServiceWorkerRegistrationDirectory();
+    if (!parameters.serviceWorkerRegistrationDirectory.isEmpty())
+        SandboxExtension::createHandleForReadWriteDirectory(parameters.serviceWorkerRegistrationDirectory, parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
+#endif
 
     return parameters;
 }
index 463f7c6..a13f4cb 100644 (file)
@@ -79,6 +79,7 @@ public:
 
         String mediaCacheDirectory;
         String indexedDBDatabaseDirectory;
+        String serviceWorkerRegistrationDirectory;
         String webSQLDatabaseDirectory;
         String localStorageDirectory;
         String mediaKeysStorageDirectory;
@@ -127,6 +128,7 @@ public:
     const String& resolvedJavaScriptConfigurationDirectory() const { return m_resolvedConfiguration.javaScriptConfigurationDirectory; }
     const String& resolvedCookieStorageFile() const { return m_resolvedConfiguration.cookieStorageFile; }
     const String& resolvedIndexedDatabaseDirectory() const { return m_resolvedConfiguration.indexedDBDatabaseDirectory; }
+    const String& resolvedServiceWorkerRegistrationDirectory() const { return m_resolvedConfiguration.serviceWorkerRegistrationDirectory; }
 
     StorageManager* storageManager() { return m_storageManager.get(); }
 
index b4a1723..21669ff 100644 (file)
@@ -106,6 +106,11 @@ String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
     return API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory();
 }
 
+String WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory()
+{
+    return API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
+}
+
 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
 {
     return API::WebsiteDataStore::defaultLocalStorageDirectory();
index 73d801b..b29a92b 100644 (file)
@@ -111,6 +111,13 @@ String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
     return WebCore::FileSystem::stringFromFileSystemRepresentation(indexedDBDatabaseDirectory.get());
 }
 
+String WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory()
+{
+    // FIXME: Implement when implementing ServiceWorkers
+    notImplemented();
+    return String();
+}
+
 String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
 {
     GUniquePtr<gchar> storageDirectory(g_build_filename(g_get_user_data_dir(), "wpe", "localstorage", nullptr));