[Cache API] Unify WebCore and WebKit error handling
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 22:33:15 +0000 (22:33 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Aug 2017 22:33:15 +0000 (22:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175902

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

Source/WebCore:

No change of behavior.

Introducing a DOMCache namespace enclosing structures, callbacks and function definitions
previously found in either WebCore::CacheStorageConnection or WebKit::CacheStorage.

Some previously used callbacks had no way to pass errors in WebCore while they had in WebKit.
Updated Cache, CacheStorage, CacheStorageConnection and WorkerCacheStorageConnection to deal with these potential errors.

* CMakeLists.txt:
* Modules/cache/Cache.cpp:
(WebCore::FetchTasksHandler::FetchTasksHandler):
(WebCore::FetchTasksHandler::records const):
(WebCore::FetchTasksHandler::addRecord):
(WebCore::Cache::addAll):
(WebCore::Cache::put):
(WebCore::Cache::retrieveRecords):
(WebCore::queryCacheMatch):
(WebCore::Cache::batchDeleteOperation):
(WebCore::toConnectionRecord):
(WebCore::Cache::batchPutOperation):
(WebCore::Cache::updateRecords):
* Modules/cache/Cache.h:
* Modules/cache/CacheStorage.cpp:
(WebCore::CacheStorage::retrieveCaches):
(WebCore::CacheStorage::open):
(WebCore::CacheStorage::remove):
* Modules/cache/CacheStorage.h:
* Modules/cache/CacheStorageConnection.cpp:
(WebCore::CacheStorageConnection::open):
(WebCore::CacheStorageConnection::remove):
(WebCore::CacheStorageConnection::retrieveCaches):
(WebCore::CacheStorageConnection::batchDeleteOperation):
(WebCore::CacheStorageConnection::batchPutOperation):
(WebCore::CacheStorageConnection::openOrRemoveCompleted):
(WebCore::CacheStorageConnection::updateCaches):
(WebCore::CacheStorageConnection::updateRecords):
(WebCore::CacheStorageConnection::deleteRecordsCompleted):
(WebCore::CacheStorageConnection::putRecordsCompleted):
* Modules/cache/CacheStorageConnection.h:
(WebCore::CacheStorageConnection::openCompleted):
(WebCore::CacheStorageConnection::removeCompleted):
(WebCore::CacheStorageConnection::doOpen):
(WebCore::CacheStorageConnection::doRemove):
(WebCore::CacheStorageConnection::doBatchDeleteOperation):
(WebCore::CacheStorageConnection::doBatchPutOperation):
* Modules/cache/WorkerCacheStorageConnection.cpp:
(WebCore::toCrossThreadRecordData):
(WebCore::fromCrossThreadRecordData):
(WebCore::WorkerCacheStorageConnection::doOpen):
(WebCore::WorkerCacheStorageConnection::doRemove):
(WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
(WebCore::recordsDataFromRecords):
(WebCore::recordsDataOrErrorFromRecords):
(WebCore::recordsFromRecordsData):
(WebCore::recordsOrErrorFromRecordsData):
(WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
(WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
(WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
* Modules/cache/DOMCache.cpp: Added.
* Modules/cache/DOMCache.h: Added.
* Modules/cache/WorkerCacheStorageConnection.h:
* WebCore.xcodeproj/project.pbxproj:

Source/WebKit:

Removing all callbacks and error definitions from WebKit
and reusing DOMCache ones instead.

* NetworkProcess/cache/CacheStorage.h: Removed.
* NetworkProcess/cache/CacheStorageEngine.cpp:
(WebKit::CacheStorage::Engine::caches const):
(WebKit::CacheStorage::Engine::queryCache):
* NetworkProcess/cache/CacheStorageEngine.h:
* NetworkProcess/cache/CacheStorageEngineCache.h:
* NetworkProcess/cache/CacheStorageEngineConnection.cpp:
(WebKit::CacheStorageEngineConnection::open):
(WebKit::CacheStorageEngineConnection::remove):
(WebKit::CacheStorageEngineConnection::putRecords):
* NetworkProcess/cache/CacheStorageEngineConnection.h:
* NetworkProcess/cache/CacheStorageEngineConnection.messages.in:
* Shared/WebCoreArgumentCoders.cpp:
(IPC::ArgumentCoder<DOMCache::CacheInfo>::encode):
(IPC::ArgumentCoder<DOMCache::CacheInfo>::decode):
(IPC::ArgumentCoder<DOMCache::Record>::encode):
(IPC::ArgumentCoder<DOMCache::Record>::decode):
* Shared/WebCoreArgumentCoders.h:
* WebProcess/Cache/WebCacheStorageConnection.cpp:
(WebKit::WebCacheStorageConnection::doBatchPutOperation):
(WebKit::WebCacheStorageConnection::openCompleted):
(WebKit::WebCacheStorageConnection::removeCompleted):
(WebKit::WebCacheStorageConnection::updateCaches):
(WebKit::WebCacheStorageConnection::updateRecords):
(WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
(WebKit::WebCacheStorageConnection::putRecordsCompleted):
* WebProcess/Cache/WebCacheStorageConnection.h:
* WebProcess/Cache/WebCacheStorageConnection.messages.in:

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

25 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/cache/Cache.cpp
Source/WebCore/Modules/cache/Cache.h
Source/WebCore/Modules/cache/CacheStorage.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.cpp
Source/WebCore/Modules/cache/CacheStorageConnection.h
Source/WebCore/Modules/cache/DOMCache.cpp [new file with mode: 0644]
Source/WebCore/Modules/cache/DOMCache.h [moved from Source/WebKit/NetworkProcess/cache/CacheStorage.h with 52% similarity]
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp
Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h
Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.messages.in
Source/WebKit/Shared/WebCoreArgumentCoders.cpp
Source/WebKit/Shared/WebCoreArgumentCoders.h
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 217ffd6..4daa9cb 100644 (file)
@@ -897,6 +897,7 @@ set(WebCore_SOURCES
     Modules/cache/Cache.cpp
     Modules/cache/CacheStorage.cpp
     Modules/cache/CacheStorageConnection.cpp
+    Modules/cache/DOMCache.cpp
     Modules/cache/DOMWindowCaches.cpp
     Modules/cache/WorkerCacheStorageConnection.cpp
     Modules/cache/WorkerGlobalScopeCaches.cpp
index 9c1631f..9fcca62 100644 (file)
@@ -1,3 +1,73 @@
+2017-08-23  Youenn Fablet  <youenn@apple.com>
+
+        [Cache API] Unify WebCore and WebKit error handling
+        https://bugs.webkit.org/show_bug.cgi?id=175902
+
+        Reviewed by Alex Christensen.
+
+        No change of behavior.
+
+        Introducing a DOMCache namespace enclosing structures, callbacks and function definitions
+        previously found in either WebCore::CacheStorageConnection or WebKit::CacheStorage.
+
+        Some previously used callbacks had no way to pass errors in WebCore while they had in WebKit.
+        Updated Cache, CacheStorage, CacheStorageConnection and WorkerCacheStorageConnection to deal with these potential errors.
+
+        * CMakeLists.txt:
+        * Modules/cache/Cache.cpp:
+        (WebCore::FetchTasksHandler::FetchTasksHandler):
+        (WebCore::FetchTasksHandler::records const):
+        (WebCore::FetchTasksHandler::addRecord):
+        (WebCore::Cache::addAll):
+        (WebCore::Cache::put):
+        (WebCore::Cache::retrieveRecords):
+        (WebCore::queryCacheMatch):
+        (WebCore::Cache::batchDeleteOperation):
+        (WebCore::toConnectionRecord):
+        (WebCore::Cache::batchPutOperation):
+        (WebCore::Cache::updateRecords):
+        * Modules/cache/Cache.h:
+        * Modules/cache/CacheStorage.cpp:
+        (WebCore::CacheStorage::retrieveCaches):
+        (WebCore::CacheStorage::open):
+        (WebCore::CacheStorage::remove):
+        * Modules/cache/CacheStorage.h:
+        * Modules/cache/CacheStorageConnection.cpp:
+        (WebCore::CacheStorageConnection::open):
+        (WebCore::CacheStorageConnection::remove):
+        (WebCore::CacheStorageConnection::retrieveCaches):
+        (WebCore::CacheStorageConnection::batchDeleteOperation):
+        (WebCore::CacheStorageConnection::batchPutOperation):
+        (WebCore::CacheStorageConnection::openOrRemoveCompleted):
+        (WebCore::CacheStorageConnection::updateCaches):
+        (WebCore::CacheStorageConnection::updateRecords):
+        (WebCore::CacheStorageConnection::deleteRecordsCompleted):
+        (WebCore::CacheStorageConnection::putRecordsCompleted):
+        * Modules/cache/CacheStorageConnection.h:
+        (WebCore::CacheStorageConnection::openCompleted):
+        (WebCore::CacheStorageConnection::removeCompleted):
+        (WebCore::CacheStorageConnection::doOpen):
+        (WebCore::CacheStorageConnection::doRemove):
+        (WebCore::CacheStorageConnection::doBatchDeleteOperation):
+        (WebCore::CacheStorageConnection::doBatchPutOperation):
+        * Modules/cache/WorkerCacheStorageConnection.cpp:
+        (WebCore::toCrossThreadRecordData):
+        (WebCore::fromCrossThreadRecordData):
+        (WebCore::WorkerCacheStorageConnection::doOpen):
+        (WebCore::WorkerCacheStorageConnection::doRemove):
+        (WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
+        (WebCore::recordsDataFromRecords):
+        (WebCore::recordsDataOrErrorFromRecords):
+        (WebCore::recordsFromRecordsData):
+        (WebCore::recordsOrErrorFromRecordsData):
+        (WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
+        (WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
+        (WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
+        * Modules/cache/DOMCache.cpp: Added.
+        * Modules/cache/DOMCache.h: Added.
+        * Modules/cache/WorkerCacheStorageConnection.h:
+        * WebCore.xcodeproj/project.pbxproj:
+
 2017-08-23  Yusuke Suzuki  <utatane.tea@gmail.com>
 
         [JSC] Optimize Map iteration with intrinsic
index d642314..366eb36 100644 (file)
 #include "ScriptExecutionContext.h"
 #include "URL.h"
 
+using namespace WebCore::DOMCache;
+
 namespace WebCore {
 
-static CacheStorageConnection::Record toConnectionRecord(const FetchRequest&, FetchResponse&, CacheStorageConnection::ResponseBody&&);
+static Record toConnectionRecord(const FetchRequest&, FetchResponse&, ResponseBody&&);
 
 Cache::Cache(ScriptExecutionContext& context, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&& connection)
     : ActiveDOMObject(&context)
@@ -135,7 +137,7 @@ static inline bool hasResponseVaryStarHeaderValue(const FetchResponse& response)
 
 class FetchTasksHandler : public RefCounted<FetchTasksHandler> {
 public:
-    explicit FetchTasksHandler(Function<void(ExceptionOr<Vector<CacheStorageConnection::Record>>&&)>&& callback)
+    explicit FetchTasksHandler(Function<void(ExceptionOr<Vector<Record>>&&)>&& callback)
         : m_callback(WTFMove(callback))
     {
     }
@@ -146,9 +148,9 @@ public:
             m_callback(WTFMove(m_records));
     }
 
-    const Vector<CacheStorageConnection::Record>& records() const { return m_records; }
+    const Vector<Record>& records() const { return m_records; }
 
-    size_t addRecord(CacheStorageConnection::Record&& record)
+    size_t addRecord(Record&& record)
     {
         ASSERT(!isDone());
         m_records.append(WTFMove(record));
@@ -170,8 +172,8 @@ public:
     }
 
 private:
-    Vector<CacheStorageConnection::Record> m_records;
-    Function<void(ExceptionOr<Vector<CacheStorageConnection::Record>>&&)> m_callback;
+    Vector<Record> m_records;
+    Function<void(ExceptionOr<Vector<Record>>&&)> m_callback;
 };
 
 ExceptionOr<Ref<FetchRequest>> Cache::requestFromInfo(RequestInfo&& info, bool ignoreMethod)
@@ -207,7 +209,7 @@ void Cache::addAll(Vector<RequestInfo>&& infos, DOMPromiseDeferred<void>&& promi
         requests.uncheckedAppend(requestOrException.releaseReturnValue());
     }
 
-    auto taskHandler = adoptRef(*new FetchTasksHandler([protectedThis = makeRef(*this), this, promise = WTFMove(promise)](ExceptionOr<Vector<CacheStorageConnection::Record>>&& result) mutable {
+    auto taskHandler = adoptRef(*new FetchTasksHandler([protectedThis = makeRef(*this), this, promise = WTFMove(promise)](ExceptionOr<Vector<Record>>&& result) mutable {
         if (result.hasException()) {
             promise.reject(result.releaseException());
             return;
@@ -248,7 +250,7 @@ void Cache::addAll(Vector<RequestInfo>&& infos, DOMPromiseDeferred<void>&& promi
 
             CacheQueryOptions options;
             for (const auto& record : taskHandler->records()) {
-                if (CacheStorageConnection::queryCacheMatch(request->resourceRequest(), record.request, record.response, options)) {
+                if (DOMCache::queryCacheMatch(request->resourceRequest(), record.request, record.response, options)) {
                     taskHandler->error(Exception { InvalidStateError, ASCIILiteral("addAll cannot store several matching requests")});
                     return;
                 }
@@ -310,7 +312,7 @@ void Cache::put(RequestInfo&& info, Ref<FetchResponse>&& response, DOMPromiseDef
             if (result.hasException())
                 promise.reject(result.releaseException());
             else {
-                CacheStorageConnection::ResponseBody body;
+                DOMCache::ResponseBody body;
                 if (auto buffer = result.releaseReturnValue())
                     body = buffer.releaseNonNull();
                 batchPutOperation(request.get(), response.get(), WTFMove(body), [promise = WTFMove(promise)](ExceptionOr<void>&& result) mutable {
@@ -381,9 +383,12 @@ void Cache::keys(std::optional<RequestInfo>&& info, CacheQueryOptions&& options,
 void Cache::retrieveRecords(WTF::Function<void()>&& callback)
 {
     setPendingActivity(this);
-    m_connection->retrieveRecords(m_identifier, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::Record>&& records) {
+    m_connection->retrieveRecords(m_identifier, [this, callback = WTFMove(callback)](RecordsOrError&& result) {
         if (!m_isStopped) {
-            updateRecords(WTFMove(records));
+            // FIXME: We should probably propagate that error up to the promise based operation.
+            ASSERT(result.hasValue());
+            if (result.hasValue())
+                updateRecords(WTFMove(result.value()));
             callback();
         }
         unsetPendingActivity(this);
@@ -400,7 +405,7 @@ void Cache::queryCache(Ref<FetchRequest>&& request, CacheQueryOptions&& options,
 static inline bool queryCacheMatch(const FetchRequest& request, const FetchRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
 {
     // We need to pass the resource request with all correct headers hence why we call resourceRequest().
-    return CacheStorageConnection::queryCacheMatch(request.resourceRequest(), cachedRequest.resourceRequest(), cachedResponse, options);
+    return DOMCache::queryCacheMatch(request.resourceRequest(), cachedRequest.resourceRequest(), cachedResponse, options);
 }
 
 Vector<CacheStorageRecord> Cache::queryCacheWithTargetStorage(const FetchRequest& request, const CacheQueryOptions& options, const Vector<CacheStorageRecord>& targetStorage)
@@ -419,15 +424,18 @@ Vector<CacheStorageRecord> Cache::queryCacheWithTargetStorage(const FetchRequest
 void Cache::batchDeleteOperation(const FetchRequest& request, CacheQueryOptions&& options, WTF::Function<void(ExceptionOr<bool>&&)>&& callback)
 {
     setPendingActivity(this);
-    m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](Vector<uint64_t>&& records, CacheStorageConnection::Error error) {
-        if (!m_isStopped)
-            callback(CacheStorageConnection::exceptionOrResult(!records.isEmpty(), error));
-
+    m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
+        if (!m_isStopped) {
+            if (!result.hasValue())
+                callback(DOMCache::errorToException(result.error()));
+            else
+                callback(!result.value().isEmpty());
+        }
         unsetPendingActivity(this);
     });
 }
 
-CacheStorageConnection::Record toConnectionRecord(const FetchRequest& request, FetchResponse& response, CacheStorageConnection::ResponseBody&& responseBody)
+Record toConnectionRecord(const FetchRequest& request, FetchResponse& response, DOMCache::ResponseBody&& responseBody)
 {
     // FIXME: Add a setHTTPHeaderFields on ResourceResponseBase.
     ResourceResponse cachedResponse = response.resourceResponse();
@@ -446,26 +454,29 @@ CacheStorageConnection::Record toConnectionRecord(const FetchRequest& request, F
     };
 }
 
-void Cache::batchPutOperation(const FetchRequest& request, FetchResponse& response, CacheStorageConnection::ResponseBody&& responseBody, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
+void Cache::batchPutOperation(const FetchRequest& request, FetchResponse& response, DOMCache::ResponseBody&& responseBody, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
 {
-    Vector<CacheStorageConnection::Record> records;
+    Vector<Record> records;
     records.append(toConnectionRecord(request, response, WTFMove(responseBody)));
 
     batchPutOperation(WTFMove(records), WTFMove(callback));
 }
 
-void Cache::batchPutOperation(Vector<CacheStorageConnection::Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
+void Cache::batchPutOperation(Vector<Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
 {
     setPendingActivity(this);
-    m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](Vector<uint64_t>&&, CacheStorageConnection::Error error) {
-        if (!m_isStopped)
-            callback(CacheStorageConnection::errorToException(error));
-
+    m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
+        if (!m_isStopped) {
+            if (!result.hasValue())
+                callback(DOMCache::errorToException(result.error()));
+            else
+                callback({ });
+        }
         unsetPendingActivity(this);
     });
 }
 
-void Cache::updateRecords(Vector<CacheStorageConnection::Record>&& records)
+void Cache::updateRecords(Vector<Record>&& records)
 {
     ASSERT(scriptExecutionContext());
     Vector<CacheStorageRecord> newRecords;
index efb34bb..27c55c2 100644 (file)
@@ -73,10 +73,10 @@ private:
     Vector<CacheStorageRecord> queryCacheWithTargetStorage(const FetchRequest&, const CacheQueryOptions&, const Vector<CacheStorageRecord>&);
     void queryCache(Ref<FetchRequest>&&, CacheQueryOptions&&, WTF::Function<void(const Vector<CacheStorageRecord>&)>&&);
     void batchDeleteOperation(const FetchRequest&, CacheQueryOptions&&, WTF::Function<void(ExceptionOr<bool>&&)>&&);
-    void batchPutOperation(const FetchRequest&, FetchResponse&, CacheStorageConnection::ResponseBody&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
-    void batchPutOperation(Vector<CacheStorageConnection::Record>&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
+    void batchPutOperation(const FetchRequest&, FetchResponse&, DOMCache::ResponseBody&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
+    void batchPutOperation(Vector<DOMCache::Record>&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
 
-    void updateRecords(Vector<CacheStorageConnection::Record>&&);
+    void updateRecords(Vector<DOMCache::Record>&&);
 
     String m_name;
     uint64_t m_identifier;
index ed808fd..7edce64 100644 (file)
@@ -31,6 +31,8 @@
 #include "JSFetchResponse.h"
 #include "ScriptExecutionContext.h"
 
+using namespace WebCore::DOMCache;
+
 namespace WebCore {
 
 CacheStorage::CacheStorage(ScriptExecutionContext& context, Ref<CacheStorageConnection>&& connection)
@@ -117,8 +119,16 @@ void CacheStorage::retrieveCaches(WTF::Function<void()>&& callback)
         return;
 
     setPendingActivity(this);
-    m_connection->retrieveCaches(origin, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::CacheInfo>&& cachesInfo) {
+    m_connection->retrieveCaches(origin, [this, callback = WTFMove(callback)](CacheInfosOrError&& result) {
         if (!m_isStopped) {
+            // FIXME: We should probably propagate that error up to the promise based operation.
+            ASSERT(result.hasValue());
+            if (!result.hasValue()) {
+                callback();
+                return;
+            }
+            auto& cachesInfo = result.value();
+
             ASSERT(scriptExecutionContext());
             m_caches.removeAllMatching([&](auto& cache) {
                 return cachesInfo.findMatching([&](const auto& info) { return info.identifier == cache->identifier(); }) == notFound;
@@ -152,13 +162,13 @@ void CacheStorage::open(const String& name, DOMPromiseDeferred<IDLInterface<Cach
         ASSERT(!origin.isNull());
 
         setPendingActivity(this);
-        m_connection->open(origin, name, [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
+        m_connection->open(origin, name, [this, name, promise = WTFMove(promise)](const CacheIdentifierOrError& result) mutable {
             if (!m_isStopped) {
-                auto result = CacheStorageConnection::errorToException(error);
-                if (result.hasException())
-                    promise.reject(result.releaseException());
+
+                if (!result.hasValue())
+                    promise.reject(DOMCache::errorToException(result.error()));
                 else {
-                    auto cache = Cache::create(*scriptExecutionContext(), String { name }, cacheIdentifier, m_connection.copyRef());
+                    auto cache = Cache::create(*scriptExecutionContext(), String { name }, result.value(), m_connection.copyRef());
                     promise.resolve(cache);
                     m_caches.append(WTFMove(cache));
                 }
@@ -181,11 +191,13 @@ void CacheStorage::remove(const String& name, DOMPromiseDeferred<IDLBoolean>&& p
         ASSERT(!origin.isNull());
 
         setPendingActivity(this);
-        m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
-            UNUSED_PARAM(cacheIdentifier);
-            if (!m_isStopped)
-                promise.settle(CacheStorageConnection::exceptionOrResult(true, error));
-
+        m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise)](const CacheIdentifierOrError& result) mutable {
+            if (!m_isStopped) {
+                if (!result.hasValue())
+                    promise.reject(DOMCache::errorToException(result.error()));
+                else
+                    promise.resolve(true);
+            }
             unsetPendingActivity(this);
         });
         m_caches.remove(position);
index 3157fc3..8a892df 100644 (file)
 #include "config.h"
 #include "CacheStorageConnection.h"
 
-#include "CacheQueryOptions.h"
-#include "Exception.h"
-#include "HTTPParsers.h"
+using namespace WebCore::DOMCache;
 
 namespace WebCore {
 
-ExceptionOr<void> CacheStorageConnection::errorToException(Error error)
-{
-    switch (error) {
-    case Error::None:
-        return { };
-    case Error::NotImplemented:
-        return Exception { NotSupportedError, ASCIILiteral("Not implemented") };
-    default:
-        return Exception { NotSupportedError, ASCIILiteral("Internal error") };
-    }
-}
-
-bool CacheStorageConnection::queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
-{
-    ASSERT(options.ignoreMethod || request.httpMethod() == "GET");
-
-    URL requestURL = request.url();
-    URL cachedRequestURL = cachedRequest.url();
-
-    if (options.ignoreSearch) {
-        requestURL.setQuery({ });
-        cachedRequestURL.setQuery({ });
-    }
-    if (!equalIgnoringFragmentIdentifier(requestURL, cachedRequestURL))
-        return false;
-
-    if (options.ignoreVary)
-        return true;
-
-    String varyValue = cachedResponse.httpHeaderField(WebCore::HTTPHeaderName::Vary);
-    if (varyValue.isNull())
-        return true;
-
-    // FIXME: This is inefficient, we should be able to split and trim whitespaces at the same time.
-    Vector<String> varyHeaderNames;
-    varyValue.split(',', false, varyHeaderNames);
-    for (auto& name : varyHeaderNames) {
-        if (stripLeadingAndTrailingHTTPSpaces(name) == "*")
-            return false;
-        if (cachedRequest.httpHeaderField(name) != request.httpHeaderField(name))
-            return false;
-    }
-    return true;
-}
-
-void CacheStorageConnection::open(const String& origin, const String& cacheName, OpenRemoveCallback&& callback)
+void CacheStorageConnection::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     m_openAndRemoveCachePendingRequests.add(requestIdentifier, WTFMove(callback));
@@ -86,7 +39,7 @@ void CacheStorageConnection::open(const String& origin, const String& cacheName,
     doOpen(requestIdentifier, origin, cacheName);
 }
 
-void CacheStorageConnection::remove(uint64_t cacheIdentifier, OpenRemoveCallback&& callback)
+void CacheStorageConnection::remove(uint64_t cacheIdentifier, CacheIdentifierCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     m_openAndRemoveCachePendingRequests.add(requestIdentifier, WTFMove(callback));
@@ -94,7 +47,7 @@ void CacheStorageConnection::remove(uint64_t cacheIdentifier, OpenRemoveCallback
     doRemove(requestIdentifier, cacheIdentifier);
 }
 
-void CacheStorageConnection::retrieveCaches(const String& origin, CachesCallback&& callback)
+void CacheStorageConnection::retrieveCaches(const String& origin, CacheInfosCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     m_retrieveCachesPendingRequests.add(requestIdentifier, WTFMove(callback));
@@ -110,7 +63,7 @@ void CacheStorageConnection::retrieveRecords(uint64_t cacheIdentifier, RecordsCa
     doRetrieveRecords(requestIdentifier, cacheIdentifier);
 }
 
-void CacheStorageConnection::batchDeleteOperation(uint64_t cacheIdentifier, const WebCore::ResourceRequest& request, WebCore::CacheQueryOptions&& options, BatchOperationCallback&& callback)
+void CacheStorageConnection::batchDeleteOperation(uint64_t cacheIdentifier, const ResourceRequest& request, CacheQueryOptions&& options, RecordIdentifiersCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     m_batchDeleteAndPutPendingRequests.add(requestIdentifier, WTFMove(callback));
@@ -118,7 +71,7 @@ void CacheStorageConnection::batchDeleteOperation(uint64_t cacheIdentifier, cons
     doBatchDeleteOperation(requestIdentifier, cacheIdentifier, request, WTFMove(options));
 }
 
-void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records, BatchOperationCallback&& callback)
+void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<Record>&& records, RecordIdentifiersCallback&& callback)
 {
     uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     m_batchDeleteAndPutPendingRequests.add(requestIdentifier, WTFMove(callback));
@@ -126,61 +79,34 @@ void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<
     doBatchPutOperation(requestIdentifier, cacheIdentifier, WTFMove(records));
 }
 
-void CacheStorageConnection::openOrRemoveCompleted(uint64_t requestIdentifier, uint64_t cacheIdentifier, Error error)
+void CacheStorageConnection::openOrRemoveCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
 {
     if (auto callback = m_openAndRemoveCachePendingRequests.take(requestIdentifier))
-        callback(cacheIdentifier, error);
+        callback(result);
 }
 
-void CacheStorageConnection::updateCaches(uint64_t requestIdentifier, Vector<CacheInfo>&& caches)
+void CacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheInfosOrError&& result)
 {
     if (auto callback = m_retrieveCachesPendingRequests.take(requestIdentifier))
-        callback(WTFMove(caches));
+        callback(WTFMove(result));
 }
 
-void CacheStorageConnection::updateRecords(uint64_t requestIdentifier, Vector<Record>&& records)
+void CacheStorageConnection::updateRecords(uint64_t requestIdentifier, RecordsOrError&& result)
 {
     if (auto callback = m_retrieveRecordsPendingRequests.take(requestIdentifier))
-        callback(WTFMove(records));
+        callback(WTFMove(result));
 }
 
-void CacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&& records, Error error)
+void CacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, Expected<Vector<uint64_t>, Error>&& result)
 {
     if (auto callback = m_batchDeleteAndPutPendingRequests.take(requestIdentifier))
-        callback(WTFMove(records), error);
+        callback(WTFMove(result));
 }
 
-void CacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&& records, Error error)
+void CacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, Expected<Vector<uint64_t>, Error>&& result)
 {
     if (auto callback = m_batchDeleteAndPutPendingRequests.take(requestIdentifier))
-        callback(WTFMove(records), error);
-}
-
-CacheStorageConnection::ResponseBody CacheStorageConnection::isolatedResponseBody(const ResponseBody& body)
-{
-    return WTF::switchOn(body, [](const Ref<FormData>& formData) {
-        return formData->isolatedCopy();
-    }, [](const Ref<SharedBuffer>& buffer) {
-        return buffer->copy();
-    }, [](const std::nullptr_t&) {
-        return CacheStorageConnection::ResponseBody { };
-    });
-}
-
-static inline CacheStorageConnection::ResponseBody copyResponseBody(const CacheStorageConnection::ResponseBody& body)
-{
-    return WTF::switchOn(body, [](const Ref<FormData>& formData) {
-        return formData.copyRef();
-    }, [](const Ref<SharedBuffer>& buffer) {
-        return buffer.copyRef();
-    }, [](const std::nullptr_t&) {
-        return CacheStorageConnection::ResponseBody { };
-    });
-}
-
-CacheStorageConnection::Record CacheStorageConnection::Record::copy() const
-{
-    return Record { identifier, updateResponseCounter, requestHeadersGuard, request, options, referrer, responseHeadersGuard, response, copyResponseBody(responseBody) };
+        callback(WTFMove(result));
 }
 
 } // namespace WebCore
index 723616c..f2080dc 100644 (file)
 
 #pragma once
 
-#include "FetchHeaders.h"
-#include "FetchOptions.h"
-#include "ResourceRequest.h"
-#include "ResourceResponse.h"
-#include "SharedBuffer.h"
+#include "DOMCache.h"
 #include <wtf/HashMap.h>
 #include <wtf/ThreadSafeRefCounted.h>
 
 namespace WebCore {
 
-struct CacheQueryOptions;
-
 class CacheStorageConnection : public ThreadSafeRefCounted<CacheStorageConnection> {
 public:
     static Ref<CacheStorageConnection> create() { return adoptRef(*new CacheStorageConnection()); }
     virtual ~CacheStorageConnection() = default;
 
-    enum class Error {
-        None,
-        NotImplemented,
-        Internal
-    };
-
-    static ExceptionOr<void> errorToException(Error);
-    template<typename T> static ExceptionOr<T> exceptionOrResult(T&& value, Error error)
-    {
-        auto result = errorToException(error);
-        if (result.hasException())
-            return result.releaseException();
-        return std::forward<T>(value);
-    }
-
-    WEBCORE_EXPORT static bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
-
-    using ResponseBody = Variant<std::nullptr_t, Ref<FormData>, Ref<SharedBuffer>>;
-    static ResponseBody isolatedResponseBody(const ResponseBody&);
-
-    struct Record {
-        WEBCORE_EXPORT Record copy() const;
-
-        uint64_t identifier;
-        uint64_t updateResponseCounter;
-
-        FetchHeaders::Guard requestHeadersGuard;
-        ResourceRequest request;
-        FetchOptions options;
-        String referrer;
+    void open(const String& origin, const String& cacheName, DOMCache::CacheIdentifierCallback&&);
+    void remove(uint64_t cacheIdentifier, DOMCache::CacheIdentifierCallback&&);
+    void retrieveCaches(const String& origin, DOMCache::CacheInfosCallback&&);
 
-        FetchHeaders::Guard responseHeadersGuard;
-        ResourceResponse response;
-        ResponseBody responseBody;
-    };
-
-    struct CacheInfo {
-        uint64_t identifier;
-        String name;
-    };
-
-    using OpenRemoveCallback = WTF::Function<void(uint64_t, Error)>;
-    using CachesCallback = WTF::Function<void(Vector<CacheInfo>&&)>;
-    using RecordsCallback = WTF::Function<void(Vector<Record>&&)>;
-    using BatchOperationCallback = WTF::Function<void(Vector<uint64_t>&&, Error)>;
-
-    void open(const String& /* origin */, const String& /* cacheName */, OpenRemoveCallback&&);
-    void remove(uint64_t /* cacheIdentifier */, OpenRemoveCallback&&);
-    void retrieveCaches(const String& /* origin */, CachesCallback&&);
-
-    void retrieveRecords(uint64_t /* cacheIdentifier */, RecordsCallback&&);
-    void batchDeleteOperation(uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&, BatchOperationCallback&&);
-    void batchPutOperation(uint64_t /* cacheIdentifier */, Vector<Record>&&, BatchOperationCallback&&);
+    void retrieveRecords(uint64_t cacheIdentifier, DOMCache::RecordsCallback&&);
+    void batchDeleteOperation(uint64_t cacheIdentifier, const ResourceRequest&, CacheQueryOptions&&, DOMCache::RecordIdentifiersCallback&&);
+    void batchPutOperation(uint64_t cacheIdentifier, Vector<DOMCache::Record>&&, DOMCache::RecordIdentifiersCallback&&);
 
 protected:
     CacheStorageConnection() =  default;
 
-    void openCompleted(uint64_t identifier, uint64_t cacheIdentifier, Error error) { openOrRemoveCompleted(identifier, cacheIdentifier, error); }
-    void removeCompleted(uint64_t identifier, uint64_t cacheIdentifier, Error error) { openOrRemoveCompleted(identifier, cacheIdentifier, error); }
-    WEBCORE_EXPORT void updateCaches(uint64_t requestIdentifier, Vector<CacheInfo>&&);
+    void openCompleted(uint64_t identifier, const DOMCache::CacheIdentifierOrError& result) { openOrRemoveCompleted(identifier, result); }
+    void removeCompleted(uint64_t identifier, const DOMCache::CacheIdentifierOrError& result) { openOrRemoveCompleted(identifier, result); }
+    WEBCORE_EXPORT void updateCaches(uint64_t requestIdentifier, DOMCache::CacheInfosOrError&&);
 
-    WEBCORE_EXPORT void updateRecords(uint64_t requestIdentifier, Vector<Record>&&);
-    WEBCORE_EXPORT void deleteRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&&, Error);
-    WEBCORE_EXPORT void putRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&&, Error);
+    WEBCORE_EXPORT void updateRecords(uint64_t requestIdentifier, DOMCache::RecordsOrError&&);
+    WEBCORE_EXPORT void deleteRecordsCompleted(uint64_t requestIdentifier, DOMCache::RecordIdentifiersOrError&&);
+    WEBCORE_EXPORT void putRecordsCompleted(uint64_t requestIdentifier, DOMCache::RecordIdentifiersOrError&&);
 
 private:
-    virtual void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) { openCompleted(requestIdentifier, 0, Error::NotImplemented); }
-    virtual void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { removeCompleted(requestIdentifier, 0, Error::NotImplemented); }
+    virtual void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) { openCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
+    virtual void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { removeCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
     virtual void doRetrieveCaches(uint64_t requestIdentifier, const String& /* origin */) { updateCaches(requestIdentifier, { }); }
 
     virtual void doRetrieveRecords(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { updateRecords(requestIdentifier, { }); }
-    virtual void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&) { deleteRecordsCompleted(requestIdentifier, { }, Error::NotImplemented); }
-    virtual void doBatchPutOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, Vector<Record>&&) { putRecordsCompleted(requestIdentifier, { }, Error::NotImplemented); }
+    virtual void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&) { deleteRecordsCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
+    virtual void doBatchPutOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, Vector<DOMCache::Record>&&) { putRecordsCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
 
-    WEBCORE_EXPORT void openOrRemoveCompleted(uint64_t requestIdentifier, uint64_t cacheIdentifier, Error);
+    WEBCORE_EXPORT void openOrRemoveCompleted(uint64_t requestIdentifier, const DOMCache::CacheIdentifierOrError&);
 
-    HashMap<uint64_t, OpenRemoveCallback> m_openAndRemoveCachePendingRequests;
-    HashMap<uint64_t, CachesCallback> m_retrieveCachesPendingRequests;
-    HashMap<uint64_t, RecordsCallback> m_retrieveRecordsPendingRequests;
-    HashMap<uint64_t, BatchOperationCallback> m_batchDeleteAndPutPendingRequests;
+    HashMap<uint64_t, DOMCache::CacheIdentifierCallback> m_openAndRemoveCachePendingRequests;
+    HashMap<uint64_t, DOMCache::CacheInfosCallback> m_retrieveCachesPendingRequests;
+    HashMap<uint64_t, DOMCache::RecordsCallback> m_retrieveRecordsPendingRequests;
+    HashMap<uint64_t, DOMCache::RecordIdentifiersCallback> m_batchDeleteAndPutPendingRequests;
 
     uint64_t m_lastRequestIdentifier { 0 };
 };
-
 } // namespace WebCore
-
diff --git a/Source/WebCore/Modules/cache/DOMCache.cpp b/Source/WebCore/Modules/cache/DOMCache.cpp
new file mode 100644 (file)
index 0000000..33da808
--- /dev/null
@@ -0,0 +1,111 @@
+
+/*
+ * 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.
+ */
+
+#include "config.h"
+#include "DOMCache.h"
+
+#include "CacheQueryOptions.h"
+#include "Exception.h"
+#include "HTTPParsers.h"
+
+namespace WebCore {
+
+namespace DOMCache {
+
+Exception errorToException(Error error)
+{
+    switch (error) {
+    case Error::NotImplemented:
+        return Exception { NotSupportedError, ASCIILiteral("Not implemented") };
+    default:
+        return Exception { TypeError, ASCIILiteral("Internal error") };
+    }
+}
+
+bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
+{
+    ASSERT(options.ignoreMethod || request.httpMethod() == "GET");
+
+    URL requestURL = request.url();
+    URL cachedRequestURL = cachedRequest.url();
+
+    if (options.ignoreSearch) {
+        requestURL.setQuery({ });
+        cachedRequestURL.setQuery({ });
+    }
+    if (!equalIgnoringFragmentIdentifier(requestURL, cachedRequestURL))
+        return false;
+
+    if (options.ignoreVary)
+        return true;
+
+    String varyValue = cachedResponse.httpHeaderField(WebCore::HTTPHeaderName::Vary);
+    if (varyValue.isNull())
+        return true;
+
+    // FIXME: This is inefficient, we should be able to split and trim whitespaces at the same time.
+    Vector<String> varyHeaderNames;
+    varyValue.split(',', false, varyHeaderNames);
+    for (auto& name : varyHeaderNames) {
+        if (stripLeadingAndTrailingHTTPSpaces(name) == "*")
+            return false;
+        if (cachedRequest.httpHeaderField(name) != request.httpHeaderField(name))
+            return false;
+    }
+    return true;
+}
+
+ResponseBody isolatedResponseBody(const ResponseBody& body)
+{
+    return WTF::switchOn(body, [](const Ref<FormData>& formData) {
+        return formData->isolatedCopy();
+    }, [](const Ref<SharedBuffer>& buffer) {
+        return buffer->copy();
+    }, [](const std::nullptr_t&) {
+        return DOMCache::ResponseBody { };
+    });
+}
+
+static inline ResponseBody copyResponseBody(const DOMCache::ResponseBody& body)
+{
+    return WTF::switchOn(body, [](const Ref<FormData>& formData) {
+        return formData.copyRef();
+    }, [](const Ref<SharedBuffer>& buffer) {
+        return buffer.copyRef();
+    }, [](const std::nullptr_t&) {
+        return DOMCache::ResponseBody { };
+    });
+}
+
+Record Record::copy() const
+{
+    return Record { identifier, updateResponseCounter, requestHeadersGuard, request, options, referrer, responseHeadersGuard, response, copyResponseBody(responseBody) };
+}
+
+} // namespace DOMCache
+
+} // namespace WebCore
+
similarity index 52%
rename from Source/WebKit/NetworkProcess/cache/CacheStorage.h
rename to Source/WebCore/Modules/cache/DOMCache.h
index 874f671..98da811 100644 (file)
@@ -1,3 +1,4 @@
+
 /*
  * Copyright (C) 2017 Apple Inc. All rights reserved.
  *
 
 #pragma once
 
-#include "WebCoreArgumentCoders.h"
-#include <WebCore/CacheStorageConnection.h>
-#include <wtf/EnumTraits.h>
+#include "FetchHeaders.h"
+#include "FetchOptions.h"
+#include "ResourceRequest.h"
+#include "ResourceResponse.h"
+#include "SharedBuffer.h"
+
+namespace WebCore {
 
-namespace WebKit {
+struct CacheQueryOptions;
 
-namespace CacheStorage {
+namespace DOMCache {
 
 enum class Error {
+    NotImplemented,
     Internal
 };
 
-using Record = WebCore::CacheStorageConnection::Record;
+Exception errorToException(Error);
 
-using CacheIdentifierOrError = Expected<uint64_t, Error>;
-using CacheIdentifierCallback = Function<void(CacheIdentifierOrError&&)>;
+WEBCORE_EXPORT bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
 
-using CacheInfosOrError = Expected<Vector<WebCore::CacheStorageConnection::CacheInfo>, Error>;
-using CacheInfosCallback = Function<void(CacheInfosOrError&&)>;
+using ResponseBody = Variant<std::nullptr_t, Ref<FormData>, Ref<SharedBuffer>>;
+ResponseBody isolatedResponseBody(const ResponseBody&);
 
-using RecordsOrError = Expected<Vector<Record>, Error>;
-using RecordsCallback = Function<void(RecordsOrError&&)>;
+struct Record {
+    WEBCORE_EXPORT Record copy() const;
+
+    uint64_t identifier;
+    uint64_t updateResponseCounter;
+
+    FetchHeaders::Guard requestHeadersGuard;
+    ResourceRequest request;
+    FetchOptions options;
+    String referrer;
+
+    FetchHeaders::Guard responseHeadersGuard;
+    ResourceResponse response;
+    ResponseBody responseBody;
+};
+
+struct CacheInfo {
+    uint64_t identifier;
+    String name;
+};
+
+using CacheIdentifierOrError = Expected<uint64_t, Error>;
+using CacheIdentifierCallback = WTF::Function<void(const CacheIdentifierOrError&)>;
 
 using RecordIdentifiersOrError = Expected<Vector<uint64_t>, Error>;
-using RecordIdentifiersCallback = Function<void(RecordIdentifiersOrError&&)>;
+using RecordIdentifiersCallback = WTF::Function<void(RecordIdentifiersOrError&&)>;
+
+using CacheInfosOrError = Expected<Vector<WebCore::DOMCache::CacheInfo>, Error>;
+using CacheInfosCallback = WTF::Function<void(CacheInfosOrError&&)>;
+
+using RecordsOrError = Expected<Vector<Record>, Error>;
+using RecordsCallback = WTF::Function<void(RecordsOrError&&)>;
 
 using CompletionCallback = Function<void(std::optional<Error>&&)>;
 
-} // namespace CacheStorage
+} // namespace DOMCache
 
-} // namespace WebKit
+} // namespace WebCore
 
 namespace WTF {
-template<> struct EnumTraits<WebKit::CacheStorage::Error> {
+template<> struct EnumTraits<WebCore::DOMCache::Error> {
     using values = EnumValues<
-        WebKit::CacheStorage::Error,
-        WebKit::CacheStorage::Error::Internal
+        WebCore::DOMCache::Error,
+        WebCore::DOMCache::Error::NotImplemented,
+        WebCore::DOMCache::Error::Internal
     >;
 };
 }
index 10aa654..820994b 100644 (file)
@@ -36,6 +36,8 @@
 #include "WorkerRunLoop.h"
 #include "WorkerThread.h"
 
+using namespace WebCore::DOMCache;
+
 namespace WebCore {
 
 struct CrossThreadRecordData {
@@ -50,10 +52,10 @@ struct CrossThreadRecordData {
 
     FetchHeaders::Guard responseHeadersGuard;
     ResourceResponse::CrossThreadData response;
-    CacheStorageConnection::ResponseBody responseBody;
+    ResponseBody responseBody;
 };
 
-static CrossThreadRecordData toCrossThreadRecordData(const CacheStorageConnection::Record& record)
+static CrossThreadRecordData toCrossThreadRecordData(const Record& record)
 {
     return CrossThreadRecordData {
         record.identifier,
@@ -64,13 +66,13 @@ static CrossThreadRecordData toCrossThreadRecordData(const CacheStorageConnectio
         record.referrer.isolatedCopy(),
         record.responseHeadersGuard,
         record.response.crossThreadData(),
-        CacheStorageConnection::isolatedResponseBody(record.responseBody)
+        isolatedResponseBody(record.responseBody)
     };
 }
 
-static CacheStorageConnection::Record fromCrossThreadRecordData(CrossThreadRecordData&& data)
+static Record fromCrossThreadRecordData(CrossThreadRecordData&& data)
 {
-    return CacheStorageConnection::Record {
+    return Record {
         data.identifier,
         data.updateResponseCounter,
         data.requestHeadersGuard,
@@ -115,10 +117,10 @@ void WorkerCacheStorageConnection::doOpen(uint64_t requestIdentifier, const Stri
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->open(origin, cacheName, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](uint64_t cacheIdentifier, Error error) mutable {
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, error, cacheIdentifier, protectedThis = WTFMove(protectedThis), requestIdentifier](ScriptExecutionContext& context) mutable {
+        m_mainThreadConnection->open(origin, cacheName, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](const CacheIdentifierOrError& result) mutable {
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                openCompleted(requestIdentifier, cacheIdentifier, error);
+                openCompleted(requestIdentifier, result);
             }, m_taskMode);
         });
     });
@@ -130,11 +132,11 @@ void WorkerCacheStorageConnection::doRemove(uint64_t requestIdentifier, uint64_t
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->remove(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier](uint64_t removedCacheIdentifier, Error error) mutable {
-            ASSERT_UNUSED(removedCacheIdentifier, removedCacheIdentifier == cacheIdentifier);
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier, error](ScriptExecutionContext& context) mutable {
+        m_mainThreadConnection->remove(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier](const CacheIdentifierOrError& result) mutable {
+            ASSERT(!result.hasValue() || result.value() == cacheIdentifier);
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                removeCompleted(requestIdentifier, cacheIdentifier, error);
+                removeCompleted(requestIdentifier, result);
             }, m_taskMode);
         });
     });
@@ -146,21 +148,26 @@ void WorkerCacheStorageConnection::doRetrieveCaches(uint64_t requestIdentifier,
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->retrieveCaches(origin, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](const Vector<CacheInfo>& caches) mutable {
-            Vector<CacheInfo> isolatedCaches;
-            isolatedCaches.reserveInitialCapacity(caches.size());
-            for (const auto& cache : caches)
-                isolatedCaches.uncheckedAppend(CacheInfo { cache.identifier, cache.name.isolatedCopy() });
-
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), caches = WTFMove(isolatedCaches), requestIdentifier](ScriptExecutionContext& context) mutable {
+        m_mainThreadConnection->retrieveCaches(origin, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](CacheInfosOrError&& result) mutable {
+            CacheInfosOrError isolatedResult;
+            if (!result.hasValue())
+                isolatedResult = WTFMove(result);
+            else {
+                Vector<CacheInfo> isolatedCaches;
+                isolatedCaches.reserveInitialCapacity(result.value().size());
+                for (const auto& cache : result.value())
+                    isolatedCaches.uncheckedAppend(CacheInfo { cache.identifier, cache.name.isolatedCopy() });
+                isolatedResult = WTFMove(isolatedCaches);
+            }
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(isolatedResult)](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                updateCaches(requestIdentifier, WTFMove(caches));
+                updateCaches(requestIdentifier, WTFMove(result));
             }, m_taskMode);
         });
     });
 }
 
-static inline Vector<CrossThreadRecordData> recordsDataFromRecords(const Vector<CacheStorageConnection::Record>& records)
+static inline Vector<CrossThreadRecordData> recordsDataFromRecords(const Vector<Record>& records)
 {
     Vector<CrossThreadRecordData> recordsData;
     recordsData.reserveInitialCapacity(records.size());
@@ -169,25 +176,40 @@ static inline Vector<CrossThreadRecordData> recordsDataFromRecords(const Vector<
     return recordsData;
 }
 
-static inline Vector<CacheStorageConnection::Record> recordsFromRecordsData(Vector<CrossThreadRecordData>&& recordsData)
+static inline Expected<Vector<CrossThreadRecordData>, Error> recordsDataOrErrorFromRecords(const RecordsOrError& result)
 {
-    Vector<CacheStorageConnection::Record> records;
+    if (!result.hasValue())
+        return makeUnexpected(result.error());
+
+    return recordsDataFromRecords(result.value());
+}
+
+static inline Vector<Record> recordsFromRecordsData(Vector<CrossThreadRecordData>&& recordsData)
+{
+    Vector<Record> records;
     records.reserveInitialCapacity(recordsData.size());
     for (auto& recordData : recordsData)
         records.uncheckedAppend(fromCrossThreadRecordData(WTFMove(recordData)));
     return records;
 }
 
+static inline RecordsOrError recordsOrErrorFromRecordsData(Expected<Vector<CrossThreadRecordData>, Error>&& recordsData)
+{
+    if (!recordsData.hasValue())
+        return makeUnexpected(recordsData.error());
+    return recordsFromRecordsData(WTFMove(recordsData.value()));
+}
+
 void WorkerCacheStorageConnection::doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier)
 {
     m_proxy.postTaskToLoader([this, protectedThis = makeRef(*this), requestIdentifier, cacheIdentifier](ScriptExecutionContext&) mutable {
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->retrieveRecords(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<Record>&& records) mutable {
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), recordsData = recordsDataFromRecords(records), requestIdentifier](ScriptExecutionContext& context) mutable {
+        m_mainThreadConnection->retrieveRecords(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordsOrError&& result) mutable {
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), result = recordsDataOrErrorFromRecords(result), requestIdentifier](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                updateRecords(requestIdentifier, recordsFromRecordsData(WTFMove(recordsData)));
+                updateRecords(requestIdentifier, recordsOrErrorFromRecordsData(WTFMove(result)));
             }, m_taskMode);
         });
     });
@@ -199,11 +221,11 @@ void WorkerCacheStorageConnection::doBatchDeleteOperation(uint64_t requestIdenti
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->batchDeleteOperation(cacheIdentifier, request, WTFMove(options), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<uint64_t>&& records, Error error) mutable {
+        m_mainThreadConnection->batchDeleteOperation(cacheIdentifier, request, WTFMove(options), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordIdentifiersOrError&& result) mutable {
 
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), records = WTFMove(records), error, requestIdentifier](ScriptExecutionContext& context) mutable {
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(result)](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                deleteRecordsCompleted(requestIdentifier, WTFMove(records), error);
+                deleteRecordsCompleted(requestIdentifier, WTFMove(result));
             }, m_taskMode);
         });
     });
@@ -215,11 +237,11 @@ void WorkerCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifie
         ASSERT(isMainThread());
         ASSERT(m_mainThreadConnection);
 
-        m_mainThreadConnection->batchPutOperation(cacheIdentifier, recordsFromRecordsData(WTFMove(recordsData)), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<uint64_t>&& records, Error error) mutable {
+        m_mainThreadConnection->batchPutOperation(cacheIdentifier, recordsFromRecordsData(WTFMove(recordsData)), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordIdentifiersOrError&& result) mutable {
 
-            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), records = WTFMove(records), error, requestIdentifier](ScriptExecutionContext& context) mutable {
+            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(result)](ScriptExecutionContext& context) mutable {
                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
-                putRecordsCompleted(requestIdentifier, WTFMove(records), error);
+                putRecordsCompleted(requestIdentifier, WTFMove(result));
             }, m_taskMode);
         });
     });
index 9f48af2..1addc52 100644 (file)
@@ -42,13 +42,13 @@ private:
     explicit WorkerCacheStorageConnection(WorkerGlobalScope&);
 
     // WebCore::CacheStorageConnection
-    void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) final;
-    void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) final;
-    void doRetrieveCaches(uint64_t requestIdentifier, const String& /* origin */) final;
+    void doOpen(uint64_t requestIdentifier, const String& origin, const String& cacheName) final;
+    void doRemove(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
+    void doRetrieveCaches(uint64_t requestIdentifier, const String& origin) final;
 
     void doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
     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 doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<DOMCache::Record>&&) final;
 
     WorkerGlobalScope& m_scope;
     WorkerLoaderProxy& m_proxy;
index e8f80bd..9b8076d 100644 (file)
                41F54F8E1C50C50C00338488 /* FetchRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F54F871C50C4F600338488 /* FetchRequest.cpp */; };
                41FA303E1316C29C00C0BFC5 /* RenderMediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */; };
                41FA303F1316C29C00C0BFC5 /* RenderMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FA303D1316C29C00C0BFC5 /* RenderMediaControls.h */; };
+               41FABD2D1F4DFE4A006A6C97 /* DOMCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD2B1F4DFE42006A6C97 /* DOMCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               41FABD2F1F4E02CB006A6C97 /* DOMCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */; };
                41FB279C1F34DB8A00795487 /* DOMWindowCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */; };
                41FB279D1F34DB8E00795487 /* WorkerGlobalScopeCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FB278F1F34C28200795487 /* WorkerGlobalScopeCaches.cpp */; };
                43107BE218CC19DE00CC18E8 /* SelectorPseudoTypeMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 43107BE118CC19DE00CC18E8 /* SelectorPseudoTypeMap.h */; };
                41F54F891C50C4F600338488 /* FetchRequest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FetchRequest.idl; sourceTree = "<group>"; };
                41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMediaControls.cpp; sourceTree = "<group>"; };
                41FA303D1316C29C00C0BFC5 /* RenderMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMediaControls.h; sourceTree = "<group>"; };
+               41FABD2B1F4DFE42006A6C97 /* DOMCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCache.h; sourceTree = "<group>"; };
+               41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCache.cpp; sourceTree = "<group>"; };
                41FB278C1F34C28200795487 /* DOMWindowCaches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowCaches.h; sourceTree = "<group>"; };
                41FB278D1F34C28200795487 /* WorkerGlobalScopeCaches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WorkerGlobalScopeCaches.h; sourceTree = "<group>"; };
                41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = DOMWindowCaches.cpp; sourceTree = "<group>"; };
                                41D129C91F3D0EE300D15E47 /* CacheStorageConnection.cpp */,
                                41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */,
                                41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */,
+                               41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */,
+                               41FABD2B1F4DFE42006A6C97 /* DOMCache.h */,
                                41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */,
                                41FB278C1F34C28200795487 /* DOMWindowCaches.h */,
                                41380C2B1F343E2F00155FDA /* DOMWindowCaches.idl */,
                                A8185F3909765766005826D9 /* DocumentType.h in Headers */,
                                973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
                                1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */,
+                               41FABD2D1F4DFE4A006A6C97 /* DOMCache.h in Headers */,
                                FC9A0F75164094CF003D6B8D /* DOMCSSNamespace.h in Headers */,
                                9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
                                7AABA25A14BC613300AA9A11 /* DOMEditor.h in Headers */,
                                A8185F3A09765766005826D9 /* DocumentType.cpp in Sources */,
                                973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */,
                                1A8F6BC20DB55CDC001DB794 /* DOMApplicationCache.cpp in Sources */,
+                               41FABD2F1F4E02CB006A6C97 /* DOMCache.cpp in Sources */,
                                FD677738195CAF3D0072E0D3 /* DOMCSSNamespace.cpp in Sources */,
                                7AABA25914BC613300AA9A11 /* DOMEditor.cpp in Sources */,
                                BC1BDF24156C1883001C1243 /* DOMError.cpp in Sources */,
index f55c45c..47b6a17 100644 (file)
@@ -1,3 +1,42 @@
+2017-08-23  Youenn Fablet  <youenn@apple.com>
+
+        [Cache API] Unify WebCore and WebKit error handling
+        https://bugs.webkit.org/show_bug.cgi?id=175902
+
+        Reviewed by Alex Christensen.
+
+        Removing all callbacks and error definitions from WebKit
+        and reusing DOMCache ones instead.
+
+        * NetworkProcess/cache/CacheStorage.h: Removed.
+        * NetworkProcess/cache/CacheStorageEngine.cpp:
+        (WebKit::CacheStorage::Engine::caches const):
+        (WebKit::CacheStorage::Engine::queryCache):
+        * NetworkProcess/cache/CacheStorageEngine.h:
+        * NetworkProcess/cache/CacheStorageEngineCache.h:
+        * NetworkProcess/cache/CacheStorageEngineConnection.cpp:
+        (WebKit::CacheStorageEngineConnection::open):
+        (WebKit::CacheStorageEngineConnection::remove):
+        (WebKit::CacheStorageEngineConnection::putRecords):
+        * NetworkProcess/cache/CacheStorageEngineConnection.h:
+        * NetworkProcess/cache/CacheStorageEngineConnection.messages.in:
+        * Shared/WebCoreArgumentCoders.cpp:
+        (IPC::ArgumentCoder<DOMCache::CacheInfo>::encode):
+        (IPC::ArgumentCoder<DOMCache::CacheInfo>::decode):
+        (IPC::ArgumentCoder<DOMCache::Record>::encode):
+        (IPC::ArgumentCoder<DOMCache::Record>::decode):
+        * Shared/WebCoreArgumentCoders.h:
+        * WebProcess/Cache/WebCacheStorageConnection.cpp:
+        (WebKit::WebCacheStorageConnection::doBatchPutOperation):
+        (WebKit::WebCacheStorageConnection::openCompleted):
+        (WebKit::WebCacheStorageConnection::removeCompleted):
+        (WebKit::WebCacheStorageConnection::updateCaches):
+        (WebKit::WebCacheStorageConnection::updateRecords):
+        (WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
+        (WebKit::WebCacheStorageConnection::putRecordsCompleted):
+        * WebProcess/Cache/WebCacheStorageConnection.h:
+        * WebProcess/Cache/WebCacheStorageConnection.messages.in:
+
 2017-08-23  Alex Christensen  <achristensen@webkit.org>
 
         Clean up UIClients
index 36aa673..5aebbe6 100644 (file)
@@ -32,6 +32,8 @@
 #include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringHash.h>
 
+using namespace WebCore::DOMCache;
+
 namespace WebKit {
 
 namespace CacheStorage {
@@ -126,10 +128,10 @@ void Engine::retrieveCaches(const String& origin, CacheInfosCallback&& callback)
 
         auto& caches = cachesOrError.value().get();
 
-        Vector<WebCore::CacheStorageConnection::CacheInfo> cachesInfo;
+        Vector<CacheInfo> cachesInfo;
         cachesInfo.reserveInitialCapacity(caches.size());
         for (auto& cache : caches)
-            cachesInfo.uncheckedAppend(WebCore::CacheStorageConnection::CacheInfo { cache.identifier, cache.name});
+            cachesInfo.uncheckedAppend(CacheInfo { cache.identifier, cache.name});
 
         callback(WTFMove(cachesInfo));
     });
@@ -297,7 +299,7 @@ Vector<uint64_t> Engine::queryCache(const Vector<Record>& records, const WebCore
 
     Vector<uint64_t> results;
     for (const auto& record : records) {
-        if (WebCore::CacheStorageConnection::queryCacheMatch(request, record.request, record.response, options))
+        if (WebCore::DOMCache::queryCacheMatch(request, record.request, record.response, options))
             results.append(record.identifier);
     }
     return results;
index 0f1ba4c..2917712 100644 (file)
@@ -45,31 +45,31 @@ public:
     static Engine& from(PAL::SessionID);
     static void destroyEngine(PAL::SessionID);
 
-    void open(const String& origin, const String& cacheName, CacheIdentifierCallback&&);
-    void remove(uint64_t cacheIdentifier, CacheIdentifierCallback&&);
-    void retrieveCaches(const String& origin, CacheInfosCallback&&);
+    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&&);
 
-    void retrieveRecords(uint64_t cacheIdentifier, RecordsCallback&&);
-    void putRecords(uint64_t cacheIdentifier, Vector<Record>&&, RecordIdentifiersCallback&&);
-    void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, RecordIdentifiersCallback&&);
+    void retrieveRecords(uint64_t cacheIdentifier, WebCore::DOMCache::RecordsCallback&&);
+    void putRecords(uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
+    void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
 
 private:
     static Engine& defaultEngine();
 
-    void writeCachesToDisk(CompletionCallback&&);
+    void writeCachesToDisk(WebCore::DOMCache::CompletionCallback&&);
 
-    using CachesOrError = Expected<std::reference_wrapper<Vector<Cache>>, Error>;
-    using CachesCallback = Function<void(CachesOrError&&)>;
-    void readCachesFromDisk(const String& origin, Function<void(CachesOrError&&)>&&);
-
-    using CacheOrError = Expected<std::reference_wrapper<Cache>, Error>;
-    using CacheCallback = Function<void(CacheOrError&&)>;
+    using CachesOrError = Expected<std::reference_wrapper<Vector<Cache>>, WebCore::DOMCache::Error>;
+    using CachesCallback = WTF::Function<void(CachesOrError&&)>;
+    void readCachesFromDisk(const String& origin, CachesCallback&&);
 
+    using CacheOrError = Expected<std::reference_wrapper<Cache>, WebCore::DOMCache::Error>;
+    using CacheCallback = WTF::Function<void(CacheOrError&&)>;
     void readCache(uint64_t cacheIdentifier, CacheCallback&&);
-    void writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, RecordIdentifiersCallback&&);
-    void removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, RecordIdentifiersCallback&&);
 
-    Vector<uint64_t> queryCache(const Vector<Record>&, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&);
+    void writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
+    void removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
+
+    Vector<uint64_t> queryCache(const Vector<WebCore::DOMCache::Record>&, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&);
 
     Cache* cache(uint64_t cacheIdentifier);
 
index 1d8f119..966b514 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "CacheStorage.h"
+#include <WebCore/DOMCache.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
 
@@ -36,7 +36,7 @@ namespace CacheStorage {
 struct Cache {
     uint64_t identifier { 0 };
     String name;
-    Vector<Record> records;
+    Vector<WebCore::DOMCache::Record> records;
     uint64_t nextRecordIdentifier { 0 };
 };
 
index 7fe29a1..35eb1d6 100644 (file)
 
 #include "NetworkConnectionToWebProcess.h"
 #include "WebCacheStorageConnectionMessages.h"
+#include "WebCoreArgumentCoders.h"
 #include <WebCore/CacheQueryOptions.h>
 
+using namespace WebCore::DOMCache;
 using namespace WebKit::CacheStorage;
 
 namespace WebKit {
@@ -42,14 +44,14 @@ CacheStorageEngineConnection::CacheStorageEngineConnection(NetworkConnectionToWe
 
 void CacheStorageEngineConnection::open(PAL::SessionID sessionID, uint64_t requestIdentifier, const String& origin, const String& cacheName)
 {
-    Engine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
+    Engine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](const 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)
 {
-    Engine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
+    Engine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
         m_connection.connection().send(Messages::WebCacheStorageConnection::RemoveCompleted(requestIdentifier, result), sessionID.sessionID());
     });
 }
@@ -75,7 +77,7 @@ void CacheStorageEngineConnection::deleteMatchingRecords(PAL::SessionID sessionI
     });
 }
 
-void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records)
+void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
 {
     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 4a93e5f..fb3a664 100644 (file)
@@ -56,7 +56,7 @@ private:
 
     void records(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier);
     void deleteMatchingRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&);
-    void putRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&&);
+    void putRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&);
 
     NetworkConnectionToWebProcess& m_connection;
 };
index 4df3942..5922eed 100644 (file)
@@ -27,5 +27,5 @@ messages -> CacheStorageEngineConnection {
 
     Records(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier);
     DeleteMatchingRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest request, struct WebCore::CacheQueryOptions options);
-    PutRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record> record);
+    PutRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record> record);
 }
index a6f8a01..c2dc755 100644 (file)
@@ -214,13 +214,13 @@ bool ArgumentCoder<CacheQueryOptions>::decode(Decoder& decoder, CacheQueryOption
     return true;
 }
 
-void ArgumentCoder<CacheStorageConnection::CacheInfo>::encode(Encoder& encoder, const CacheStorageConnection::CacheInfo& info)
+void ArgumentCoder<DOMCache::CacheInfo>::encode(Encoder& encoder, const DOMCache::CacheInfo& info)
 {
     encoder << info.identifier;
     encoder << info.name;
 }
 
-bool ArgumentCoder<CacheStorageConnection::CacheInfo>::decode(Decoder& decoder, CacheStorageConnection::CacheInfo& record)
+bool ArgumentCoder<DOMCache::CacheInfo>::decode(Decoder& decoder, DOMCache::CacheInfo& record)
 {
     uint64_t identifier;
     if (!decoder.decode(identifier))
@@ -236,7 +236,7 @@ bool ArgumentCoder<CacheStorageConnection::CacheInfo>::decode(Decoder& decoder,
     return true;
 }
 
-void ArgumentCoder<CacheStorageConnection::Record>::encode(Encoder& encoder, const CacheStorageConnection::Record& record)
+void ArgumentCoder<DOMCache::Record>::encode(Encoder& encoder, const DOMCache::Record& record)
 {
     encoder << record.identifier;
 
@@ -262,7 +262,7 @@ void ArgumentCoder<CacheStorageConnection::Record>::encode(Encoder& encoder, con
     });
 }
 
-bool ArgumentCoder<CacheStorageConnection::Record>::decode(Decoder& decoder, CacheStorageConnection::Record& record)
+bool ArgumentCoder<DOMCache::Record>::decode(Decoder& decoder, DOMCache::Record& record)
 {
     uint64_t identifier;
     if (!decoder.decode(identifier))
@@ -296,7 +296,7 @@ bool ArgumentCoder<CacheStorageConnection::Record>::decode(Decoder& decoder, Cac
     if (!decoder.decode(updateResponseCounter))
         return false;
 
-    WebCore::CacheStorageConnection::ResponseBody responseBody;
+    WebCore::DOMCache::ResponseBody responseBody;
     bool hasSharedBufferBody;
     if (!decoder.decode(hasSharedBufferBody))
         return false;
index 081fb01..790b829 100644 (file)
@@ -200,14 +200,14 @@ template<> struct ArgumentCoder<WebCore::CacheQueryOptions> {
     static bool decode(Decoder&, WebCore::CacheQueryOptions&);
 };
 
-template<> struct ArgumentCoder<WebCore::CacheStorageConnection::CacheInfo> {
-    static void encode(Encoder&, const WebCore::CacheStorageConnection::CacheInfo&);
-    static bool decode(Decoder&, WebCore::CacheStorageConnection::CacheInfo&);
+template<> struct ArgumentCoder<WebCore::DOMCache::CacheInfo> {
+    static void encode(Encoder&, const WebCore::DOMCache::CacheInfo&);
+    static bool decode(Decoder&, WebCore::DOMCache::CacheInfo&);
 };
 
-template<> struct ArgumentCoder<WebCore::CacheStorageConnection::Record> {
-    static void encode(Encoder&, const WebCore::CacheStorageConnection::Record&);
-    static bool decode(Decoder&, WebCore::CacheStorageConnection::Record&);
+template<> struct ArgumentCoder<WebCore::DOMCache::Record> {
+    static void encode(Encoder&, const WebCore::DOMCache::Record&);
+    static bool decode(Decoder&, WebCore::DOMCache::Record&);
 };
 
 template<> struct ArgumentCoder<WebCore::EventTrackingRegions> {
@@ -786,12 +786,4 @@ template<> struct EnumTraits<WebCore::MediaSelectionOption::Type> {
     >;
 };
 
-template<> struct EnumTraits<WebCore::CacheStorageConnection::Error> {
-    using values = EnumValues<
-        WebCore::CacheStorageConnection::Error,
-        WebCore::CacheStorageConnection::Error::None,
-        WebCore::CacheStorageConnection::Error::NotImplemented
-    >;
-};
-
 } // namespace WTF
index 6299b4b..90e1acd 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 */; };
                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>"; };
                E489D2821A0A2BE80078C06A /* cache */ = {
                        isa = PBXGroup;
                        children = (
-                               41FABD271F4DDFDC006A6C97 /* CacheStorage.h */,
                                41897ED61F415D860016FA42 /* CacheStorageEngine.cpp */,
                                41897ED21F415D850016FA42 /* CacheStorageEngine.h */,
                                41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */,
                                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 */,
index 5c282be..c3d1302 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "WebCacheStorageConnection.h"
 
+#include "CacheStorageEngine.h"
 #include "CacheStorageEngineConnectionMessages.h"
 #include "NetworkConnectionToWebProcessMessages.h"
 #include "NetworkProcessConnection.h"
@@ -34,6 +35,7 @@
 #include "WebProcess.h"
 #include <wtf/MainThread.h>
 
+using namespace WebCore::DOMCache;
 using namespace WebKit::CacheStorage;
 
 namespace WebKit {
@@ -79,39 +81,39 @@ void WebCacheStorageConnection::doBatchDeleteOperation(uint64_t requestIdentifie
     connection().send(Messages::CacheStorageEngineConnection::DeleteMatchingRecords(m_sessionID, requestIdentifier, cacheIdentifier, request, options), 0);
 }
 
-void WebCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records)
+void WebCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
 {
     connection().send(Messages::CacheStorageEngineConnection::PutRecords(m_sessionID, requestIdentifier, cacheIdentifier, records), 0);
 }
 
-void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
+void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
 {
-    CacheStorageConnection::openCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
+    CacheStorageConnection::openCompleted(requestIdentifier, result);
 }
 
-void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
+void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
 {
-    CacheStorageConnection::removeCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
+    CacheStorageConnection::removeCompleted(requestIdentifier, result);
 }
 
 void WebCacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheInfosOrError&& result)
 {
-    CacheStorageConnection::updateCaches(requestIdentifier, result.hasValue() ? result.value() : Vector<CacheInfo>());
+    CacheStorageConnection::updateCaches(requestIdentifier, WTFMove(result));
 }
 
 void WebCacheStorageConnection::updateRecords(uint64_t requestIdentifier, RecordsOrError&& result)
 {
-    CacheStorageConnection::updateRecords(requestIdentifier, result.hasValue() ? WTFMove(result.value()) : Vector<Record>());
+    CacheStorageConnection::updateRecords(requestIdentifier, WTFMove(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);
+    CacheStorageConnection::deleteRecordsCompleted(requestIdentifier, WTFMove(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);
+    CacheStorageConnection::putRecordsCompleted(requestIdentifier, WTFMove(result));
 }
 
 }
index 73c1d37..25affcf 100644 (file)
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "CacheStorage.h"
 #include <WebCore/CacheStorageConnection.h>
 #include <wtf/HashMap.h>
 
@@ -59,15 +58,15 @@ private:
 
     void doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
     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 doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&) final;
 
-    void openCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
-    void removeCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
-    void updateCaches(uint64_t requestIdentifier, CacheStorage::CacheInfosOrError&&);
+    void openCompleted(uint64_t requestIdentifier, const WebCore::DOMCache::CacheIdentifierOrError&);
+    void removeCompleted(uint64_t requestIdentifier, const WebCore::DOMCache::CacheIdentifierOrError&);
+    void updateCaches(uint64_t requestIdentifier, WebCore::DOMCache::CacheInfosOrError&&);
 
-    void updateRecords(uint64_t requestIdentifier, CacheStorage::RecordsOrError&&);
-    void deleteRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
-    void putRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
+    void updateRecords(uint64_t requestIdentifier, WebCore::DOMCache::RecordsOrError&&);
+    void deleteRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError&&);
+    void putRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError&&);
 
     WebCacheStorageProvider& m_provider;
     PAL::SessionID m_sessionID;
index d30863f..a9e3324 100644 (file)
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebCacheStorageConnection {
-    OpenCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
-    RemoveCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
-    UpdateCaches(uint64_t requestIdentifier, WebKit::CacheStorage::CacheInfosOrError result);
+    OpenCompleted(uint64_t requestIdentifier, WebCore::DOMCache::CacheIdentifierOrError result);
+    RemoveCompleted(uint64_t requestIdentifier, WebCore::DOMCache::CacheIdentifierOrError result);
+    UpdateCaches(uint64_t requestIdentifier, WebCore::DOMCache::CacheInfosOrError 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);
+    UpdateRecords(uint64_t requestIdentifier, WebCore::DOMCache::RecordsOrError result);
+    DeleteRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError result);
+    PutRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError result);
 }