Skip to content
Permalink
Browse files
Configure serviceWorkerRegistrationDirectory on the web site data sto…
…re and move it to a Caches subfolder as a default

https://bugs.webkit.org/show_bug.cgi?id=182403

Patch by Youenn Fablet <youenn@apple.com> on 2018-02-02
Reviewed by Alex Christensen.

Source/WebKit:

WebsiteDataStore is the place to set configuration information such as service worker registration path.
This patch updates WebKit code accordingly.
By default, the service worker registration path is in a Caches subfolder, similarly to cache API path.

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::createWithLegacyOptions):
(API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration):
(API::ProcessPoolConfiguration::ProcessPoolConfiguration):
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/C/WKContextConfigurationRef.cpp:
(WKContextConfigurationCopyServiceWorkerDatabaseDirectory): Deleted.
(WKContextConfigurationSetServiceWorkerDatabaseDirectory): Deleted.
* UIProcess/API/C/WKContextConfigurationRef.h:
* UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
(API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _serviceWorkerRegistrationDirectory]):
(-[WKWebsiteDataStore _setServiceWorkerRegistrationDirectory:]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
(WebKit::WebProcessPool::initializeNewWebProcess):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::serviceWorkerRegistrationDirectory const):
(WebKit::WebsiteDataStore::setServiceWorkerRegistrationDirectory):
* UIProcess/gtk/WebProcessPoolGtk.cpp:
* UIProcess/gtk/WebProcessPoolWPE.cpp:

Tools:

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::generateContextConfiguration const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):

Canonical link: https://commits.webkit.org/198237@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228019 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
youennf authored and webkit-commit-queue committed Feb 2, 2018
1 parent 3c52452 commit cd7142219a816a420f241bbc8b70df275feff738
Showing 17 changed files with 70 additions and 48 deletions.
@@ -1,3 +1,39 @@
2018-02-02 Youenn Fablet <youenn@apple.com>

Configure serviceWorkerRegistrationDirectory on the web site data store and move it to a Caches subfolder as a default
https://bugs.webkit.org/show_bug.cgi?id=182403

Reviewed by Alex Christensen.

WebsiteDataStore is the place to set configuration information such as service worker registration path.
This patch updates WebKit code accordingly.
By default, the service worker registration path is in a Caches subfolder, similarly to cache API path.

* UIProcess/API/APIProcessPoolConfiguration.cpp:
(API::ProcessPoolConfiguration::createWithLegacyOptions):
(API::ProcessPoolConfiguration::createWithWebsiteDataStoreConfiguration):
(API::ProcessPoolConfiguration::ProcessPoolConfiguration):
(API::ProcessPoolConfiguration::copy):
* UIProcess/API/APIProcessPoolConfiguration.h:
* UIProcess/API/C/WKContextConfigurationRef.cpp:
(WKContextConfigurationCopyServiceWorkerDatabaseDirectory): Deleted.
(WKContextConfigurationSetServiceWorkerDatabaseDirectory): Deleted.
* UIProcess/API/C/WKContextConfigurationRef.h:
* UIProcess/API/Cocoa/APIWebsiteDataStoreCocoa.mm:
(API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory):
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _serviceWorkerRegistrationDirectory]):
(-[WKWebsiteDataStore _setServiceWorkerRegistrationDirectory:]):
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::ensureStorageProcessAndWebsiteDataStore):
(WebKit::WebProcessPool::initializeNewWebProcess):
* UIProcess/WebsiteData/WebsiteDataStore.h:
(WebKit::WebsiteDataStore::serviceWorkerRegistrationDirectory const):
(WebKit::WebsiteDataStore::setServiceWorkerRegistrationDirectory):
* UIProcess/gtk/WebProcessPoolGtk.cpp:
* UIProcess/gtk/WebProcessPoolWPE.cpp:

2018-02-02 Wenson Hsieh <wenson_hsieh@apple.com>

[Extra Zoom Mode] Implement support for indirect mainframe scrolling
@@ -49,7 +49,6 @@ 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();
@@ -67,7 +66,6 @@ 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::legacyPlatformDefaultServiceWorkerRegistrationDirectory();
configuration->m_localStorageDirectory = legacyConfiguration.localStorageDirectory;
configuration->m_mediaKeysStorageDirectory = legacyConfiguration.mediaKeysStorageDirectory;
configuration->m_resourceLoadStatisticsDirectory = legacyConfiguration.resourceLoadStatisticsDirectory;
@@ -82,7 +80,6 @@ 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())
@@ -109,7 +106,6 @@ Ref<ProcessPoolConfiguration> ProcessPoolConfiguration::copy()
copy->m_applicationCacheFlatFileSubdirectoryName = this->m_applicationCacheFlatFileSubdirectoryName;
copy->m_mediaCacheDirectory = this->m_mediaCacheDirectory;
copy->m_indexedDBDatabaseDirectory = this->m_indexedDBDatabaseDirectory;
copy->m_serviceWorkerRegistrationDirectory = this->m_serviceWorkerRegistrationDirectory;
copy->m_injectedBundlePath = this->m_injectedBundlePath;
copy->m_localStorageDirectory = this->m_localStorageDirectory;
copy->m_mediaKeysStorageDirectory = this->m_mediaKeysStorageDirectory;
@@ -76,9 +76,6 @@ class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPo
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; }

