Diff
Modified: trunk/Source/WebCore/ChangeLog (232862 => 232863)
--- trunk/Source/WebCore/ChangeLog 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebCore/ChangeLog 2018-06-15 01:05:49 UTC (rev 232863)
@@ -1,3 +1,18 @@
+2018-06-14 Youenn Fablet <[email protected]>
+
+ Make NetworkProcess get cache storage parameters at creation of the CacheStorage engine
+ https://bugs.webkit.org/show_bug.cgi?id=186166
+
+ Reviewed by Alex Christensen.
+
+ Covered by existing tests.
+
+ * platform/network/NetworkStorageSession.h:
+ (WebCore::NetworkStorageSession::cacheStorageDirectory const): Deleted.
+ (WebCore::NetworkStorageSession::setCacheStorageDirectory): Deleted.
+ (WebCore::NetworkStorageSession::cacheStoragePerOriginQuota const): Deleted.
+ (WebCore::NetworkStorageSession::setCacheStoragePerOriginQuota): Deleted.
+
2018-06-14 Matt Lewis <[email protected]>
Unreviewed, rolling out r232823.
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (232862 => 232863)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -85,11 +85,6 @@
WEBCORE_EXPORT NSHTTPCookieStorage *nsCookieStorage() const;
#endif
- const String& cacheStorageDirectory() const { return m_cacheStorageDirectory; }
- void setCacheStorageDirectory(String&& path) { m_cacheStorageDirectory = WTFMove(path); }
- uint64_t cacheStoragePerOriginQuota() const { return m_cacheStoragePerOriginQuota; }
- void setCacheStoragePerOriginQuota(uint64_t quota) { m_cacheStoragePerOriginQuota = quota; }
-
#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
WEBCORE_EXPORT static void ensureSession(PAL::SessionID, const String& identifierBase, RetainPtr<CFHTTPCookieStorageRef>&&);
NetworkStorageSession(PAL::SessionID, RetainPtr<CFURLStorageSessionRef>&&, RetainPtr<CFHTTPCookieStorageRef>&&);
@@ -173,9 +168,6 @@
CredentialStorage m_credentialStorage;
- String m_cacheStorageDirectory;
- uint64_t m_cacheStoragePerOriginQuota { 0 };
-
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
bool shouldPartitionCookies(const String& topPrivatelyControlledDomain) const;
bool shouldBlockThirdPartyCookies(const String& topPrivatelyControlledDomain) const;
Modified: trunk/Source/WebKit/ChangeLog (232862 => 232863)
--- trunk/Source/WebKit/ChangeLog 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/ChangeLog 2018-06-15 01:05:49 UTC (rev 232863)
@@ -1,3 +1,92 @@
+2018-06-14 Youenn Fablet <[email protected]>
+
+ Make NetworkProcess get cache storage parameters at creation of the CacheStorage engine
+ https://bugs.webkit.org/show_bug.cgi?id=186166
+
+ Reviewed by Alex Christensen.
+
+ Make CacheStorage::Engine creation asynchronous.
+ Update Engine public methods be static methods taking a SessionID, which will be used to create the engine.
+
+ Add IPC methods to retrieve cache storage parameters from NetworkProcess to UIProcess.
+
+ Add NetworkProcessProxy ability to compute the cache storage parameters based on the SessionID.
+ For that purpose, make NetworkProcessProxy store a map of SessionID-to-WebsiteDataStore.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::deleteWebsiteData):
+ (WebKit::NetworkProcess::deleteWebsiteDataForOrigins):
+ (WebKit::NetworkProcess::cacheStorageParameters):
+ (WebKit::NetworkProcess::setCacheStorageParameters):
+ (WebKit::NetworkProcess::cacheStorageDirectory const): Deleted.
+ (WebKit::NetworkProcess::cacheStoragePerOriginQuota const): Deleted.
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * NetworkProcess/NetworkProcessCreationParameters.cpp:
+ (WebKit::NetworkProcessCreationParameters::encode const):
+ (WebKit::NetworkProcessCreationParameters::decode):
+ * NetworkProcess/NetworkProcessCreationParameters.h:
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::Engine::from):
+ (WebKit::CacheStorage::Engine::fetchEntries):
+ (WebKit::CacheStorage::Engine::open):
+ (WebKit::CacheStorage::Engine::remove):
+ (WebKit::CacheStorage::Engine::retrieveCaches):
+ (WebKit::CacheStorage::Engine::retrieveRecords):
+ (WebKit::CacheStorage::Engine::putRecords):
+ (WebKit::CacheStorage::Engine::deleteMatchingRecords):
+ (WebKit::CacheStorage::Engine::lock):
+ (WebKit::CacheStorage::Engine::unlock):
+ (WebKit::CacheStorage::Engine::clearMemoryRepresentation):
+ (WebKit::CacheStorage::Engine::representation):
+ (WebKit::CacheStorage::Engine::clearAllCaches):
+ (WebKit::CacheStorage::Engine::clearCachesForOrigin):
+ (WebKit::CacheStorage::Engine::Engine):
+ (WebKit::CacheStorage::Engine::readCachesFromDisk):
+ (WebKit::CacheStorage::Engine::defaultEngine): Deleted.
+ * NetworkProcess/cache/CacheStorageEngine.h:
+ (WebKit::CacheStorage::Engine::shouldPersist const):
+ (WebKit::CacheStorage::Engine::weakPtrFactory):
+ (WebKit::CacheStorage::Engine::create): Deleted.
+ * NetworkProcess/cache/CacheStorageEngineConnection.cpp:
+ (WebKit::CacheStorageEngineConnection::~CacheStorageEngineConnection):
+ (WebKit::CacheStorageEngineConnection::open):
+ (WebKit::CacheStorageEngineConnection::remove):
+ (WebKit::CacheStorageEngineConnection::caches):
+ (WebKit::CacheStorageEngineConnection::retrieveRecords):
+ (WebKit::CacheStorageEngineConnection::deleteMatchingRecords):
+ (WebKit::CacheStorageEngineConnection::putRecords):
+ (WebKit::CacheStorageEngineConnection::reference):
+ (WebKit::CacheStorageEngineConnection::dereference):
+ (WebKit::CacheStorageEngineConnection::clearMemoryRepresentation):
+ (WebKit::CacheStorageEngineConnection::engineRepresentation):
+ * NetworkProcess/cache/CacheStorageEngineConnection.h:
+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+ (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+ * NetworkProcess/mac/RemoteNetworkingContext.mm:
+ (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
+ * Shared/WebsiteDataStoreParameters.cpp:
+ (WebKit::WebsiteDataStoreParameters::encode const):
+ (WebKit::WebsiteDataStoreParameters::decode):
+ (WebKit::WebsiteDataStoreParameters::privateSessionParameters):
+ * Shared/WebsiteDataStoreParameters.h:
+ (): Deleted.
+ * UIProcess/Network/NetworkProcessProxy.cpp:
+ (WebKit::NetworkProcessProxy::addSession):
+ (WebKit::NetworkProcessProxy::removeSession):
+ (WebKit::NetworkProcessProxy::retrieveCacheStorageParameters):
+ * UIProcess/Network/NetworkProcessProxy.h:
+ * UIProcess/Network/NetworkProcessProxy.messages.in:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::ensureNetworkProcess):
+ (WebKit::WebProcessPool::setAnyPageGroupMightHavePrivateBrowsingEnabled):
+ (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
+ (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::parameters):
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::~WebsiteDataStore):
+
2018-06-14 Basuke Suzuki <[email protected]>
[Win] Add IPC error case for broken pipe
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -132,6 +132,10 @@
NetworkProcess::~NetworkProcess()
{
+ for (auto& callbacks : m_cacheStorageParametersCallbacks.values()) {
+ for (auto& callback : callbacks)
+ callback(String { }, 0);
+ }
}
AuthenticationManager& NetworkProcess::authenticationManager()
@@ -563,7 +567,7 @@
});
if (websiteDataTypes.contains(WebsiteDataType::DOMCache))
- CacheStorage::Engine::from(sessionID).clearAllCaches(clearTasksHandler);
+ CacheStorage::Engine::clearAllCaches(sessionID, clearTasksHandler.copyRef());
if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral())
clearDiskCache(modifiedSince, [clearTasksHandler = WTFMove(clearTasksHandler)] { });
@@ -607,7 +611,7 @@
if (websiteDataTypes.contains(WebsiteDataType::DOMCache)) {
for (auto& originData : originDatas)
- CacheStorage::Engine::from(sessionID).clearCachesForOrigin(originData, clearTasksHandler);
+ CacheStorage::Engine::clearCachesForOrigin(sessionID, SecurityOriginData { originData }, clearTasksHandler.copyRef());
}
if (websiteDataTypes.contains(WebsiteDataType::DiskCache) && !sessionID.isEphemeral())
@@ -848,19 +852,25 @@
WebCore::prefetchDNS(hostname);
}
-String NetworkProcess::cacheStorageDirectory(PAL::SessionID sessionID) const
+void NetworkProcess::cacheStorageParameters(PAL::SessionID sessionID, CacheStorageParametersCallback&& callback)
{
- if (sessionID.isEphemeral())
- return { };
+ m_cacheStorageParametersCallbacks.ensure(sessionID, [&] {
+ parentProcessConnection()->send(Messages::NetworkProcessProxy::RetrieveCacheStorageParameters { sessionID }, 0);
+ return Vector<CacheStorageParametersCallback> { };
+ }).iterator->value.append(WTFMove(callback));
+}
- if (sessionID == PAL::SessionID::defaultSessionID())
- return m_cacheStorageDirectory;
+void NetworkProcess::setCacheStorageParameters(PAL::SessionID sessionID, uint64_t quota, String&& cacheStorageDirectory, SandboxExtension::Handle&& handle)
+{
+ auto iterator = m_cacheStorageParametersCallbacks.find(sessionID);
+ if (iterator == m_cacheStorageParametersCallbacks.end())
+ return;
- auto* session = NetworkStorageSession::storageSession(sessionID);
- if (!session)
- return { };
-
- return session->cacheStorageDirectory();
+ SandboxExtension::consumePermanently(handle);
+ auto callbacks = WTFMove(iterator->value);
+ m_cacheStorageParametersCallbacks.remove(iterator);
+ for (auto& callback : callbacks)
+ callback(String { cacheStorageDirectory }, quota);
}
void NetworkProcess::preconnectTo(const WebCore::URL& url, WebCore::StoredCredentialsPolicy storedCredentialsPolicy)
@@ -879,11 +889,6 @@
#endif
}
-uint64_t NetworkProcess::cacheStoragePerOriginQuota() const
-{
- return m_cacheStoragePerOriginQuota;
-}
-
void NetworkProcess::registerURLSchemeAsSecure(const String& scheme) const
{
SchemeRegistry::registerURLSchemeAsSecure(scheme);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -143,9 +143,10 @@
#endif
Seconds loadThrottleLatency() const { return m_loadThrottleLatency; }
- String cacheStorageDirectory(PAL::SessionID) const;
- uint64_t cacheStoragePerOriginQuota() const;
+ using CacheStorageParametersCallback = CompletionHandler<void(const String&, uint64_t quota)>;
+ void cacheStorageParameters(PAL::SessionID, CacheStorageParametersCallback&&);
+
void preconnectTo(const WebCore::URL&, WebCore::StoredCredentialsPolicy);
#if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED
@@ -206,6 +207,8 @@
void clearCachedCredentials();
+ void setCacheStorageParameters(PAL::SessionID, uint64_t quota, String&& cacheStorageDirectory, SandboxExtension::Handle&&);
+
// FIXME: This should take a session ID so we can identify which disk cache to delete.
void clearDiskCache(WallTime modifiedSince, Function<void ()>&& completionHandler);
@@ -253,8 +256,6 @@
// Connections to WebProcesses.
Vector<RefPtr<NetworkConnectionToWebProcess>> m_webProcessConnections;
- String m_cacheStorageDirectory;
- uint64_t m_cacheStoragePerOriginQuota { 0 };
String m_diskCacheDirectory;
bool m_hasSetCacheModel;
CacheModel m_cacheModel;
@@ -279,6 +280,8 @@
#endif
HashSet<PAL::SessionID> m_sessionsControlledByAutomation;
+ HashMap<PAL::SessionID, Vector<CacheStorageParametersCallback>> m_cacheStorageParametersCallbacks;
+
#if PLATFORM(COCOA)
void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);
void setCookieStoragePartitioningEnabled(bool);
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in 2018-06-15 01:05:49 UTC (rev 232863)
@@ -98,4 +98,6 @@
RegisterURLSchemeAsDisplayIsolated(String scheme)
RegisterURLSchemeAsCORSEnabled(String scheme)
RegisterURLSchemeAsCanDisplayOnlyIfCanRequest(String scheme)
+
+ SetCacheStorageParameters(PAL::SessionID sessionID, uint64_t quota, String cacheStorageDirectory, WebKit::SandboxExtension::Handle handle);
}
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -46,9 +46,6 @@
encoder.encodeEnum(cacheModel);
encoder << diskCacheSizeOverride;
encoder << canHandleHTTPSServerTrustEvaluation;
- encoder << cacheStorageDirectory;
- encoder << cacheStoragePerOriginQuota;
- encoder << cacheStorageDirectoryExtensionHandle;
encoder << diskCacheDirectory;
encoder << diskCacheDirectoryExtensionHandle;
encoder << shouldEnableNetworkCacheEfficacyLogging;
@@ -130,16 +127,6 @@
return false;
if (!decoder.decode(result.canHandleHTTPSServerTrustEvaluation))
return false;
- if (!decoder.decode(result.cacheStorageDirectory))
- return false;
- if (!decoder.decode(result.cacheStoragePerOriginQuota))
- return false;
-
- std::optional<SandboxExtension::Handle> cacheStorageDirectoryExtensionHandle;
- decoder >> cacheStorageDirectoryExtensionHandle;
- if (!cacheStorageDirectoryExtensionHandle)
- return false;
- result.cacheStorageDirectoryExtensionHandle = WTFMove(*cacheStorageDirectoryExtensionHandle);
if (!decoder.decode(result.diskCacheDirectory))
return false;
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -56,9 +56,6 @@
int64_t diskCacheSizeOverride { -1 };
bool canHandleHTTPSServerTrustEvaluation { true };
- String cacheStorageDirectory;
- uint64_t cacheStoragePerOriginQuota;
- SandboxExtension::Handle cacheStorageDirectoryExtensionHandle;
String diskCacheDirectory;
SandboxExtension::Handle diskCacheDirectoryExtensionHandle;
bool shouldEnableNetworkCacheEfficacyLogging { false };
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -80,12 +80,23 @@
callback(Data { }, 1);
}
-Engine& Engine::from(PAL::SessionID sessionID)
+void Engine::from(PAL::SessionID sessionID, Function<void(Engine&)>&& callback)
{
- auto addResult = globalEngineMap().add(sessionID, nullptr);
- if (addResult.isNewEntry)
- addResult.iterator->value = Engine::create(NetworkProcess::singleton().cacheStorageDirectory(sessionID));
- return *addResult.iterator->value;
+ auto iterator = globalEngineMap().find(sessionID);
+ if (iterator != globalEngineMap().end()) {
+ callback(*iterator->value);
+ return;
+ }
+
+ if (sessionID.isEphemeral())
+ sessionID = PAL::SessionID::legacyPrivateSessionID();
+
+ NetworkProcess::singleton().cacheStorageParameters(sessionID, [sessionID, callback = WTFMove(callback)](auto&& rootPath, auto quota) {
+ auto addResult = globalEngineMap().add(sessionID, nullptr);
+ if (addResult.isNewEntry)
+ addResult.iterator->value = adoptRef(*new Engine { String { rootPath }, quota });
+ callback(*addResult.iterator->value);
+ });
}
void Engine::destroyEngine(PAL::SessionID sessionID)
@@ -94,20 +105,101 @@
globalEngineMap().remove(sessionID);
}
-void Engine::fetchEntries(PAL::SessionID sessionID, bool shouldComputeSize, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler)
+void Engine::fetchEntries(PAL::SessionID sessionID, bool shouldComputeSize, CompletionHandler<void(Vector<WebsiteData::Entry>)>&& completionHandler)
{
- from(sessionID).fetchEntries(shouldComputeSize, WTFMove(completionHandler));
+ from(sessionID, [shouldComputeSize, completionHandler = WTFMove(completionHandler)] (auto& engine) mutable {
+ engine.fetchEntries(shouldComputeSize, WTFMove(completionHandler));
+ });
}
-Engine& Engine::defaultEngine()
+void Engine::open(PAL::SessionID sessionID, WebCore::ClientOrigin&& origin, String&& cacheName, WebCore::DOMCacheEngine::CacheIdentifierCallback&& callback)
{
- auto sessionID = PAL::SessionID::defaultSessionID();
- static NeverDestroyed<Ref<Engine>> defaultEngine = { Engine::create(NetworkProcess::singleton().cacheStorageDirectory(sessionID)) };
- return defaultEngine.get();
+ from(sessionID, [origin = WTFMove(origin), cacheName = WTFMove(cacheName), callback = WTFMove(callback)](auto& engine) mutable {
+ engine.open(origin, cacheName, WTFMove(callback));
+ });
}
-Engine::Engine(String&& rootPath)
+void Engine::remove(PAL::SessionID sessionID, uint64_t cacheIdentifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&& callback)
+{
+ from(sessionID, [cacheIdentifier, callback = WTFMove(callback)](auto& engine) mutable {
+ engine.remove(cacheIdentifier, WTFMove(callback));
+ });
+}
+
+void Engine::retrieveCaches(PAL::SessionID sessionID, WebCore::ClientOrigin&& origin, uint64_t updateCounter, WebCore::DOMCacheEngine::CacheInfosCallback&& callback)
+{
+ from(sessionID, [origin = WTFMove(origin), updateCounter, callback = WTFMove(callback)](auto& engine) mutable {
+ engine.retrieveCaches(origin, updateCounter, WTFMove(callback));
+ });
+}
+
+
+void Engine::retrieveRecords(PAL::SessionID sessionID, uint64_t cacheIdentifier, WebCore::URL&& url, WebCore::DOMCacheEngine::RecordsCallback&& callback)
+{
+ from(sessionID, [cacheIdentifier, url = "" callback = WTFMove(callback)](auto& engine) mutable {
+ engine.retrieveRecords(cacheIdentifier, WTFMove(url), WTFMove(callback));
+ });
+}
+
+void Engine::putRecords(PAL::SessionID sessionID, uint64_t cacheIdentifier, Vector<WebCore::DOMCacheEngine::Record>&& records, WebCore::DOMCacheEngine::RecordIdentifiersCallback&& callback)
+{
+ from(sessionID, [cacheIdentifier, records = WTFMove(records), callback = WTFMove(callback)](auto& engine) mutable {
+ engine.putRecords(cacheIdentifier, WTFMove(records), WTFMove(callback));
+ });
+}
+
+void Engine::deleteMatchingRecords(PAL::SessionID sessionID, uint64_t cacheIdentifier, WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options, WebCore::DOMCacheEngine::RecordIdentifiersCallback&& callback)
+{
+ from(sessionID, [cacheIdentifier, request = WTFMove(request), options = WTFMove(options), callback = WTFMove(callback)](auto& engine) mutable {
+ engine.deleteMatchingRecords(cacheIdentifier, WTFMove(request), WTFMove(options), WTFMove(callback));
+ });
+}
+
+void Engine::lock(PAL::SessionID sessionID, uint64_t cacheIdentifier)
+{
+ from(sessionID, [cacheIdentifier](auto& engine) mutable {
+ engine.lock(cacheIdentifier);
+ });
+}
+
+void Engine::unlock(PAL::SessionID sessionID, uint64_t cacheIdentifier)
+{
+ from(sessionID, [cacheIdentifier](auto& engine) mutable {
+ engine.unlock(cacheIdentifier);
+ });
+}
+
+void Engine::clearMemoryRepresentation(PAL::SessionID sessionID, WebCore::ClientOrigin&& origin, WebCore::DOMCacheEngine::CompletionCallback&& callback)
+{
+ from(sessionID, [origin = WTFMove(origin), callback = WTFMove(callback)](auto& engine) mutable {
+ engine.clearMemoryRepresentation(origin, WTFMove(callback));
+ });
+}
+
+void Engine::representation(PAL::SessionID sessionID, CompletionHandler<void(String&&)>&& callback)
+{
+ from(sessionID, [callback = WTFMove(callback)](auto& engine) mutable {
+ callback(engine.representation());
+ });
+}
+
+void Engine::clearAllCaches(PAL::SessionID sessionID, Ref<WTF::CallbackAggregator>&& aggregator)
+{
+ from(sessionID, [aggregator = WTFMove(aggregator)](auto& engine) mutable {
+ engine.clearAllCaches(aggregator);
+ });
+}
+
+void Engine::clearCachesForOrigin(PAL::SessionID sessionID, WebCore::SecurityOriginData&& originData, Ref<WTF::CallbackAggregator>&& aggregator)
+{
+ from(sessionID, [originData = WTFMove(originData), aggregator = WTFMove(aggregator)](auto& engine) mutable {
+ engine.clearCachesForOrigin(originData, aggregator);
+ });
+}
+
+Engine::Engine(String&& rootPath, uint64_t quota)
: m_rootPath(WTFMove(rootPath))
+ , m_quota(quota)
{
if (!m_rootPath.isNull())
m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background);
@@ -229,7 +321,7 @@
initialize([this, origin, callback = WTFMove(callback)](std::optional<Error>&& error) mutable {
auto& caches = m_caches.ensure(origin, [&origin, this] {
auto path = cachesRootPath(origin);
- return Caches::create(*this, WebCore::ClientOrigin { origin }, WTFMove(path), NetworkProcess::singleton().cacheStoragePerOriginQuota());
+ return Caches::create(*this, WebCore::ClientOrigin { origin }, WTFMove(path), m_quota);
}).iterator->value;
if (caches->isInitialized()) {
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -57,25 +57,29 @@
public:
~Engine();
- static Engine& from(PAL::SessionID);
+ static void from(PAL::SessionID, Function<void(Engine&)>&&);
static void destroyEngine(PAL::SessionID);
static void fetchEntries(PAL::SessionID, bool shouldComputeSize, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&&);
- static Ref<Engine> create(String&& rootPath) { return adoptRef(*new Engine(WTFMove(rootPath))); }
+ static void open(PAL::SessionID, WebCore::ClientOrigin&&, String&& cacheName, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
+ static void remove(PAL::SessionID, uint64_t cacheIdentifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
+ static void retrieveCaches(PAL::SessionID, WebCore::ClientOrigin&&, uint64_t updateCounter, WebCore::DOMCacheEngine::CacheInfosCallback&&);
- bool shouldPersist() const { return !!m_ioQueue;}
+ static void retrieveRecords(PAL::SessionID, uint64_t cacheIdentifier, WebCore::URL&&, WebCore::DOMCacheEngine::RecordsCallback&&);
+ static void putRecords(PAL::SessionID, uint64_t cacheIdentifier, Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
+ static void deleteMatchingRecords(PAL::SessionID, uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
- void open(const WebCore::ClientOrigin&, const String& cacheName, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
- void remove(uint64_t cacheIdentifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
- void retrieveCaches(const WebCore::ClientOrigin&, uint64_t updateCounter, WebCore::DOMCacheEngine::CacheInfosCallback&&);
+ static void lock(PAL::SessionID, uint64_t cacheIdentifier);
+ static void unlock(PAL::SessionID, uint64_t cacheIdentifier);
- void retrieveRecords(uint64_t cacheIdentifier, WebCore::URL&&, WebCore::DOMCacheEngine::RecordsCallback&&);
- void putRecords(uint64_t cacheIdentifier, Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
- void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
+ static void clearMemoryRepresentation(PAL::SessionID, WebCore::ClientOrigin&&, WebCore::DOMCacheEngine::CompletionCallback&&);
+ static void representation(PAL::SessionID, CompletionHandler<void(String&&)>&&);
- void lock(uint64_t cacheIdentifier);
- void unlock(uint64_t cacheIdentifier);
+ static void clearAllCaches(PAL::SessionID, Ref<WTF::CallbackAggregator>&&);
+ static void clearCachesForOrigin(PAL::SessionID, WebCore::SecurityOriginData&&, Ref<WTF::CallbackAggregator>&&);
+ bool shouldPersist() const { return !!m_ioQueue;}
+
void writeFile(const String& filename, NetworkCache::Data&&, WebCore::DOMCacheEngine::CompletionCallback&&);
void readFile(const String& filename, CompletionHandler<void(const NetworkCache::Data&, int error)>&&);
void removeFile(const String& filename);
@@ -84,16 +88,26 @@
const NetworkCache::Salt& salt() const { return m_salt.value(); }
uint64_t nextCacheIdentifier() { return ++m_nextCacheIdentifier; }
- void clearMemoryRepresentation(const WebCore::ClientOrigin&, WebCore::DOMCacheEngine::CompletionCallback&&);
- String representation();
+private:
+ Engine(String&& rootPath, uint64_t quota);
+ void open(const WebCore::ClientOrigin&, const String& cacheName, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
+ void remove(uint64_t cacheIdentifier, WebCore::DOMCacheEngine::CacheIdentifierCallback&&);
+ void retrieveCaches(const WebCore::ClientOrigin&, uint64_t updateCounter, WebCore::DOMCacheEngine::CacheInfosCallback&&);
+
void clearAllCaches(WTF::CallbackAggregator&);
void clearCachesForOrigin(const WebCore::SecurityOriginData&, WTF::CallbackAggregator&);
-private:
- static Engine& defaultEngine();
- explicit Engine(String&& rootPath);
+ void clearMemoryRepresentation(const WebCore::ClientOrigin&, WebCore::DOMCacheEngine::CompletionCallback&&);
+ String representation();
+ void retrieveRecords(uint64_t cacheIdentifier, WebCore::URL&&, WebCore::DOMCacheEngine::RecordsCallback&&);
+ void putRecords(uint64_t cacheIdentifier, Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
+ void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
+
+ void lock(uint64_t cacheIdentifier);
+ void unlock(uint64_t cacheIdentifier);
+
String cachesRootPath(const WebCore::ClientOrigin&);
void fetchEntries(bool /* shouldComputeSize */, WTF::CompletionHandler<void(Vector<WebsiteData::Entry>)>&&);
@@ -113,6 +127,7 @@
HashMap<WebCore::ClientOrigin, RefPtr<Caches>> m_caches;
uint64_t m_nextCacheIdentifier { 0 };
String m_rootPath;
+ uint64_t m_quota { 0 };
RefPtr<WorkQueue> m_ioQueue;
std::optional<NetworkCache::Salt> m_salt;
HashMap<CacheIdentifier, LockCount> m_cacheLocks;
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -58,15 +58,15 @@
auto& sessionID = keyValue.key;
for (auto& references : keyValue.value) {
ASSERT(references.value);
- Engine::from(sessionID).unlock(references.key);
+ Engine::unlock(sessionID, references.key);
}
}
}
-void CacheStorageEngineConnection::open(PAL::SessionID sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin, const String& cacheName)
+void CacheStorageEngineConnection::open(PAL::SessionID sessionID, uint64_t requestIdentifier, WebCore::ClientOrigin&& origin, String&& cacheName)
{
RELEASE_LOG_IF_ALLOWED("open (%" PRIu64 ")", requestIdentifier);
- Engine::from(sessionID).open(origin, cacheName, [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
+ Engine::open(sessionID, WTFMove(origin), WTFMove(cacheName), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("open", "cache identifier is %" PRIu64, [](const auto& value) { return value.identifier; });
connection->send(Messages::WebCacheStorageConnection::OpenCompleted(requestIdentifier, result), sessionID.sessionID());
});
@@ -75,16 +75,16 @@
void CacheStorageEngineConnection::remove(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier)
{
RELEASE_LOG_IF_ALLOWED("remove (%" PRIu64 ") cache %" PRIu64, requestIdentifier, cacheIdentifier);
- Engine::from(sessionID).remove(cacheIdentifier, [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
+ Engine::remove(sessionID, cacheIdentifier, [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("remove", "removed cache %" PRIu64, [](const auto& value) { return value.identifier; });
connection->send(Messages::WebCacheStorageConnection::RemoveCompleted(requestIdentifier, result), sessionID.sessionID());
});
}
-void CacheStorageEngineConnection::caches(PAL::SessionID sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin, uint64_t updateCounter)
+void CacheStorageEngineConnection::caches(PAL::SessionID sessionID, uint64_t requestIdentifier, WebCore::ClientOrigin&& origin, uint64_t updateCounter)
{
RELEASE_LOG_IF_ALLOWED("caches (%" PRIu64 ")", requestIdentifier);
- Engine::from(sessionID).retrieveCaches(origin, updateCounter, [connection = makeRef(m_connection.connection()), sessionID, origin, requestIdentifier](CacheInfosOrError&& result) {
+ Engine::retrieveCaches(sessionID, WTFMove(origin), updateCounter, [connection = makeRef(m_connection.connection()), sessionID, origin, requestIdentifier](CacheInfosOrError&& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("caches", "caches size is %lu", [](const auto& value) { return value.infos.size(); });
connection->send(Messages::WebCacheStorageConnection::UpdateCaches(requestIdentifier, result), sessionID.sessionID());
});
@@ -93,7 +93,7 @@
void CacheStorageEngineConnection::retrieveRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::URL&& url)
{
RELEASE_LOG_IF_ALLOWED("retrieveRecords (%" PRIu64 ") in cache %" PRIu64, requestIdentifier, cacheIdentifier);
- Engine::from(sessionID).retrieveRecords(cacheIdentifier, WTFMove(url), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordsOrError&& result) {
+ Engine::retrieveRecords(sessionID, cacheIdentifier, WTFMove(url), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordsOrError&& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("retrieveRecords", "records size is %lu", [](const auto& value) { return value.size(); });
connection->send(Messages::WebCacheStorageConnection::UpdateRecords(requestIdentifier, result), sessionID.sessionID());
});
@@ -102,7 +102,7 @@
void CacheStorageEngineConnection::deleteMatchingRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options)
{
RELEASE_LOG_IF_ALLOWED("deleteMatchingRecords (%" PRIu64 ") in cache %" PRIu64, requestIdentifier, cacheIdentifier);
- Engine::from(sessionID).deleteMatchingRecords(cacheIdentifier, WTFMove(request), WTFMove(options), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
+ Engine::deleteMatchingRecords(sessionID, cacheIdentifier, WTFMove(request), WTFMove(options), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("deleteMatchingRecords", "deleted %lu records", [](const auto& value) { return value.size(); });
connection->send(Messages::WebCacheStorageConnection::DeleteRecordsCompleted(requestIdentifier, result), sessionID.sessionID());
});
@@ -111,7 +111,7 @@
void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
{
RELEASE_LOG_IF_ALLOWED("putRecords (%" PRIu64 ") in cache %" PRIu64 ", %lu records", requestIdentifier, cacheIdentifier, records.size());
- Engine::from(sessionID).putRecords(cacheIdentifier, WTFMove(records), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
+ Engine::putRecords(sessionID, cacheIdentifier, WTFMove(records), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
RELEASE_LOG_FUNCTION_IF_ALLOWED_IN_CALLBACK("putRecords", "put %lu records", [](const auto& value) { return value.size(); });
connection->send(Messages::WebCacheStorageConnection::PutRecordsCompleted(requestIdentifier, result), sessionID.sessionID());
});
@@ -127,7 +127,7 @@
return 0;
}).iterator->value;
if (!counter++)
- Engine::from(sessionID).lock(cacheIdentifier);
+ Engine::lock(sessionID, cacheIdentifier);
}
void CacheStorageEngineConnection::dereference(PAL::SessionID sessionID, uint64_t cacheIdentifier)
@@ -147,13 +147,13 @@
if (--referenceResult->value)
return;
- Engine::from(sessionID).unlock(cacheIdentifier);
+ Engine::unlock(sessionID, cacheIdentifier);
references.remove(referenceResult);
}
-void CacheStorageEngineConnection::clearMemoryRepresentation(PAL::SessionID sessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin& origin)
+void CacheStorageEngineConnection::clearMemoryRepresentation(PAL::SessionID sessionID, uint64_t requestIdentifier, WebCore::ClientOrigin&& origin)
{
- Engine::from(sessionID).clearMemoryRepresentation(origin, [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier] (std::optional<Error>&& error) {
+ Engine::clearMemoryRepresentation(sessionID, WTFMove(origin), [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier] (std::optional<Error>&& error) {
connection->send(Messages::WebCacheStorageConnection::ClearMemoryRepresentationCompleted(requestIdentifier, error), sessionID.sessionID());
});
}
@@ -160,7 +160,9 @@
void CacheStorageEngineConnection::engineRepresentation(PAL::SessionID sessionID, uint64_t requestIdentifier)
{
- m_connection.connection().send(Messages::WebCacheStorageConnection::EngineRepresentationCompleted(requestIdentifier, Engine::from(sessionID).representation()), sessionID.sessionID());
+ Engine::representation(sessionID, [connection = makeRef(m_connection.connection()), sessionID, requestIdentifier] (auto&& representation) {
+ connection->send(Messages::WebCacheStorageConnection::EngineRepresentationCompleted { requestIdentifier, representation }, sessionID.sessionID());
+ });
}
}
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -50,9 +50,9 @@
private:
explicit CacheStorageEngineConnection(NetworkConnectionToWebProcess&);
- void open(PAL::SessionID, uint64_t openRequestIdentifier, const WebCore::ClientOrigin&, const String& cacheName);
+ void open(PAL::SessionID, uint64_t openRequestIdentifier, WebCore::ClientOrigin&&, String&& cacheName);
void remove(PAL::SessionID, uint64_t removeRequestIdentifier, uint64_t cacheIdentifier);
- void caches(PAL::SessionID, uint64_t retrieveCachesIdentifier, const WebCore::ClientOrigin&, uint64_t updateCounter);
+ void caches(PAL::SessionID, uint64_t retrieveCachesIdentifier, WebCore::ClientOrigin&&, uint64_t updateCounter);
void retrieveRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::URL&&);
void deleteMatchingRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&);
@@ -61,7 +61,7 @@
void reference(PAL::SessionID, uint64_t cacheIdentifier);
void dereference(PAL::SessionID, uint64_t cacheIdentifier);
- void clearMemoryRepresentation(PAL::SessionID, uint64_t requestIdentifier, const WebCore::ClientOrigin&);
+ void clearMemoryRepresentation(PAL::SessionID, uint64_t requestIdentifier, WebCore::ClientOrigin&&);
void engineRepresentation(PAL::SessionID, uint64_t requestIdentifier);
NetworkConnectionToWebProcess& m_connection;
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2018-06-15 01:05:49 UTC (rev 232863)
@@ -110,12 +110,6 @@
ASSERT(!m_diskCacheIsDisabledForTesting);
- if (!parameters.cacheStorageDirectory.isNull()) {
- m_cacheStorageDirectory = parameters.cacheStorageDirectory;
- m_cacheStoragePerOriginQuota = parameters.cacheStoragePerOriginQuota;
- SandboxExtension::consumePermanently(parameters.cacheStorageDirectoryExtensionHandle);
- }
-
#if ENABLE(WIFI_ASSERTIONS)
initializeWiFiAssertions(parameters);
#endif
Modified: trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm (232862 => 232863)
--- trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm 2018-06-15 01:05:49 UTC (rev 232863)
@@ -72,12 +72,6 @@
for (const auto& cookie : parameters.pendingCookies)
session->setCookie(cookie);
- if (!sessionID.isEphemeral() && !parameters.cacheStorageDirectory.isNull()) {
- SandboxExtension::consumePermanently(parameters.cacheStorageDirectoryExtensionHandle);
- session->setCacheStorageDirectory(WTFMove(parameters.cacheStorageDirectory));
- session->setCacheStoragePerOriginQuota(parameters.cacheStoragePerOriginQuota);
- }
-
SessionTracker::setSession(sessionID, NetworkSession::create(WTFMove(parameters.networkSessionParameters)));
}
Modified: trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp (232862 => 232863)
--- trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -41,9 +41,6 @@
encoder << uiProcessCookieStorageIdentifier;
encoder << cookieStoragePathExtensionHandle;
encoder << pendingCookies;
- encoder << cacheStorageDirectory;
- encoder << cacheStoragePerOriginQuota;
- encoder << cacheStorageDirectoryExtensionHandle;
}
std::optional<WebsiteDataStoreParameters> WebsiteDataStoreParameters::decode(IPC::Decoder& decoder)
@@ -67,29 +64,13 @@
decoder >> pendingCookies;
if (!pendingCookies)
return std::nullopt;
-
- std::optional<String> cacheStorageDirectory;
- decoder >> cacheStorageDirectory;
- if (!cacheStorageDirectory)
- return std::nullopt;
-
- std::optional<uint64_t> cacheStoragePerOriginQuota;
- decoder >> cacheStoragePerOriginQuota;
- if (!cacheStoragePerOriginQuota)
- return std::nullopt;
-
- std::optional<SandboxExtension::Handle> cacheStorageDirectoryExtensionHandle;
- decoder >> cacheStorageDirectoryExtensionHandle;
- if (!cacheStorageDirectoryExtensionHandle)
- return std::nullopt;
-
- return {{ WTFMove(*uiProcessCookieStorageIdentifier), WTFMove(*cookieStoragePathExtensionHandle), WTFMove(*pendingCookies), WTFMove(*cacheStorageDirectory), WTFMove(*cacheStoragePerOriginQuota), WTFMove(*cacheStorageDirectoryExtensionHandle), WTFMove(*networkSessionParameters)}};
+ return {{ WTFMove(*uiProcessCookieStorageIdentifier), WTFMove(*cookieStoragePathExtensionHandle), WTFMove(*pendingCookies), WTFMove(*networkSessionParameters)}};
}
WebsiteDataStoreParameters WebsiteDataStoreParameters::privateSessionParameters(PAL::SessionID sessionID)
{
ASSERT(sessionID.isEphemeral());
- return { { }, { }, { }, { }, WebsiteDataStore::defaultCacheStoragePerOriginQuota, { }, { sessionID, { }, AllowsCellularAccess::Yes
+ return { { }, { }, { }, { sessionID, { }, AllowsCellularAccess::Yes
#if PLATFORM(COCOA)
, nullptr
#endif
Modified: trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h (232862 => 232863)
--- trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -54,9 +54,6 @@
Vector<uint8_t> uiProcessCookieStorageIdentifier;
SandboxExtension::Handle cookieStoragePathExtensionHandle;
Vector<WebCore::Cookie> pendingCookies;
- String cacheStorageDirectory;
- uint64_t cacheStoragePerOriginQuota { 0 };
- SandboxExtension::Handle cacheStorageDirectoryExtensionHandle;
NetworkSessionCreationParameters networkSessionParameters;
};
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -574,6 +574,41 @@
}
}
+void NetworkProcessProxy::addSession(Ref<WebsiteDataStore>&& store)
+{
+ if (canSendMessage())
+ send(Messages::NetworkProcess::AddWebsiteDataStore { store->parameters() }, 0);
+ auto sessionID = store->sessionID();
+ if (!sessionID.isEphemeral())
+ m_websiteDataStores.set(sessionID, WTFMove(store));
+}
+
+void NetworkProcessProxy::removeSession(PAL::SessionID sessionID)
+{
+ if (canSendMessage())
+ send(Messages::NetworkProcess::DestroySession { sessionID }, 0);
+ if (!sessionID.isEphemeral())
+ m_websiteDataStores.remove(sessionID);
+}
+
+void NetworkProcessProxy::retrieveCacheStorageParameters(PAL::SessionID sessionID)
+{
+ auto iterator = m_websiteDataStores.find(sessionID);
+ if (iterator == m_websiteDataStores.end()) {
+ auto quota = m_processPool.websiteDataStore() ? m_processPool.websiteDataStore()->websiteDataStore().cacheStoragePerOriginQuota() : WebsiteDataStore::defaultCacheStoragePerOriginQuota;
+ send(Messages::NetworkProcess::SetCacheStorageParameters { sessionID, quota, { }, { } }, 0);
+ return;
+ }
+
+ auto& store = *iterator->value;
+ auto& cacheStorageDirectory = store.cacheStorageDirectory();
+ SandboxExtension::Handle cacheStorageDirectoryExtensionHandle;
+ if (!cacheStorageDirectory.isEmpty())
+ SandboxExtension::createHandleForReadWriteDirectory(cacheStorageDirectory, cacheStorageDirectoryExtensionHandle);
+
+ send(Messages::NetworkProcess::SetCacheStorageParameters { sessionID, store.cacheStoragePerOriginQuota(), cacheStorageDirectory, cacheStorageDirectoryExtensionHandle }, 0);
+}
+
#if ENABLE(CONTENT_EXTENSIONS)
void NetworkProcessProxy::contentExtensionRules(UserContentControllerIdentifier identifier)
{
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h 2018-06-15 01:05:49 UTC (rev 232863)
@@ -26,6 +26,7 @@
#ifndef NetworkProcessProxy_h
#define NetworkProcessProxy_h
+#include "APIWebsiteDataStore.h"
#include "ChildProcessProxy.h"
#if ENABLE(LEGACY_CUSTOM_PROTOCOL_MANAGER)
#include "LegacyCustomProtocolManagerProxy.h"
@@ -99,6 +100,9 @@
void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
#endif
+ void addSession(Ref<WebsiteDataStore>&&);
+ void removeSession(PAL::SessionID);
+
private:
NetworkProcessProxy(WebProcessPool&);
@@ -143,6 +147,7 @@
void storageAccessRequestResult(bool wasGranted, uint64_t contextId);
void allStorageAccessEntriesResult(Vector<String>&& domains, uint64_t contextId);
#endif
+ void retrieveCacheStorageParameters(PAL::SessionID);
#if ENABLE(CONTENT_EXTENSIONS)
void contentExtensionRules(UserContentControllerIdentifier);
@@ -177,6 +182,8 @@
#if ENABLE(CONTENT_EXTENSIONS)
HashSet<WebUserContentControllerProxy*> m_webUserContentControllerProxies;
#endif
+
+ HashMap<PAL::SessionID, RefPtr<WebsiteDataStore>> m_websiteDataStores;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in 2018-06-15 01:05:49 UTC (rev 232863)
@@ -53,4 +53,6 @@
#if ENABLE(CONTENT_EXTENSIONS)
ContentExtensionRules(WebKit::UserContentControllerIdentifier identifier)
#endif
+
+ RetrieveCacheStorageParameters(PAL::SessionID sessionID)
}
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -448,15 +448,12 @@
{
if (m_networkProcess) {
if (withWebsiteDataStore) {
- m_networkProcess->send(Messages::NetworkProcess::AddWebsiteDataStore(withWebsiteDataStore->parameters()), 0);
+ m_networkProcess->addSession(makeRef(*withWebsiteDataStore));
withWebsiteDataStore->clearPendingCookies();
}
return *m_networkProcess;
}
- if (m_websiteDataStore)
- m_websiteDataStore->websiteDataStore().resolveDirectoriesIfNecessary();
-
m_networkProcess = NetworkProcessProxy::create(*this);
NetworkProcessCreationParameters parameters;
@@ -463,7 +460,7 @@
if (withWebsiteDataStore) {
auto websiteDataStoreParameters = withWebsiteDataStore->parameters();
- parameters.defaultSessionParameters = websiteDataStoreParameters.networkSessionParameters;
+ parameters.defaultSessionParameters = WTFMove(websiteDataStoreParameters.networkSessionParameters);
// FIXME: This isn't conceptually correct, but it's needed to preserve behavior introduced in r213241.
// We should separate the concept of the default session from the currently used persistent session.
@@ -482,11 +479,6 @@
for (auto& scheme : m_urlSchemesRegisteredForCustomProtocols)
parameters.urlSchemesRegisteredForCustomProtocols.append(scheme);
- parameters.cacheStorageDirectory = m_websiteDataStore ? m_websiteDataStore->websiteDataStore().cacheStorageDirectory() : API::WebsiteDataStore::defaultCacheStorageDirectory();
- if (!parameters.cacheStorageDirectory.isEmpty())
- SandboxExtension::createHandleForReadWriteDirectory(parameters.cacheStorageDirectory, parameters.cacheStorageDirectoryExtensionHandle);
- parameters.cacheStoragePerOriginQuota = m_websiteDataStore ? m_websiteDataStore->websiteDataStore().cacheStoragePerOriginQuota() : WebsiteDataStore::defaultCacheStoragePerOriginQuota;
-
parameters.diskCacheDirectory = m_configuration->diskCacheDirectory();
if (!parameters.diskCacheDirectory.isEmpty())
SandboxExtension::createHandleForReadWriteDirectory(parameters.diskCacheDirectory, parameters.diskCacheDirectoryExtensionHandle);
@@ -537,12 +529,12 @@
}
if (m_websiteDataStore) {
- m_networkProcess->send(Messages::NetworkProcess::AddWebsiteDataStore(m_websiteDataStore->websiteDataStore().parameters()), 0);
+ m_networkProcess->addSession(makeRef(m_websiteDataStore->websiteDataStore()));
m_websiteDataStore->websiteDataStore().clearPendingCookies();
}
if (withWebsiteDataStore) {
- m_networkProcess->send(Messages::NetworkProcess::AddWebsiteDataStore(withWebsiteDataStore->parameters()), 0);
+ m_networkProcess->addSession(makeRef(*withWebsiteDataStore));
withWebsiteDataStore->clearPendingCookies();
}
@@ -723,7 +715,7 @@
sendToNetworkingProcess(Messages::NetworkProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()));
sendToAllProcesses(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::legacyPrivateSessionParameters()));
} else {
- sendToNetworkingProcess(Messages::NetworkProcess::DestroySession(PAL::SessionID::legacyPrivateSessionID()));
+ networkProcess()->removeSession(PAL::SessionID::legacyPrivateSessionID());
sendToStorageProcess(Messages::StorageProcess::DestroySession(PAL::SessionID::legacyPrivateSessionID()));
sendToAllProcesses(Messages::WebProcess::DestroySession(PAL::SessionID::legacyPrivateSessionID()));
}
@@ -1197,11 +1189,13 @@
auto sessionID = page.sessionID();
if (sessionID.isEphemeral()) {
ASSERT(page.websiteDataStore().parameters().networkSessionParameters.sessionID == sessionID);
- sendToNetworkingProcess(Messages::NetworkProcess::AddWebsiteDataStore(page.websiteDataStore().parameters()));
+ if (m_networkProcess)
+ m_networkProcess->addSession(makeRef(page.websiteDataStore()));
page.process().send(Messages::WebProcess::AddWebsiteDataStore(WebsiteDataStoreParameters::privateSessionParameters(sessionID)), 0);
page.websiteDataStore().clearPendingCookies();
} else if (sessionID != PAL::SessionID::defaultSessionID()) {
- sendToNetworkingProcess(Messages::NetworkProcess::AddWebsiteDataStore(page.websiteDataStore().parameters()));
+ if (m_networkProcess)
+ m_networkProcess->addSession(makeRef(page.websiteDataStore()));
page.process().send(Messages::WebProcess::AddWebsiteDataStore(page.websiteDataStore().parameters()), 0);
page.websiteDataStore().clearPendingCookies();
@@ -1237,7 +1231,7 @@
// The last user of this non-default PAL::SessionID is gone, so clean it up in the child processes.
if (networkProcess())
- networkProcess()->send(Messages::NetworkProcess::DestroySession(sessionID), 0);
+ networkProcess()->removeSession(sessionID);
page.process().send(Messages::WebProcess::DestroySession(sessionID), 0);
}
}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2018-06-15 01:05:49 UTC (rev 232863)
@@ -78,11 +78,6 @@
if (!cookieFile.isEmpty())
SandboxExtension::createHandleForReadWriteDirectory(WebCore::FileSystem::directoryName(cookieFile), parameters.cookieStoragePathExtensionHandle);
- if (!m_configuration.cacheStorageDirectory.isNull()) {
- parameters.cacheStorageDirectory = m_configuration.cacheStorageDirectory;
- SandboxExtension::createHandleForReadWriteDirectory(parameters.cacheStorageDirectory, parameters.cacheStorageDirectoryExtensionHandle);
- }
-
return parameters;
}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (232862 => 232863)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-06-15 00:23:03 UTC (rev 232862)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-06-15 01:05:49 UTC (rev 232863)
@@ -118,8 +118,9 @@
ASSERT(nonDefaultDataStores().get(m_sessionID) == this);
nonDefaultDataStores().remove(m_sessionID);
for (auto& processPool : WebProcessPool::allProcessPools()) {
- processPool->sendToNetworkingProcess(Messages::NetworkProcess::DestroySession(m_sessionID));
processPool->sendToStorageProcess(Messages::StorageProcess::DestroySession(m_sessionID));
+ if (auto* networkProcess = processPool->networkProcess())
+ networkProcess->removeSession(m_sessionID);
}
}
}