[CacheAPI] Introduce a WebKit::CacheStorage namespace
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 19:45:48 +0000 (19:45 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 19:45:48 +0000 (19:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175885

Patch by Youenn Fablet <youenn@apple.com> on 2017-08-23
Reviewed by Alex Christensen.

Introducing WebKit::CacheStorage namespace.
Splitting CacheStorageEngine.h in three files.
Updating client code accordingly.

* NetworkProcess/cache/CacheStorage.h: Added.
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::globalEngineMap):
(WebKit::CacheStorage::Engine::from):
(WebKit::CacheStorage::Engine::destroyEngine):
(WebKit::CacheStorage::Engine::defaultEngine):
(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::writeCachesToDisk):
(WebKit::CacheStorage::Engine::readCachesFromDisk):
(WebKit::CacheStorage::Engine::readCache):
(WebKit::CacheStorage::Engine::writeCacheRecords):
(WebKit::CacheStorage::Engine::removeCacheRecords):
(WebKit::CacheStorage::Engine::cache):
(WebKit::CacheStorage::Engine::caches const):
(WebKit::CacheStorage::Engine::queryCache):
* NetworkProcess/cache/CacheStorageEngineCache.h: Added.
* NetworkProcess/cache/CacheStorageEngineConnection.cpp:
(WebKit::CacheStorageEngineConnection::open):
(WebKit::CacheStorageEngineConnection::remove):
(WebKit::CacheStorageEngineConnection::caches):
(WebKit::CacheStorageEngineConnection::records):
(WebKit::CacheStorageEngineConnection::deleteMatchingRecords):
(WebKit::CacheStorageEngineConnection::putRecords):
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::openCompleted):
(WebKit::WebCacheStorageConnection::removeCompleted):
(WebKit::WebCacheStorageConnection::updateCaches):
(WebKit::WebCacheStorageConnection::updateRecords):
(WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
(WebKit::WebCacheStorageConnection::putRecordsCompleted):
* WebProcess/Cache/WebCacheStorageConnection.h:

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

Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorage.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h [new file with mode: 0644]
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp
Source/WebKit/WebKit.xcodeproj/project.pbxproj
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h
Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.messages.in

index 5872452..86f9e6f 100644 (file)
@@ -1,5 +1,54 @@
 2017-08-23  Youenn Fablet  <youenn@apple.com>
 
+        [CacheAPI] Introduce a WebKit::CacheStorage namespace
+        https://bugs.webkit.org/show_bug.cgi?id=175885
+
+        Reviewed by Alex Christensen.
+
+        Introducing WebKit::CacheStorage namespace.
+        Splitting CacheStorageEngine.h in three files.
+        Updating client code accordingly.
+
+        * NetworkProcess/cache/CacheStorage.h: Added.
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::globalEngineMap):
+        (WebKit::CacheStorage::Engine::from):
+        (WebKit::CacheStorage::Engine::destroyEngine):
+        (WebKit::CacheStorage::Engine::defaultEngine):
+        (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::writeCachesToDisk):
+        (WebKit::CacheStorage::Engine::readCachesFromDisk):
+        (WebKit::CacheStorage::Engine::readCache):
+        (WebKit::CacheStorage::Engine::writeCacheRecords):
+        (WebKit::CacheStorage::Engine::removeCacheRecords):
+        (WebKit::CacheStorage::Engine::cache):
+        (WebKit::CacheStorage::Engine::caches const):
+        (WebKit::CacheStorage::Engine::queryCache):
+        * NetworkProcess/cache/CacheStorageEngineCache.h: Added.
+        * NetworkProcess/cache/CacheStorageEngineConnection.cpp:
+        (WebKit::CacheStorageEngineConnection::open):
+        (WebKit::CacheStorageEngineConnection::remove):
+        (WebKit::CacheStorageEngineConnection::caches):
+        (WebKit::CacheStorageEngineConnection::records):
+        (WebKit::CacheStorageEngineConnection::deleteMatchingRecords):
+        (WebKit::CacheStorageEngineConnection::putRecords):
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/Cache/WebCacheStorageConnection.cpp:
+        (WebKit::WebCacheStorageConnection::openCompleted):
+        (WebKit::WebCacheStorageConnection::removeCompleted):
+        (WebKit::WebCacheStorageConnection::updateCaches):
+        (WebKit::WebCacheStorageConnection::updateRecords):
+        (WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
+        (WebKit::WebCacheStorageConnection::putRecordsCompleted):
+        * WebProcess/Cache/WebCacheStorageConnection.h:
+
+2017-08-23  Youenn Fablet  <youenn@apple.com>
+
         [Cache API] Enable persistent coder to encode FetchOptions
         https://bugs.webkit.org/show_bug.cgi?id=175883
 
diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorage.h b/Source/WebKit/NetworkProcess/cache/CacheStorage.h
new file mode 100644 (file)
index 0000000..874f671
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "WebCoreArgumentCoders.h"
+#include <WebCore/CacheStorageConnection.h>
+#include <wtf/EnumTraits.h>
+
+namespace WebKit {
+
+namespace CacheStorage {
+
+enum class Error {
+    Internal
+};
+
+using Record = WebCore::CacheStorageConnection::Record;
+
+using CacheIdentifierOrError = Expected<uint64_t, Error>;
+using CacheIdentifierCallback = Function<void(CacheIdentifierOrError&&)>;
+
+using CacheInfosOrError = Expected<Vector<WebCore::CacheStorageConnection::CacheInfo>, Error>;
+using CacheInfosCallback = Function<void(CacheInfosOrError&&)>;
+
+using RecordsOrError = Expected<Vector<Record>, Error>;
+using RecordsCallback = Function<void(RecordsOrError&&)>;
+
+using RecordIdentifiersOrError = Expected<Vector<uint64_t>, Error>;
+using RecordIdentifiersCallback = Function<void(RecordIdentifiersOrError&&)>;
+
+using CompletionCallback = Function<void(std::optional<Error>&&)>;
+
+} // namespace CacheStorage
+
+} // namespace WebKit
+
+namespace WTF {
+template<> struct EnumTraits<WebKit::CacheStorage::Error> {
+    using values = EnumValues<
+        WebKit::CacheStorage::Error,
+        WebKit::CacheStorage::Error::Internal
+    >;
+};
+}
index 5e892be..36aa673 100644 (file)
 
 namespace WebKit {
 
-static HashMap<PAL::SessionID, std::unique_ptr<CacheStorageEngine>>& globalEngineMap()
+namespace CacheStorage {
+
+static HashMap<PAL::SessionID, std::unique_ptr<Engine>>& globalEngineMap()
 {
-    static NeverDestroyed<HashMap<PAL::SessionID, std::unique_ptr<CacheStorageEngine>>> map;
+    static NeverDestroyed<HashMap<PAL::SessionID, std::unique_ptr<Engine>>> map;
     return map;
 }
 
-CacheStorageEngine& CacheStorageEngine::from(PAL::SessionID sessionID)
+Engine& Engine::from(PAL::SessionID sessionID)
 {
     if (sessionID == PAL::SessionID::defaultSessionID())
         return defaultEngine();
 
     return *globalEngineMap().ensure(sessionID, [] {
-        return std::make_unique<CacheStorageEngine>();
+        return std::make_unique<Engine>();
     }).iterator->value;
 }
 
-void CacheStorageEngine::destroyEngine(PAL::SessionID sessionID)
+void Engine::destroyEngine(PAL::SessionID sessionID)
 {
     ASSERT(sessionID != PAL::SessionID::defaultSessionID());
     globalEngineMap().remove(sessionID);
 }
 
-CacheStorageEngine& CacheStorageEngine::defaultEngine()
+Engine& Engine::defaultEngine()
 {
-    static NeverDestroyed<std::unique_ptr<CacheStorageEngine>> defaultEngine = { std::make_unique<CacheStorageEngine>() };
+    static NeverDestroyed<std::unique_ptr<Engine>> defaultEngine = { std::make_unique<Engine>() };
     return *defaultEngine.get();
 }
 
-void CacheStorageEngine::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback)
+void Engine::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback)
 {
     readCachesFromDisk(origin, [this, cacheName, callback = WTFMove(callback)](CachesOrError&& cachesOrError) mutable {
         if (!cachesOrError.hasValue()) {
@@ -89,7 +91,7 @@ void CacheStorageEngine::open(const String& origin, const String& cacheName, Cac
     });
 }
 
-void CacheStorageEngine::remove(uint64_t cacheIdentifier, CacheIdentifierCallback&& callback)
+void Engine::remove(uint64_t cacheIdentifier, CacheIdentifierCallback&& callback)
 {
     std::optional<Cache> removedCache;
     for (auto& caches : m_caches.values()) {
@@ -114,7 +116,7 @@ void CacheStorageEngine::remove(uint64_t cacheIdentifier, CacheIdentifierCallbac
     });
 }
 
-void CacheStorageEngine::retrieveCaches(const String& origin, CacheInfosCallback&& callback)
+void Engine::retrieveCaches(const String& origin, CacheInfosCallback&& callback)
 {
     readCachesFromDisk(origin, [this, callback = WTFMove(callback)](CachesOrError&& cachesOrError) mutable {
         if (!cachesOrError.hasValue()) {
@@ -133,7 +135,7 @@ void CacheStorageEngine::retrieveCaches(const String& origin, CacheInfosCallback
     });
 }
 
-void CacheStorageEngine::retrieveRecords(uint64_t cacheIdentifier, RecordsCallback&& callback)
+void Engine::retrieveRecords(uint64_t cacheIdentifier, RecordsCallback&& callback)
 {
     readCache(cacheIdentifier, [callback = WTFMove(callback)](CacheOrError&& result) mutable {
         if (!result.hasValue()) {
@@ -152,7 +154,7 @@ void CacheStorageEngine::retrieveRecords(uint64_t cacheIdentifier, RecordsCallba
     });
 }
 
-void CacheStorageEngine::putRecords(uint64_t cacheIdentifier, Vector<Record>&& records, RecordIdentifiersCallback&& callback)
+void Engine::putRecords(uint64_t cacheIdentifier, Vector<Record>&& records, RecordIdentifiersCallback&& callback)
 {
     readCache(cacheIdentifier, [this, cacheIdentifier, records = WTFMove(records), callback = WTFMove(callback)](CacheOrError&& result) mutable {
         if (!result.hasValue()) {
@@ -166,7 +168,7 @@ void CacheStorageEngine::putRecords(uint64_t cacheIdentifier, Vector<Record>&& r
         Vector<uint64_t> recordIdentifiers;
         recordIdentifiers.reserveInitialCapacity(records.size());
         for (auto& record : records) {
-            auto matchingRecords = CacheStorageEngine::queryCache(cache.records, record.request, options);
+            auto matchingRecords = Engine::queryCache(cache.records, record.request, options);
             if (matchingRecords.isEmpty()) {
                 record.identifier = ++cache.nextRecordIdentifier;
                 recordIdentifiers.uncheckedAppend(record.identifier);
@@ -191,7 +193,7 @@ void CacheStorageEngine::putRecords(uint64_t cacheIdentifier, Vector<Record>&& r
     });
 }
 
-void CacheStorageEngine::deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options, RecordIdentifiersCallback&& callback)
+void Engine::deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options, RecordIdentifiersCallback&& callback)
 {
     readCache(cacheIdentifier, [this, cacheIdentifier, request = WTFMove(request), options = WTFMove(options), callback = WTFMove(callback)](CacheOrError&& result) mutable {
         if (!result.hasValue()) {
@@ -230,13 +232,13 @@ void CacheStorageEngine::deleteMatchingRecords(uint64_t cacheIdentifier, WebCore
     });
 }
 
-void CacheStorageEngine::writeCachesToDisk(Function<void(std::optional<Error>&&)>&& callback)
+void Engine::writeCachesToDisk(Function<void(std::optional<Error>&&)>&& callback)
 {
     // FIXME: Implement writing.
     callback(std::nullopt);
 }
 
-void CacheStorageEngine::readCachesFromDisk(const String& origin, CachesCallback&& callback)
+void Engine::readCachesFromDisk(const String& origin, CachesCallback&& callback)
 {
     // FIXME: Implement reading.
 
@@ -247,7 +249,7 @@ void CacheStorageEngine::readCachesFromDisk(const String& origin, CachesCallback
     callback(std::reference_wrapper<Vector<Cache>> { caches });
 }
 
-void CacheStorageEngine::readCache(uint64_t cacheIdentifier, CacheCallback&& callback)
+void Engine::readCache(uint64_t cacheIdentifier, CacheCallback&& callback)
 {
     // FIXME: Implement reading.
     auto* cache = this->cache(cacheIdentifier);
@@ -258,19 +260,19 @@ void CacheStorageEngine::readCache(uint64_t cacheIdentifier, CacheCallback&& cal
     callback(std::reference_wrapper<Cache> { *cache });
 }
 
-void CacheStorageEngine::writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&& recordsIdentifiers, RecordIdentifiersCallback&& callback)
+void Engine::writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&& recordsIdentifiers, RecordIdentifiersCallback&& callback)
 {
     // FIXME: Implement writing.
     callback(WTFMove(recordsIdentifiers));
 }
 
-void CacheStorageEngine::removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&& recordsIdentifiers, RecordIdentifiersCallback&& callback)
+void Engine::removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&& recordsIdentifiers, RecordIdentifiersCallback&& callback)
 {
     // FIXME: Implement writing.
     callback(WTFMove(recordsIdentifiers));
 }
 
-CacheStorageEngine::Cache* CacheStorageEngine::cache(uint64_t cacheIdentifier)
+CacheEngine::cache(uint64_t cacheIdentifier)
 {
     Cache* result = nullptr;
     for (auto& caches : m_caches.values()) {
@@ -288,7 +290,7 @@ CacheStorageEngine::Cache* CacheStorageEngine::cache(uint64_t cacheIdentifier)
     return result;
 }
 
-Vector<uint64_t> CacheStorageEngine::queryCache(const Vector<Record>& records, const WebCore::ResourceRequest& request, const WebCore::CacheQueryOptions& options)
+Vector<uint64_t> Engine::queryCache(const Vector<Record>& records, const WebCore::ResourceRequest& request, const WebCore::CacheQueryOptions& options)
 {
     if (!options.ignoreMethod && request.httpMethod() != "GET")
         return { };
@@ -301,4 +303,7 @@ Vector<uint64_t> CacheStorageEngine::queryCache(const Vector<Record>& records, c
     return results;
 }
 
-}
+} // namespace CacheStorage
+
+} // namespace WebKit
+
index be9b994..0f1ba4c 100644 (file)
 
 #pragma once
 
-#include "WebCoreArgumentCoders.h"
-#include <WebCore/CacheStorageConnection.h>
-#include <wtf/Forward.h>
+#include "CacheStorageEngineCache.h"
 #include <wtf/HashMap.h>
-#include <wtf/Vector.h>
-#include <wtf/text/WTFString.h>
 
 namespace IPC {
 class Connection;
@@ -42,32 +38,13 @@ class SessionID;
 
 namespace WebKit {
 
-class NetworkConnectionToWebProcess;
+namespace CacheStorage {
 
-class CacheStorageEngine {
+class Engine {
 public:
-    static CacheStorageEngine& from(PAL::SessionID);
+    static Engine& from(PAL::SessionID);
     static void destroyEngine(PAL::SessionID);
 
-    enum class Error {
-        Internal
-    };
-    using Record = WebCore::CacheStorageConnection::Record;
-
-    using CacheIdentifierOrError = Expected<uint64_t, Error>;
-    using CacheIdentifierCallback = Function<void(CacheIdentifierOrError&&)>;
-
-    using CacheInfosOrError = Expected<Vector<WebCore::CacheStorageConnection::CacheInfo>, Error>;
-    using CacheInfosCallback = Function<void(CacheInfosOrError&&)>;
-
-    using RecordsOrError = Expected<Vector<Record>, Error>;
-    using RecordsCallback = Function<void(RecordsOrError&&)>;
-
-    using RecordIdentifiersOrError = Expected<Vector<uint64_t>, Error>;
-    using RecordIdentifiersCallback = Function<void(RecordIdentifiersOrError&&)>;
-
-    using CompletionCallback = Function<void(std::optional<Error>&&)>;
-
     void open(const String& origin, const String& cacheName, CacheIdentifierCallback&&);
     void remove(uint64_t cacheIdentifier, CacheIdentifierCallback&&);
     void retrieveCaches(const String& origin, CacheInfosCallback&&);
@@ -77,14 +54,7 @@ public:
     void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, RecordIdentifiersCallback&&);
 
 private:
-    static CacheStorageEngine& defaultEngine();
-
-    struct Cache {
-        uint64_t identifier;
-        String name;
-        Vector<Record> records;
-        uint64_t nextRecordIdentifier { 0 };
-    };
+    static Engine& defaultEngine();
 
     void writeCachesToDisk(CompletionCallback&&);
 
@@ -108,13 +78,6 @@ private:
     uint64_t m_nextCacheIdentifier { 0 };
 };
 
-}
+} // namespace CacheStorage
 
-namespace WTF {
-template<> struct EnumTraits<WebKit::CacheStorageEngine::Error> {
-    using values = EnumValues<
-        WebKit::CacheStorageEngine::Error,
-        WebKit::CacheStorageEngine::Error::Internal
-    >;
-};
-}
+} // namespace WebKit
diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h b/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h
new file mode 100644 (file)
index 0000000..1d8f119
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "CacheStorage.h"
+#include <wtf/Vector.h>
+#include <wtf/text/WTFString.h>
+
+namespace WebKit {
+
+namespace CacheStorage {
+
+struct Cache {
+    uint64_t identifier { 0 };
+    String name;
+    Vector<Record> records;
+    uint64_t nextRecordIdentifier { 0 };
+};
+
+} // namespace CacheStorage
+
+} // namespace WebKit
index ba50627..7fe29a1 100644 (file)
 
 #include "NetworkConnectionToWebProcess.h"
 #include "WebCacheStorageConnectionMessages.h"
-#include "WebCoreArgumentCoders.h"
 #include <WebCore/CacheQueryOptions.h>
 
+using namespace WebKit::CacheStorage;
+
 namespace WebKit {
 
 CacheStorageEngineConnection::CacheStorageEngineConnection(NetworkConnectionToWebProcess& connection)
@@ -41,42 +42,42 @@ CacheStorageEngineConnection::CacheStorageEngineConnection(NetworkConnectionToWe
 
 void CacheStorageEngineConnection::open(PAL::SessionID sessionID, uint64_t requestIdentifier, const String& origin, const String& cacheName)
 {
-    CacheStorageEngine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheStorageEngine::CacheIdentifierOrError&& result) {
+    Engine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::OpenCompleted(requestIdentifier, result), sessionID.sessionID());
     });
 }
 
 void CacheStorageEngineConnection::remove(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier)
 {
-    CacheStorageEngine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheStorageEngine::CacheIdentifierOrError&& result) {
+    Engine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::RemoveCompleted(requestIdentifier, result), sessionID.sessionID());
     });
 }
 
 void CacheStorageEngineConnection::caches(PAL::SessionID sessionID, uint64_t requestIdentifier, const String& origin)
 {
-    CacheStorageEngine::from(sessionID).retrieveCaches(origin, [protectedThis = makeRef(*this), this, sessionID, origin, requestIdentifier](CacheStorageEngine::CacheInfosOrError&& result) {
+    Engine::from(sessionID).retrieveCaches(origin, [protectedThis = makeRef(*this), this, sessionID, origin, requestIdentifier](CacheInfosOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::UpdateCaches(requestIdentifier, result), sessionID.sessionID());
     });
 }
 
 void CacheStorageEngineConnection::records(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier)
 {
-    CacheStorageEngine::from(sessionID).retrieveRecords(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, cacheIdentifier, requestIdentifier](CacheStorageEngine::RecordsOrError&& result) {
+    Engine::from(sessionID).retrieveRecords(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, cacheIdentifier, requestIdentifier](RecordsOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::UpdateRecords(requestIdentifier, result), sessionID.sessionID());
     });
 }
 
 void CacheStorageEngineConnection::deleteMatchingRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest&& request, WebCore::CacheQueryOptions&& options)
 {
-    CacheStorageEngine::from(sessionID).deleteMatchingRecords(cacheIdentifier, WTFMove(request), WTFMove(options), [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheStorageEngine::RecordIdentifiersOrError&& result) {
+    Engine::from(sessionID).deleteMatchingRecords(cacheIdentifier, WTFMove(request), WTFMove(options), [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::DeleteRecordsCompleted(requestIdentifier, result), sessionID.sessionID());
     });
 }
 
 void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records)
 {
-    CacheStorageEngine::from(sessionID).putRecords(cacheIdentifier, WTFMove(records), [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheStorageEngine::RecordIdentifiersOrError&& result) {
+    Engine::from(sessionID).putRecords(cacheIdentifier, WTFMove(records), [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::PutRecordsCompleted(requestIdentifier, result), sessionID.sessionID());
     });
 }
index f9ea9f4..6299b4b 100644 (file)
                41DC459E1E3DBDA100B11F51 /* WebRTCSocket.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC459D1E3DBCF000B11F51 /* WebRTCSocket.cpp */; };
                41DC459F1E3DBDA500B11F51 /* WebRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */; };
                41DC45A11E3DC53F00B11F51 /* WebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC45A01E3DC53C00B11F51 /* WebRTCResolver.cpp */; };
+               41FABD291F4DE001006A6C97 /* CacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD271F4DDFDC006A6C97 /* CacheStorage.h */; };
+               41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; };
                41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
                41FAF5F81E3C1021001AE678 /* LibWebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */; };
                41FAF5F91E3C1025001AE678 /* LibWebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FAF5F71E3C0B47001AE678 /* LibWebRTCResolver.cpp */; };
                517A530B1F479E3600DCDC0A /* WebSWServerConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A53071F479E3100DCDC0A /* WebSWServerConnection.h */; };
                517A530F1F47A86200DCDC0A /* WebSWClientConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */; };
                517A53101F47A86200DCDC0A /* WebSWClientConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */; };