@@ -151,7 +148,6 @@ class ProcessPoolConfiguration final : public ObjectImpl<Object::Type::ProcessPo
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;
@@ -78,16 +78,6 @@ void WKContextConfigurationSetIndexedDBDatabaseDirectory(WKContextConfigurationR
toImpl(configuration)->setIndexedDBDatabaseDirectory(toImpl(indexedDBDatabaseDirectory)->string());
}

WKStringRef WKContextConfigurationCopyServiceWorkerDatabaseDirectory(WKContextConfigurationRef configuration)
{
return toCopiedAPI(toImpl(configuration)->serviceWorkerRegistrationDirectory());
}

void WKContextConfigurationSetServiceWorkerDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef swDatabaseDirectory)
{
toImpl(configuration)->setServiceWorkerRegistrationDirectory(toImpl(swDatabaseDirectory)->string());
}

WKStringRef WKContextConfigurationCopyInjectedBundlePath(WKContextConfigurationRef configuration)
{
return toCopiedAPI(toImpl(configuration)->injectedBundlePath());
@@ -44,9 +44,6 @@ WK_EXPORT void WKContextConfigurationSetDiskCacheDirectory(WKContextConfiguratio
WK_EXPORT WKStringRef WKContextConfigurationCopyIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration);
WK_EXPORT void WKContextConfigurationSetIndexedDBDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef indexedDBDatabaseDirectory);

WK_EXPORT WKStringRef WKContextConfigurationCopyServiceWorkerDatabaseDirectory(WKContextConfigurationRef configuration);
WK_EXPORT void WKContextConfigurationSetServiceWorkerDatabaseDirectory(WKContextConfigurationRef configuration, WKStringRef swDatabaseDirectory);

WK_EXPORT WKStringRef WKContextConfigurationCopyInjectedBundlePath(WKContextConfigurationRef configuration);
WK_EXPORT void WKContextConfigurationSetInjectedBundlePath(WKContextConfigurationRef configuration, WKStringRef injectedBundlePath);

@@ -74,7 +74,7 @@

String WebsiteDataStore::defaultServiceWorkerRegistrationDirectory()
{
return websiteDataDirectoryFileSystemRepresentation("ServiceWorkers");
return cacheDirectoryFileSystemRepresentation("ServiceWorkers");
}

String WebsiteDataStore::defaultLocalStorageDirectory()
@@ -264,6 +264,16 @@ - (void)_setCacheStorageDirectory:(NSString *)directory
_websiteDataStore->websiteDataStore().setCacheStorageDirectory(directory);
}

- (NSString *)_serviceWorkerRegistrationDirectory
{
return _websiteDataStore->websiteDataStore().serviceWorkerRegistrationDirectory();
}

- (void)_setServiceWorkerRegistrationDirectory:(NSString *)directory
{
_websiteDataStore->websiteDataStore().setServiceWorkerRegistrationDirectory(directory);
}

- (void)_setBoundInterfaceIdentifier:(NSString *)identifier
{
_websiteDataStore->websiteDataStore().setBoundInterfaceIdentifier(identifier);
@@ -48,6 +48,7 @@ typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) {
@property (nonatomic, setter=_setResourceLoadStatisticsDebugMode:) BOOL _resourceLoadStatisticsDebugMode WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setCacheStoragePerOriginQuota:) NSUInteger _cacheStoragePerOriginQuota WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setCacheStorageDirectory:) NSString* _cacheStorageDirectory WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setServiceWorkerRegistrationDirectory:) NSString* _serviceWorkerRegistrationDirectory WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));

