Diff
Modified: trunk/Source/WebCore/ChangeLog (221314 => 221315)
--- trunk/Source/WebCore/ChangeLog 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebCore/ChangeLog 2017-08-29 21:39:48 UTC (rev 221315)
@@ -1,3 +1,16 @@
+2017-08-29 Youenn Fablet <you...@apple.com>
+
+ Setting the cache storage engine root path according the session WebsiteDataStore
+ https://bugs.webkit.org/show_bug.cgi?id=176055
+
+ Reviewed by Alex Christensen.
+
+ No test right now as the engine is not making any read/write operations.
+
+ * platform/network/NetworkStorageSession.h:
+ (WebCore::NetworkStorageSession::cacheStorageDirectory const):
+ (WebCore::NetworkStorageSession::setCacheStorageDirectory):
+
2017-08-29 Don Olmstead <don.olmst...@sony.com>
[CMake] Use find_package for libxml2 and libxstl
Modified: trunk/Source/WebCore/platform/network/NetworkStorageSession.h (221314 => 221315)
--- trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebCore/platform/network/NetworkStorageSession.h 2017-08-29 21:39:48 UTC (rev 221315)
@@ -77,6 +77,9 @@
NSHTTPCookieStorage *nsCookieStorage() const;
#endif
+ const String& cacheStorageDirectory() const { return m_cacheStorageDirectory; }
+ void setCacheStorageDirectory(String&& path) { m_cacheStorageDirectory = WTFMove(path); }
+
#if PLATFORM(COCOA) || USE(CFURLCONNECTION)
WEBCORE_EXPORT static void ensureSession(PAL::SessionID, const String& identifierBase, RetainPtr<CFHTTPCookieStorageRef>&&);
NetworkStorageSession(PAL::SessionID, RetainPtr<CFURLStorageSessionRef>&&, RetainPtr<CFHTTPCookieStorageRef>&&);
@@ -139,6 +142,8 @@
CredentialStorage m_credentialStorage;
+ String m_cacheStorageDirectory;
+
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
bool shouldPartitionCookies(const String& topPrivatelyControlledDomain) const;
HashSet<String> m_topPrivatelyControlledDomainsForCookiePartitioning;
Modified: trunk/Source/WebKit/ChangeLog (221314 => 221315)
--- trunk/Source/WebKit/ChangeLog 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/ChangeLog 2017-08-29 21:39:48 UTC (rev 221315)
@@ -1,3 +1,43 @@
+2017-08-29 Youenn Fablet <you...@apple.com>
+
+ Setting the cache storage engine root path according the session WebsiteDataStore
+ https://bugs.webkit.org/show_bug.cgi?id=176055
+
+ Reviewed by Alex Christensen.
+
+ Adding disk read/write capacities to CacheStorage engine.
+ This is used to store per-origin cache names in a file.
+ Making Engine a thread safe refcounted object so that it does read/write in a background thread.
+
+ Setting the root path of the engine to the directory set for the session in use according the WebsiteDataStore.
+ For each WebsiteDataStore, a path and a sandbox extension is passed to the network process if persistency of the cache storage is wanted.
+ Ephemeral sessions will set the path of the engine to null so that no read/write access is performed.
+
+ * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+ (WebKit::NetworkConnectionToWebProcess::ensureLegacyPrivateBrowsingSession):
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::initializeNetworkProcess):
+ (WebKit::NetworkProcess::cacheStorageDirectory const):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/cache/CacheStorageEngine.cpp:
+ (WebKit::CacheStorage::Engine::from):
+ (WebKit::CacheStorage::Engine::defaultEngine):
+ (WebKit::CacheStorage::Engine::Engine):
+ (WebKit::CacheStorage::Engine::writeFile):
+ * NetworkProcess/cache/CacheStorageEngine.h:
+ (WebKit::CacheStorage::Engine::create):
+ (WebKit::CacheStorage::Engine::shouldPersist const):
+ * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
+ (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
+ * NetworkProcess/mac/RemoteNetworkingContext.mm:
+ (WebKit::RemoteNetworkingContext::ensureWebsiteDataStoreSession):
+ * Shared/WebsiteDataStoreParameters.cpp:
+ (WebKit::WebsiteDataStoreParameters::encode const):
+ (WebKit::WebsiteDataStoreParameters::decode):
+ * Shared/WebsiteDataStoreParameters.h:
+ * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+ (WebKit::WebsiteDataStore::parameters):
+
2017-08-29 Chris Dumez <cdu...@apple.com>
Add initial support for dataTransferItem.webkitGetAsEntry()
Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp 2017-08-29 21:39:48 UTC (rev 221315)
@@ -446,7 +446,7 @@
void NetworkConnectionToWebProcess::ensureLegacyPrivateBrowsingSession()
{
- NetworkProcess::singleton().ensurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }});
+ NetworkProcess::singleton().ensurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }, { }, { }});
}
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp 2017-08-29 21:39:48 UTC (rev 221315)
@@ -237,7 +237,7 @@
// FIXME: instead of handling this here, a message should be sent later (scales to multiple sessions)
if (parameters.privateBrowsingEnabled)
- RemoteNetworkingContext::ensurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }});
+ RemoteNetworkingContext::ensurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }, { }, { }});
if (parameters.shouldUseTestingNetworkSession)
NetworkStorageSession::switchToNewTestingSession();
@@ -701,6 +701,21 @@
WebCore::prefetchDNS(hostname);
}
+String NetworkProcess::cacheStorageDirectory(PAL::SessionID sessionID) const
+{
+ if (sessionID.isEphemeral())
+ return { };
+
+ if (sessionID == PAL::SessionID::defaultSessionID())
+ return m_cacheStorageDirectory;
+
+ auto* session = NetworkStorageSession::storageSession(sessionID);
+ if (!session)
+ return { };
+
+ return session->cacheStorageDirectory();
+}
+
#if !PLATFORM(COCOA)
void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&)
{
@@ -717,6 +732,7 @@
void NetworkProcess::syncAllCookies()
{
}
+
#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h 2017-08-29 21:39:48 UTC (rev 221315)
@@ -134,7 +134,7 @@
#endif
Seconds loadThrottleLatency() const { return m_loadThrottleLatency; }
- const String& cacheStorageDirectory() const { return m_cacheStorageDirectory; }
+ String cacheStorageDirectory(PAL::SessionID) const;
private:
NetworkProcess();
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp 2017-08-29 21:39:48 UTC (rev 221315)
@@ -26,6 +26,8 @@
#include "config.h"
#include "CacheStorageEngine.h"
+#include "NetworkCacheIOChannel.h"
+#include "NetworkProcess.h"
#include <WebCore/CacheQueryOptions.h>
#include <pal/SessionID.h>
#include <wtf/MainThread.h>
@@ -33,25 +35,25 @@
#include <wtf/text/StringHash.h>
using namespace WebCore::DOMCache;
+using namespace WebKit::NetworkCache;
namespace WebKit {
namespace CacheStorage {
-static HashMap<PAL::SessionID, std::unique_ptr<Engine>>& globalEngineMap()
+static HashMap<PAL::SessionID, RefPtr<Engine>>& globalEngineMap()
{
- static NeverDestroyed<HashMap<PAL::SessionID, std::unique_ptr<Engine>>> map;
+ static NeverDestroyed<HashMap<PAL::SessionID, RefPtr<Engine>>> map;
+
return map;
}
Engine& Engine::from(PAL::SessionID sessionID)
{
- if (sessionID == PAL::SessionID::defaultSessionID())
- return defaultEngine();
-
- return *globalEngineMap().ensure(sessionID, [] {
- return std::make_unique<Engine>();
- }).iterator->value;
+ auto addResult = globalEngineMap().add(sessionID, nullptr);
+ if (addResult.isNewEntry)
+ addResult.iterator->value = Engine::create(NetworkProcess::singleton().cacheStorageDirectory(sessionID));
+ return *addResult.iterator->value;
}
void Engine::destroyEngine(PAL::SessionID sessionID)
@@ -62,10 +64,18 @@
Engine& Engine::defaultEngine()
{
- static NeverDestroyed<std::unique_ptr<Engine>> defaultEngine = { std::make_unique<Engine>() };
- return *defaultEngine.get();
+ auto sessionID = PAL::SessionID::defaultSessionID();
+ static NeverDestroyed<Ref<Engine>> defaultEngine = { Engine::create(NetworkProcess::singleton().cacheStorageDirectory(sessionID)) };
+ return defaultEngine.get();
}
+Engine::Engine(String&& rootPath)
+ : m_rootPath(WTFMove(rootPath))
+{
+ if (!m_rootPath.isNull())
+ m_ioQueue = WorkQueue::create("com.apple.WebKit.CacheStorageEngine.serialBackground", WorkQueue::Type::Serial, WorkQueue::QOS::Background);
+}
+
void Engine::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback)
{
readCachesFromDisk(origin, [this, cacheName, callback = WTFMove(callback)](CachesOrError&& cachesOrError) mutable {
@@ -305,7 +315,62 @@
return results;
}
+void Engine::writeFile(const String& filename, NetworkCache::Data&& data, WebCore::DOMCache::CompletionCallback&& callback)
+{
+ if (!shouldPersist()) {
+ callback(std::nullopt);
+ return;
+ }
+
+ m_ioQueue->dispatch([this, protectedThis = makeRef(*this), callback = WTFMove(callback), data = "" filename = filename.isolatedCopy()] () mutable {
+ auto channel = IOChannel::open(filename, IOChannel::Type::Create);
+ channel->write(0, data, m_ioQueue.get(), [callback = WTFMove(callback)](int error) mutable {
+ RunLoop::main().dispatch([callback = WTFMove(callback), error]() mutable {
+ if (error) {
+ // FIXME: Use specific filesystem error.
+ callback(Error::Internal);
+ return;
+ }
+ callback(std::nullopt);
+ });
+ });
+ });
+}
+
+void Engine::readFile(const String& filename, WTF::Function<void(const NetworkCache::Data&, int error)>&& callback)
+{
+ if (!shouldPersist()) {
+ callback(Data { }, 0);
+ return;
+ }
+
+ m_ioQueue->dispatch([this, protectedThis = makeRef(*this), callback = WTFMove(callback), filename = filename.isolatedCopy()]() mutable {
+ auto channel = IOChannel::open(filename, IOChannel::Type::Read);
+ if (channel->fileDescriptor() < 0) {
+ RunLoop::main().dispatch([callback = WTFMove(callback)]() mutable {
+ callback(Data { }, 0);
+ });
+ return;
+ }
+
+ channel->read(0, std::numeric_limits<size_t>::max(), m_ioQueue.get(), [callback = WTFMove(callback)](const Data& data, int error) mutable {
+ RunLoop::main().dispatch([callback = WTFMove(callback), data, error]() mutable {
+ callback(data, error);
+ });
+ });
+ });
+}
+
+void Engine::removeFile(const String& filename)
+{
+ if (!shouldPersist())
+ return;
+
+ m_ioQueue->dispatch([filename = filename.isolatedCopy()]() mutable {
+ WebCore::deleteFile(filename);
+ });
+}
+
} // namespace CacheStorage
} // namespace WebKit
-
Modified: trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h 2017-08-29 21:39:48 UTC (rev 221315)
@@ -26,7 +26,10 @@
#pragma once
#include "CacheStorageEngineCache.h"
+#include "NetworkCacheData.h"
#include <wtf/HashMap.h>
+#include <wtf/ThreadSafeRefCounted.h>
+#include <wtf/WorkQueue.h>
namespace IPC {
class Connection;
@@ -40,11 +43,14 @@
namespace CacheStorage {
-class Engine {
+class Engine : public ThreadSafeRefCounted<Engine> {
public:
static Engine& from(PAL::SessionID);
static void destroyEngine(PAL::SessionID);
+ static Ref<Engine> create(String&& rootPath) { return adoptRef(*new Engine(WTFMove(rootPath))); }
+ bool shouldPersist() const { return !!m_ioQueue;}
+
void open(const String& origin, const String& cacheName, WebCore::DOMCache::CacheIdentifierCallback&&);
void remove(uint64_t cacheIdentifier, WebCore::DOMCache::CacheIdentifierCallback&&);
void retrieveCaches(const String& origin, WebCore::DOMCache::CacheInfosCallback&&);
@@ -53,8 +59,13 @@
void putRecords(uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
+ void writeFile(const String& filename, NetworkCache::Data&&, WebCore::DOMCache::CompletionCallback&&);
+ void readFile(const String& filename, WTF::Function<void(const NetworkCache::Data&, int error)>&&);
+ void removeFile(const String& filename);
+
private:
static Engine& defaultEngine();
+ explicit Engine(String&& rootPath);
void writeCachesToDisk(WebCore::DOMCache::CompletionCallback&&);
@@ -76,6 +87,8 @@
HashMap<String, Vector<Cache>> m_caches;
Vector<Cache> m_removedCaches;
uint64_t m_nextCacheIdentifier { 0 };
+ String m_rootPath;
+ RefPtr<WorkQueue> m_ioQueue;
};
} // namespace CacheStorage
Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm 2017-08-29 21:39:48 UTC (rev 221315)
@@ -30,6 +30,7 @@
#import "NetworkProcessCreationParameters.h"
#import "NetworkResourceLoader.h"
#import "NetworkSessionCocoa.h"
+#import "RemoteNetworkingContext.h"
#import "SandboxExtension.h"
#import "SessionTracker.h"
#import <WebCore/NetworkStorageSession.h>
@@ -73,7 +74,6 @@
SandboxExtension::consumePermanently(parameters.containerCachesDirectoryExtensionHandle);
SandboxExtension::consumePermanently(parameters.parentBundleDirectoryExtensionHandle);
#endif
- m_cacheStorageDirectory = parameters.cacheStorageDirectory;
m_diskCacheDirectory = parameters.diskCacheDirectory;
_CFNetworkSetATSContext(parameters.networkATSContext.get());
@@ -106,8 +106,10 @@
ASSERT(!m_diskCacheIsDisabledForTesting || !parameters.nsURLCacheDiskCapacity);
- if (!m_cacheStorageDirectory.isNull())
+ if (!parameters.cacheStorageDirectory.isNull()) {
+ m_cacheStorageDirectory = parameters.cacheStorageDirectory;
SandboxExtension::consumePermanently(parameters.cacheStorageDirectoryExtensionHandle);
+ }
if (!m_diskCacheDirectory.isNull()) {
SandboxExtension::consumePermanently(parameters.diskCacheDirectoryExtensionHandle);
Modified: trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm (221314 => 221315)
--- trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/NetworkProcess/mac/RemoteNetworkingContext.mm 2017-08-29 21:39:48 UTC (rev 221315)
@@ -129,6 +129,11 @@
for (const auto& cookie : parameters.pendingCookies)
session->setCookie(cookie);
+ if (!parameters.cacheStorageDirectory.isNull()) {
+ SandboxExtension::consumePermanently(parameters.cacheStorageDirectoryExtensionHandle);
+ session->setCacheStorageDirectory(WTFMove(parameters.cacheStorageDirectory));
+ }
+
#if USE(NETWORK_SESSION)
auto networkSession = NetworkSession::create(parameters.sessionID, NetworkProcess::singleton().supplement<LegacyCustomProtocolManager>());
SessionTracker::setSession(parameters.sessionID, WTFMove(networkSession));
Modified: trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp (221314 => 221315)
--- trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.cpp 2017-08-29 21:39:48 UTC (rev 221315)
@@ -40,6 +40,8 @@
encoder << uiProcessCookieStorageIdentifier;
encoder << cookieStoragePathExtensionHandle;
encoder << pendingCookies;
+ encoder << cacheStorageDirectory;
+ encoder << cacheStorageDirectoryExtensionHandle;
}
bool WebsiteDataStoreParameters::decode(IPC::Decoder& decoder, WebsiteDataStoreParameters& parameters)
@@ -56,6 +58,12 @@
if (!decoder.decode(parameters.pendingCookies))
return false;
+ if (!decoder.decode(parameters.cacheStorageDirectory))
+ return false;
+
+ if (!decoder.decode(parameters.cacheStorageDirectoryExtensionHandle))
+ return false;
+
return true;
}
Modified: trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h (221314 => 221315)
--- trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/Shared/WebsiteDataStoreParameters.h 2017-08-29 21:39:48 UTC (rev 221315)
@@ -50,6 +50,8 @@
Vector<uint8_t> uiProcessCookieStorageIdentifier;
SandboxExtension::Handle cookieStoragePathExtensionHandle;
Vector<WebCore::Cookie> pendingCookies;
+ String cacheStorageDirectory;
+ SandboxExtension::Handle cacheStorageDirectoryExtensionHandle;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (221314 => 221315)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2017-08-29 21:39:48 UTC (rev 221315)
@@ -589,7 +589,7 @@
{
if (networkProcess()) {
if (privateBrowsingEnabled)
- networkProcess()->send(Messages::NetworkProcess::EnsurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }}), 0);
+ networkProcess()->send(Messages::NetworkProcess::EnsurePrivateBrowsingSession({PAL::SessionID::legacyPrivateSessionID(), { }, { }, { }, { }, { }}), 0);
else
networkProcess()->send(Messages::NetworkProcess::DestroySession(PAL::SessionID::legacyPrivateSessionID()), 0);
}
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm (221314 => 221315)
--- trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2017-08-29 21:35:18 UTC (rev 221314)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm 2017-08-29 21:39:48 UTC (rev 221315)
@@ -75,6 +75,11 @@
if (!cookieFile.isEmpty())
SandboxExtension::createHandleForReadWriteDirectory(WebCore::directoryName(cookieFile), parameters.cookieStoragePathExtensionHandle);
+ if (!m_configuration.cacheStorageDirectory.isNull()) {
+ parameters.cacheStorageDirectory = m_configuration.cacheStorageDirectory;
+ SandboxExtension::createHandleForReadWriteDirectory(parameters.cacheStorageDirectory, parameters.cacheStorageDirectoryExtensionHandle);
+ }
+
return parameters;
}