-               517CF0E3163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */; };
                517CF0E3163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp */; };
+               517CF0E3163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */; };
                517CF0E3163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517CF0E1163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp */; };
                517CF0E4163A486C00C2950E /* NetworkProcessConnectionMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = 517CF0E2163A486C00C2950E /* NetworkProcessConnectionMessages.h */; };
                517DD5BE180DA7D30081660B /* StorageProcessProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 517DD5BC180DA7D30081660B /* StorageProcessProxy.cpp */; };
                41DC459A1E3DBB2400B11F51 /* LibWebRTCSocketClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCSocketClient.h; path = NetworkProcess/webrtc/LibWebRTCSocketClient.h; sourceTree = "<group>"; };
                41DC459D1E3DBCF000B11F51 /* WebRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCSocket.cpp; path = Network/webrtc/WebRTCSocket.cpp; sourceTree = "<group>"; };
                41DC45A01E3DC53C00B11F51 /* WebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCResolver.cpp; path = Network/webrtc/WebRTCResolver.cpp; sourceTree = "<group>"; };
+               41FABD271F4DDFDC006A6C97 /* CacheStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorage.h; sourceTree = "<group>"; };
+               41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCache.h; sourceTree = "<group>"; };
                41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTCSocket.h; path = Network/webrtc/WebRTCSocket.h; sourceTree = "<group>"; };
                41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTCResolver.h; path = Network/webrtc/WebRTCResolver.h; sourceTree = "<group>"; };
                41FAF5F61E3C0B47001AE678 /* LibWebRTCResolver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LibWebRTCResolver.h; path = Network/webrtc/LibWebRTCResolver.h; sourceTree = "<group>"; };
                517A530C1F479E9700DCDC0A /* WebSWClientConnection.messages.in */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebSWClientConnection.messages.in; sourceTree = "<group>"; };
                517A530D1F47A84300DCDC0A /* WebSWClientConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSWClientConnectionMessages.h; sourceTree = "<group>"; };
                517A530E1F47A84300DCDC0A /* WebSWClientConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSWClientConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
-               517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkProcessConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
                517CF0E1163A486C00C2950D /* WebCacheStorageConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebCacheStorageConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
+               517CF0E1163A486C00C2950E /* NetworkProcessConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkProcessConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
                517CF0E1163A486C00C2950F /* CacheStorageEngineConnectionMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CacheStorageEngineConnectionMessageReceiver.cpp; sourceTree = "<group>"; };
                517CF0E2163A486C00C2950E /* NetworkProcessConnectionMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NetworkProcessConnectionMessages.h; sourceTree = "<group>"; };
                517DD5BC180DA7D30081660B /* StorageProcessProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StorageProcessProxy.cpp; sourceTree = "<group>"; };
                E489D2821A0A2BE80078C06A /* cache */ = {
                        isa = PBXGroup;
                        children = (
+                               41FABD271F4DDFDC006A6C97 /* CacheStorage.h */,
                                41897ED61F415D860016FA42 /* CacheStorageEngine.cpp */,
                                41897ED21F415D850016FA42 /* CacheStorageEngine.h */,
+                               41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */,
                                41897ED31F415D850016FA42 /* CacheStorageEngineConnection.cpp */,
                                41897ED41F415D850016FA42 /* CacheStorageEngineConnection.h */,
                                41897ED51F415D850016FA42 /* CacheStorageEngineConnection.messages.in */,
                                4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */,
                                1A5705111BE410E600874AF1 /* BlockSPI.h in Headers */,
                                BC3065FA1259344E00E71278 /* CacheModel.h in Headers */,
+                               41FABD291F4DE001006A6C97 /* CacheStorage.h in Headers */,
                                41897ED81F415D8A0016FA42 /* CacheStorageEngine.h in Headers */,
+                               41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */,
                                41897EDA1F415D8A0016FA42 /* CacheStorageEngineConnection.h in Headers */,
                                1AA2E51D12E4C05E00BC4966 /* CGUtilities.h in Headers */,
                                1A2D956F12848564001EB962 /* ChildProcess.h in Headers */,
index 29dbb64..5c282be 100644 (file)
@@ -34,6 +34,8 @@
 #include "WebProcess.h"
 #include <wtf/MainThread.h>
 
+using namespace WebKit::CacheStorage;
+
 namespace WebKit {
 
 WebCacheStorageConnection::WebCacheStorageConnection(WebCacheStorageProvider& provider, PAL::SessionID sessionID)
@@ -82,32 +84,32 @@ void WebCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier,
     connection().send(Messages::CacheStorageEngineConnection::PutRecords(m_sessionID, requestIdentifier, cacheIdentifier, records), 0);
 }
 
-void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, CacheStorageEngine::CacheIdentifierOrError&& result)
+void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
 {
     CacheStorageConnection::openCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
 }
 
-void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, CacheStorageEngine::CacheIdentifierOrError&& result)
+void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
 {
     CacheStorageConnection::removeCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
 }
 