@property (nonatomic, setter=_setBoundInterfaceIdentifier:) NSString *_boundInterfaceIdentifier WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@property (nonatomic, setter=_setAllowsCellularAccess:) BOOL _allowsCellularAccess WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
@@ -403,16 +403,6 @@ static void registerUserDefaultsIfNeeded()
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();
@@ -555,7 +555,7 @@ void WebProcessPool::ensureStorageProcessAndWebsiteDataStore(WebsiteDataStore* r
#endif
#if ENABLE(SERVICE_WORKER)
if (parameters.serviceWorkerRegistrationDirectory.isEmpty()) {
parameters.serviceWorkerRegistrationDirectory = m_configuration->serviceWorkerRegistrationDirectory();
parameters.serviceWorkerRegistrationDirectory = API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
SandboxExtension::createHandleForReadWriteDirectory(parameters.serviceWorkerRegistrationDirectory, parameters.serviceWorkerRegistrationDirectoryExtensionHandle);
}

@@ -816,7 +816,10 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa
#endif

#if ENABLE(SERVICE_WORKER)
parameters.hasRegisteredServiceWorkers = ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(m_configuration->serviceWorkerRegistrationDirectory());
String serviceWorkerRegistrationDirectory = websiteDataStore.resolvedServiceWorkerRegistrationDirectory();
if (serviceWorkerRegistrationDirectory.isEmpty())
serviceWorkerRegistrationDirectory = API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
parameters.hasRegisteredServiceWorkers = ServiceWorkerProcessProxy::hasRegisteredServiceWorkers(serviceWorkerRegistrationDirectory);
#endif

#if ENABLE(NETSCAPE_PLUGIN_API)
@@ -393,7 +393,6 @@ class WebProcessPool final : public API::ObjectImpl<API::Object::Type::ProcessPo
// FIXME: Move these to API::WebsiteDataStore.
static String legacyPlatformDefaultLocalStorageDirectory();
static String legacyPlatformDefaultIndexedDBDatabaseDirectory();
static String legacyPlatformDefaultServiceWorkerRegistrationDirectory();
static String legacyPlatformDefaultWebSQLDatabaseDirectory();
static String legacyPlatformDefaultMediaKeysStorageDirectory();
static String legacyPlatformDefaultMediaCacheDirectory();
@@ -107,6 +107,8 @@ class WebsiteDataStore : public RefCounted<WebsiteDataStore>, public WebProcessL
void setCacheStoragePerOriginQuota(uint64_t quota) { m_resolvedConfiguration.cacheStoragePerOriginQuota = quota; }
const String& cacheStorageDirectory() const { return m_resolvedConfiguration.cacheStorageDirectory; }
void setCacheStorageDirectory(String&& directory) { m_resolvedConfiguration.cacheStorageDirectory = WTFMove(directory); }
const String& serviceWorkerRegistrationDirectory() const { return m_resolvedConfiguration.serviceWorkerRegistrationDirectory; }
void setServiceWorkerRegistrationDirectory(String&& directory) { m_resolvedConfiguration.serviceWorkerRegistrationDirectory = WTFMove(directory); }

WebResourceLoadStatisticsStore* resourceLoadStatistics() const { return m_resourceLoadStatistics.get(); }
void clearResourceLoadStatisticsInWebProcesses(CompletionHandler<void()>&&);
@@ -106,11 +106,6 @@ String WebProcessPool::legacyPlatformDefaultIndexedDBDatabaseDirectory()
return API::WebsiteDataStore::defaultIndexedDBDatabaseDirectory();
}

String WebProcessPool::legacyPlatformDefaultServiceWorkerRegistrationDirectory()
{
return API::WebsiteDataStore::defaultServiceWorkerRegistrationDirectory();
}

String WebProcessPool::legacyPlatformDefaultLocalStorageDirectory()
{
return API::WebsiteDataStore::defaultLocalStorageDirectory();
@@ -111,13 +111,6 @@ 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));
@@ -1,3 +1,15 @@
2018-02-02 Youenn Fablet <youenn@apple.com>

Configure serviceWorkerRegistrationDirectory on the web site data store and move it to a Caches subfolder as a default
https://bugs.webkit.org/show_bug.cgi?id=182403

Reviewed by Alex Christensen.

* WebKitTestRunner/TestController.cpp:
(WTR::TestController::generateContextConfiguration const):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):

2018-02-02 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] WebDriver: tests step always times out in the bot
@@ -411,7 +411,6 @@ WKRetainPtr<WKContextConfigurationRef> TestController::generateContextConfigurat
WKContextConfigurationSetApplicationCacheDirectory(configuration.get(), toWK(temporaryFolder + separator + "ApplicationCache").get());
WKContextConfigurationSetDiskCacheDirectory(configuration.get(), toWK(temporaryFolder + separator + "Cache").get());
WKContextConfigurationSetIndexedDBDatabaseDirectory(configuration.get(), toWK(temporaryFolder + separator + "Databases" + separator + "IndexedDB").get());
WKContextConfigurationSetServiceWorkerDatabaseDirectory(configuration.get(), toWK(temporaryFolder + separator + "ServiceWorkers").get());
WKContextConfigurationSetLocalStorageDirectory(configuration.get(), toWK(temporaryFolder + separator + "LocalStorage").get());
WKContextConfigurationSetWebSQLDatabaseDirectory(configuration.get(), toWK(temporaryFolder + separator + "Databases" + separator + "WebSQL").get());
WKContextConfigurationSetMediaKeysStorageDirectory(configuration.get(), toWK(temporaryFolder + separator + "MediaKeys").get());
@@ -83,6 +83,9 @@ void initializeWebViewConfiguration(const char* libraryPath, WKStringRef injecte
if (libraryPath) {
String cacheStorageDirectory = String(libraryPath) + '/' + "CacheStorage";
[poolWebsiteDataStore _setCacheStorageDirectory: cacheStorageDirectory];

String serviceWorkerRegistrationDirectory = String(libraryPath) + '/' + "ServiceWorkers";
[poolWebsiteDataStore _setServiceWorkerRegistrationDirectory: serviceWorkerRegistrationDirectory];
}

[globalWebViewConfiguration.websiteDataStore _setResourceLoadStatisticsEnabled:YES];

0 comments on commit cd71422

Please sign in to comment.