-void WebCacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheStorageEngine::CacheInfosOrError&& result)
+void WebCacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheInfosOrError&& result)
 {
     CacheStorageConnection::updateCaches(requestIdentifier, result.hasValue() ? result.value() : Vector<CacheInfo>());
 }
 
-void WebCacheStorageConnection::updateRecords(uint64_t requestIdentifier, CacheStorageEngine::RecordsOrError&& result)
+void WebCacheStorageConnection::updateRecords(uint64_t requestIdentifier, RecordsOrError&& result)
 {
     CacheStorageConnection::updateRecords(requestIdentifier, result.hasValue() ? WTFMove(result.value()) : Vector<Record>());
 }
 
-void WebCacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, CacheStorageEngine::RecordIdentifiersOrError&& result)
+void WebCacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, RecordIdentifiersOrError&& result)
 {
     CacheStorageConnection::deleteRecordsCompleted(requestIdentifier, result.hasValue() ? result.value() : Vector<uint64_t>(), !result.hasValue() ? Error::Internal : Error::None);
 }
 
-void WebCacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, CacheStorageEngine::RecordIdentifiersOrError&& result)
+void WebCacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, RecordIdentifiersOrError&& result)
 {
     CacheStorageConnection::putRecordsCompleted(requestIdentifier, result.hasValue() ? result.value() : Vector<uint64_t>(), !result.hasValue() ? Error::Internal : Error::None);
 }
index 864129f..73c1d37 100644 (file)
 
 #pragma once
 
-#include "CacheStorageEngine.h"
+#include "CacheStorage.h"
 #include <WebCore/CacheStorageConnection.h>
 #include <wtf/HashMap.h>
 
 namespace IPC {
+class Connection;
 class Decoder;
 class Encoder;
 }
@@ -60,13 +61,13 @@ private:
     void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, const WebCore::ResourceRequest&, WebCore::CacheQueryOptions&&) final;
     void doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&&) final;
 
-    void openCompleted(uint64_t requestIdentifier, CacheStorageEngine::CacheIdentifierOrError&&);
-    void removeCompleted(uint64_t requestIdentifier, CacheStorageEngine::CacheIdentifierOrError&&);
-    void updateCaches(uint64_t requestIdentifier, CacheStorageEngine::CacheInfosOrError&&);
+    void openCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
+    void removeCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
+    void updateCaches(uint64_t requestIdentifier, CacheStorage::CacheInfosOrError&&);
 
-    void updateRecords(uint64_t requestIdentifier, CacheStorageEngine::RecordsOrError&&);
-    void deleteRecordsCompleted(uint64_t requestIdentifier, CacheStorageEngine::RecordIdentifiersOrError&&);
-    void putRecordsCompleted(uint64_t requestIdentifier, CacheStorageEngine::RecordIdentifiersOrError&&);
+    void updateRecords(uint64_t requestIdentifier, CacheStorage::RecordsOrError&&);
+    void deleteRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
+    void putRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
 
     WebCacheStorageProvider& m_provider;
     PAL::SessionID m_sessionID;
index 8744e76..d30863f 100644 (file)
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebCacheStorageConnection {
-    OpenCompleted(uint64_t requestIdentifier, WebKit::CacheStorageEngine::CacheIdentifierOrError result);
-    RemoveCompleted(uint64_t requestIdentifier, WebKit::CacheStorageEngine::CacheIdentifierOrError result);
-    UpdateCaches(uint64_t requestIdentifier, WebKit::CacheStorageEngine::CacheInfosOrError result);
+    OpenCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
+    RemoveCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
+    UpdateCaches(uint64_t requestIdentifier, WebKit::CacheStorage::CacheInfosOrError result);
 
-    UpdateRecords(uint64_t requestIdentifier, WebKit::CacheStorageEngine::RecordsOrError result);
-    DeleteRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorageEngine::RecordIdentifiersOrError result);
-    PutRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorageEngine::RecordIdentifiersOrError result);
+    UpdateRecords(uint64_t requestIdentifier, WebKit::CacheStorage::RecordsOrError result);
+    DeleteRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::RecordIdentifiersOrError result);
+    PutRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::RecordIdentifiersOrError result);
 }