Changeset 221112 in webkit


Ignore:
Timestamp:
Aug 23, 2017 3:33:15 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

[Cache API] Unify WebCore and WebKit error handling
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:
Location:
trunk/Source
Files:
1 added
23 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r220977 r221112  
    898898    Modules/cache/CacheStorage.cpp
    899899    Modules/cache/CacheStorageConnection.cpp
     900    Modules/cache/DOMCache.cpp
    900901    Modules/cache/DOMWindowCaches.cpp
    901902    Modules/cache/WorkerCacheStorageConnection.cpp
  • trunk/Source/WebCore/ChangeLog

    r221110 r221112  
     12017-08-23  Youenn Fablet  <youenn@apple.com>
     2
     3        [Cache API] Unify WebCore and WebKit error handling
     4        https://bugs.webkit.org/show_bug.cgi?id=175902
     5
     6        Reviewed by Alex Christensen.
     7
     8        No change of behavior.
     9
     10        Introducing a DOMCache namespace enclosing structures, callbacks and function definitions
     11        previously found in either WebCore::CacheStorageConnection or WebKit::CacheStorage.
     12
     13        Some previously used callbacks had no way to pass errors in WebCore while they had in WebKit.
     14        Updated Cache, CacheStorage, CacheStorageConnection and WorkerCacheStorageConnection to deal with these potential errors.
     15
     16        * CMakeLists.txt:
     17        * Modules/cache/Cache.cpp:
     18        (WebCore::FetchTasksHandler::FetchTasksHandler):
     19        (WebCore::FetchTasksHandler::records const):
     20        (WebCore::FetchTasksHandler::addRecord):
     21        (WebCore::Cache::addAll):
     22        (WebCore::Cache::put):
     23        (WebCore::Cache::retrieveRecords):
     24        (WebCore::queryCacheMatch):
     25        (WebCore::Cache::batchDeleteOperation):
     26        (WebCore::toConnectionRecord):
     27        (WebCore::Cache::batchPutOperation):
     28        (WebCore::Cache::updateRecords):
     29        * Modules/cache/Cache.h:
     30        * Modules/cache/CacheStorage.cpp:
     31        (WebCore::CacheStorage::retrieveCaches):
     32        (WebCore::CacheStorage::open):
     33        (WebCore::CacheStorage::remove):
     34        * Modules/cache/CacheStorage.h:
     35        * Modules/cache/CacheStorageConnection.cpp:
     36        (WebCore::CacheStorageConnection::open):
     37        (WebCore::CacheStorageConnection::remove):
     38        (WebCore::CacheStorageConnection::retrieveCaches):
     39        (WebCore::CacheStorageConnection::batchDeleteOperation):
     40        (WebCore::CacheStorageConnection::batchPutOperation):
     41        (WebCore::CacheStorageConnection::openOrRemoveCompleted):
     42        (WebCore::CacheStorageConnection::updateCaches):
     43        (WebCore::CacheStorageConnection::updateRecords):
     44        (WebCore::CacheStorageConnection::deleteRecordsCompleted):
     45        (WebCore::CacheStorageConnection::putRecordsCompleted):
     46        * Modules/cache/CacheStorageConnection.h:
     47        (WebCore::CacheStorageConnection::openCompleted):
     48        (WebCore::CacheStorageConnection::removeCompleted):
     49        (WebCore::CacheStorageConnection::doOpen):
     50        (WebCore::CacheStorageConnection::doRemove):
     51        (WebCore::CacheStorageConnection::doBatchDeleteOperation):
     52        (WebCore::CacheStorageConnection::doBatchPutOperation):
     53        * Modules/cache/WorkerCacheStorageConnection.cpp:
     54        (WebCore::toCrossThreadRecordData):
     55        (WebCore::fromCrossThreadRecordData):
     56        (WebCore::WorkerCacheStorageConnection::doOpen):
     57        (WebCore::WorkerCacheStorageConnection::doRemove):
     58        (WebCore::WorkerCacheStorageConnection::doRetrieveCaches):
     59        (WebCore::recordsDataFromRecords):
     60        (WebCore::recordsDataOrErrorFromRecords):
     61        (WebCore::recordsFromRecordsData):
     62        (WebCore::recordsOrErrorFromRecordsData):
     63        (WebCore::WorkerCacheStorageConnection::doRetrieveRecords):
     64        (WebCore::WorkerCacheStorageConnection::doBatchDeleteOperation):
     65        (WebCore::WorkerCacheStorageConnection::doBatchPutOperation):
     66        * Modules/cache/DOMCache.cpp: Added.
     67        * Modules/cache/DOMCache.h: Added.
     68        * Modules/cache/WorkerCacheStorageConnection.h:
     69        * WebCore.xcodeproj/project.pbxproj:
     70
    1712017-08-23  Yusuke Suzuki  <utatane.tea@gmail.com>
    272
  • trunk/Source/WebCore/Modules/cache/Cache.cpp

    r221031 r221112  
    3535#include "URL.h"
    3636
     37using namespace WebCore::DOMCache;
     38
    3739namespace WebCore {
    3840
    39 static CacheStorageConnection::Record toConnectionRecord(const FetchRequest&, FetchResponse&, CacheStorageConnection::ResponseBody&&);
     41static Record toConnectionRecord(const FetchRequest&, FetchResponse&, ResponseBody&&);
    4042
    4143Cache::Cache(ScriptExecutionContext& context, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&& connection)
     
    136138class FetchTasksHandler : public RefCounted<FetchTasksHandler> {
    137139public:
    138     explicit FetchTasksHandler(Function<void(ExceptionOr<Vector<CacheStorageConnection::Record>>&&)>&& callback)
     140    explicit FetchTasksHandler(Function<void(ExceptionOr<Vector<Record>>&&)>&& callback)
    139141        : m_callback(WTFMove(callback))
    140142    {
     
    147149    }
    148150
    149     const Vector<CacheStorageConnection::Record>& records() const { return m_records; }
    150 
    151     size_t addRecord(CacheStorageConnection::Record&& record)
     151    const Vector<Record>& records() const { return m_records; }
     152
     153    size_t addRecord(Record&& record)
    152154    {
    153155        ASSERT(!isDone());
     
    171173
    172174private:
    173     Vector<CacheStorageConnection::Record> m_records;
    174     Function<void(ExceptionOr<Vector<CacheStorageConnection::Record>>&&)> m_callback;
     175    Vector<Record> m_records;
     176    Function<void(ExceptionOr<Vector<Record>>&&)> m_callback;
    175177};
    176178
     
    208210    }
    209211
    210     auto taskHandler = adoptRef(*new FetchTasksHandler([protectedThis = makeRef(*this), this, promise = WTFMove(promise)](ExceptionOr<Vector<CacheStorageConnection::Record>>&& result) mutable {
     212    auto taskHandler = adoptRef(*new FetchTasksHandler([protectedThis = makeRef(*this), this, promise = WTFMove(promise)](ExceptionOr<Vector<Record>>&& result) mutable {
    211213        if (result.hasException()) {
    212214            promise.reject(result.releaseException());
     
    249251            CacheQueryOptions options;
    250252            for (const auto& record : taskHandler->records()) {
    251                 if (CacheStorageConnection::queryCacheMatch(request->resourceRequest(), record.request, record.response, options)) {
     253                if (DOMCache::queryCacheMatch(request->resourceRequest(), record.request, record.response, options)) {
    252254                    taskHandler->error(Exception { InvalidStateError, ASCIILiteral("addAll cannot store several matching requests")});
    253255                    return;
     
    311313                promise.reject(result.releaseException());
    312314            else {
    313                 CacheStorageConnection::ResponseBody body;
     315                DOMCache::ResponseBody body;
    314316                if (auto buffer = result.releaseReturnValue())
    315317                    body = buffer.releaseNonNull();
     
    382384{
    383385    setPendingActivity(this);
    384     m_connection->retrieveRecords(m_identifier, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::Record>&& records) {
     386    m_connection->retrieveRecords(m_identifier, [this, callback = WTFMove(callback)](RecordsOrError&& result) {
    385387        if (!m_isStopped) {
    386             updateRecords(WTFMove(records));
     388            // FIXME: We should probably propagate that error up to the promise based operation.
     389            ASSERT(result.hasValue());
     390            if (result.hasValue())
     391                updateRecords(WTFMove(result.value()));
    387392            callback();
    388393        }
     
    401406{
    402407    // We need to pass the resource request with all correct headers hence why we call resourceRequest().
    403     return CacheStorageConnection::queryCacheMatch(request.resourceRequest(), cachedRequest.resourceRequest(), cachedResponse, options);
     408    return DOMCache::queryCacheMatch(request.resourceRequest(), cachedRequest.resourceRequest(), cachedResponse, options);
    404409}
    405410
     
    420425{
    421426    setPendingActivity(this);
    422     m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](Vector<uint64_t>&& records, CacheStorageConnection::Error error) {
    423         if (!m_isStopped)
    424             callback(CacheStorageConnection::exceptionOrResult(!records.isEmpty(), error));
    425 
     427    m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
     428        if (!m_isStopped) {
     429            if (!result.hasValue())
     430                callback(DOMCache::errorToException(result.error()));
     431            else
     432                callback(!result.value().isEmpty());
     433        }
    426434        unsetPendingActivity(this);
    427435    });
    428436}
    429437
    430 CacheStorageConnection::Record toConnectionRecord(const FetchRequest& request, FetchResponse& response, CacheStorageConnection::ResponseBody&& responseBody)
     438Record toConnectionRecord(const FetchRequest& request, FetchResponse& response, DOMCache::ResponseBody&& responseBody)
    431439{
    432440    // FIXME: Add a setHTTPHeaderFields on ResourceResponseBase.
     
    447455}
    448456
    449 void Cache::batchPutOperation(const FetchRequest& request, FetchResponse& response, CacheStorageConnection::ResponseBody&& responseBody, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
    450 {
    451     Vector<CacheStorageConnection::Record> records;
     457void Cache::batchPutOperation(const FetchRequest& request, FetchResponse& response, DOMCache::ResponseBody&& responseBody, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
     458{
     459    Vector<Record> records;
    452460    records.append(toConnectionRecord(request, response, WTFMove(responseBody)));
    453461
     
    455463}
    456464
    457 void Cache::batchPutOperation(Vector<CacheStorageConnection::Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
     465void Cache::batchPutOperation(Vector<Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
    458466{
    459467    setPendingActivity(this);
    460     m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](Vector<uint64_t>&&, CacheStorageConnection::Error error) {
    461         if (!m_isStopped)
    462             callback(CacheStorageConnection::errorToException(error));
    463 
     468    m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
     469        if (!m_isStopped) {
     470            if (!result.hasValue())
     471                callback(DOMCache::errorToException(result.error()));
     472            else
     473                callback({ });
     474        }
    464475        unsetPendingActivity(this);
    465476    });
    466477}
    467478
    468 void Cache::updateRecords(Vector<CacheStorageConnection::Record>&& records)
     479void Cache::updateRecords(Vector<Record>&& records)
    469480{
    470481    ASSERT(scriptExecutionContext());
  • trunk/Source/WebCore/Modules/cache/Cache.h

    r220998 r221112  
    7474    void queryCache(Ref<FetchRequest>&&, CacheQueryOptions&&, WTF::Function<void(const Vector<CacheStorageRecord>&)>&&);
    7575    void batchDeleteOperation(const FetchRequest&, CacheQueryOptions&&, WTF::Function<void(ExceptionOr<bool>&&)>&&);
    76     void batchPutOperation(const FetchRequest&, FetchResponse&, CacheStorageConnection::ResponseBody&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
    77     void batchPutOperation(Vector<CacheStorageConnection::Record>&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
     76    void batchPutOperation(const FetchRequest&, FetchResponse&, DOMCache::ResponseBody&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
     77    void batchPutOperation(Vector<DOMCache::Record>&&, WTF::Function<void(ExceptionOr<void>&&)>&&);
    7878
    79     void updateRecords(Vector<CacheStorageConnection::Record>&&);
     79    void updateRecords(Vector<DOMCache::Record>&&);
    8080
    8181    String m_name;
  • trunk/Source/WebCore/Modules/cache/CacheStorage.cpp

    r220984 r221112  
    3232#include "ScriptExecutionContext.h"
    3333
     34using namespace WebCore::DOMCache;
     35
    3436namespace WebCore {
    3537
     
    118120
    119121    setPendingActivity(this);
    120     m_connection->retrieveCaches(origin, [this, callback = WTFMove(callback)](Vector<CacheStorageConnection::CacheInfo>&& cachesInfo) {
     122    m_connection->retrieveCaches(origin, [this, callback = WTFMove(callback)](CacheInfosOrError&& result) {
    121123        if (!m_isStopped) {
     124            // FIXME: We should probably propagate that error up to the promise based operation.
     125            ASSERT(result.hasValue());
     126            if (!result.hasValue()) {
     127                callback();
     128                return;
     129            }
     130            auto& cachesInfo = result.value();
     131
    122132            ASSERT(scriptExecutionContext());
    123133            m_caches.removeAllMatching([&](auto& cache) {
     
    153163
    154164        setPendingActivity(this);
    155         m_connection->open(origin, name, [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
     165        m_connection->open(origin, name, [this, name, promise = WTFMove(promise)](const CacheIdentifierOrError& result) mutable {
    156166            if (!m_isStopped) {
    157                 auto result = CacheStorageConnection::errorToException(error);
    158                 if (result.hasException())
    159                     promise.reject(result.releaseException());
     167
     168                if (!result.hasValue())
     169                    promise.reject(DOMCache::errorToException(result.error()));
    160170                else {
    161                     auto cache = Cache::create(*scriptExecutionContext(), String { name }, cacheIdentifier, m_connection.copyRef());
     171                    auto cache = Cache::create(*scriptExecutionContext(), String { name }, result.value(), m_connection.copyRef());
    162172                    promise.resolve(cache);
    163173                    m_caches.append(WTFMove(cache));
     
    182192
    183193        setPendingActivity(this);
    184         m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise)](uint64_t cacheIdentifier, CacheStorageConnection::Error error) mutable {
    185             UNUSED_PARAM(cacheIdentifier);
    186             if (!m_isStopped)
    187                 promise.settle(CacheStorageConnection::exceptionOrResult(true, error));
    188 
     194        m_connection->remove(m_caches[position]->identifier(), [this, name, promise = WTFMove(promise)](const CacheIdentifierOrError& result) mutable {
     195            if (!m_isStopped) {
     196                if (!result.hasValue())
     197                    promise.reject(DOMCache::errorToException(result.error()));
     198                else
     199                    promise.resolve(true);
     200            }
    189201            unsetPendingActivity(this);
    190202        });
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp

    r221024 r221112  
    2828#include "CacheStorageConnection.h"
    2929
    30 #include "CacheQueryOptions.h"
    31 #include "Exception.h"
    32 #include "HTTPParsers.h"
     30using namespace WebCore::DOMCache;
    3331
    3432namespace WebCore {
    3533
    36 ExceptionOr<void> CacheStorageConnection::errorToException(Error error)
    37 {
    38     switch (error) {
    39     case Error::None:
    40         return { };
    41     case Error::NotImplemented:
    42         return Exception { NotSupportedError, ASCIILiteral("Not implemented") };
    43     default:
    44         return Exception { NotSupportedError, ASCIILiteral("Internal error") };
    45     }
    46 }
    47 
    48 bool CacheStorageConnection::queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse& cachedResponse, const CacheQueryOptions& options)
    49 {
    50     ASSERT(options.ignoreMethod || request.httpMethod() == "GET");
    51 
    52     URL requestURL = request.url();
    53     URL cachedRequestURL = cachedRequest.url();
    54 
    55     if (options.ignoreSearch) {
    56         requestURL.setQuery({ });
    57         cachedRequestURL.setQuery({ });
    58     }
    59     if (!equalIgnoringFragmentIdentifier(requestURL, cachedRequestURL))
    60         return false;
    61 
    62     if (options.ignoreVary)
    63         return true;
    64 
    65     String varyValue = cachedResponse.httpHeaderField(WebCore::HTTPHeaderName::Vary);
    66     if (varyValue.isNull())
    67         return true;
    68 
    69     // FIXME: This is inefficient, we should be able to split and trim whitespaces at the same time.
    70     Vector<String> varyHeaderNames;
    71     varyValue.split(',', false, varyHeaderNames);
    72     for (auto& name : varyHeaderNames) {
    73         if (stripLeadingAndTrailingHTTPSpaces(name) == "*")
    74             return false;
    75         if (cachedRequest.httpHeaderField(name) != request.httpHeaderField(name))
    76             return false;
    77     }
    78     return true;
    79 }
    80 
    81 void CacheStorageConnection::open(const String& origin, const String& cacheName, OpenRemoveCallback&& callback)
     34void CacheStorageConnection::open(const String& origin, const String& cacheName, CacheIdentifierCallback&& callback)
    8235{
    8336    uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     
    8740}
    8841
    89 void CacheStorageConnection::remove(uint64_t cacheIdentifier, OpenRemoveCallback&& callback)
     42void CacheStorageConnection::remove(uint64_t cacheIdentifier, CacheIdentifierCallback&& callback)
    9043{
    9144    uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     
    9548}
    9649
    97 void CacheStorageConnection::retrieveCaches(const String& origin, CachesCallback&& callback)
     50void CacheStorageConnection::retrieveCaches(const String& origin, CacheInfosCallback&& callback)
    9851{
    9952    uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     
    11164}
    11265
    113 void CacheStorageConnection::batchDeleteOperation(uint64_t cacheIdentifier, const WebCore::ResourceRequest& request, WebCore::CacheQueryOptions&& options, BatchOperationCallback&& callback)
     66void CacheStorageConnection::batchDeleteOperation(uint64_t cacheIdentifier, const ResourceRequest& request, CacheQueryOptions&& options, RecordIdentifiersCallback&& callback)
    11467{
    11568    uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     
    11972}
    12073
    121 void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records, BatchOperationCallback&& callback)
     74void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<Record>&& records, RecordIdentifiersCallback&& callback)
    12275{
    12376    uint64_t requestIdentifier = ++m_lastRequestIdentifier;
     
    12780}
    12881
    129 void CacheStorageConnection::openOrRemoveCompleted(uint64_t requestIdentifier, uint64_t cacheIdentifier, Error error)
     82void CacheStorageConnection::openOrRemoveCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
    13083{
    13184    if (auto callback = m_openAndRemoveCachePendingRequests.take(requestIdentifier))
    132         callback(cacheIdentifier, error);
     85        callback(result);
    13386}
    13487
    135 void CacheStorageConnection::updateCaches(uint64_t requestIdentifier, Vector<CacheInfo>&& caches)
     88void CacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheInfosOrError&& result)
    13689{
    13790    if (auto callback = m_retrieveCachesPendingRequests.take(requestIdentifier))
    138         callback(WTFMove(caches));
     91        callback(WTFMove(result));
    13992}
    14093
    141 void CacheStorageConnection::updateRecords(uint64_t requestIdentifier, Vector<Record>&& records)
     94void CacheStorageConnection::updateRecords(uint64_t requestIdentifier, RecordsOrError&& result)
    14295{
    14396    if (auto callback = m_retrieveRecordsPendingRequests.take(requestIdentifier))
    144         callback(WTFMove(records));
     97        callback(WTFMove(result));
    14598}
    14699
    147 void CacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&& records, Error error)
     100void CacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, Expected<Vector<uint64_t>, Error>&& result)
    148101{
    149102    if (auto callback = m_batchDeleteAndPutPendingRequests.take(requestIdentifier))
    150         callback(WTFMove(records), error);
     103        callback(WTFMove(result));
    151104}
    152105
    153 void CacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&& records, Error error)
     106void CacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, Expected<Vector<uint64_t>, Error>&& result)
    154107{
    155108    if (auto callback = m_batchDeleteAndPutPendingRequests.take(requestIdentifier))
    156         callback(WTFMove(records), error);
    157 }
    158 
    159 CacheStorageConnection::ResponseBody CacheStorageConnection::isolatedResponseBody(const ResponseBody& body)
    160 {
    161     return WTF::switchOn(body, [](const Ref<FormData>& formData) {
    162         return formData->isolatedCopy();
    163     }, [](const Ref<SharedBuffer>& buffer) {
    164         return buffer->copy();
    165     }, [](const std::nullptr_t&) {
    166         return CacheStorageConnection::ResponseBody { };
    167     });
    168 }
    169 
    170 static inline CacheStorageConnection::ResponseBody copyResponseBody(const CacheStorageConnection::ResponseBody& body)
    171 {
    172     return WTF::switchOn(body, [](const Ref<FormData>& formData) {
    173         return formData.copyRef();
    174     }, [](const Ref<SharedBuffer>& buffer) {
    175         return buffer.copyRef();
    176     }, [](const std::nullptr_t&) {
    177         return CacheStorageConnection::ResponseBody { };
    178     });
    179 }
    180 
    181 CacheStorageConnection::Record CacheStorageConnection::Record::copy() const
    182 {
    183     return Record { identifier, updateResponseCounter, requestHeadersGuard, request, options, referrer, responseHeadersGuard, response, copyResponseBody(responseBody) };
     109        callback(WTFMove(result));
    184110}
    185111
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.h

    r221024 r221112  
    2727#pragma once
    2828
    29 #include "FetchHeaders.h"
    30 #include "FetchOptions.h"
    31 #include "ResourceRequest.h"
    32 #include "ResourceResponse.h"
    33 #include "SharedBuffer.h"
     29#include "DOMCache.h"
    3430#include <wtf/HashMap.h>
    3531#include <wtf/ThreadSafeRefCounted.h>
    3632
    3733namespace WebCore {
    38 
    39 struct CacheQueryOptions;
    4034
    4135class CacheStorageConnection : public ThreadSafeRefCounted<CacheStorageConnection> {
     
    4438    virtual ~CacheStorageConnection() = default;
    4539
    46     enum class Error {
    47         None,
    48         NotImplemented,
    49         Internal
    50     };
     40    void open(const String& origin, const String& cacheName, DOMCache::CacheIdentifierCallback&&);
     41    void remove(uint64_t cacheIdentifier, DOMCache::CacheIdentifierCallback&&);
     42    void retrieveCaches(const String& origin, DOMCache::CacheInfosCallback&&);
    5143
    52     static ExceptionOr<void> errorToException(Error);
    53     template<typename T> static ExceptionOr<T> exceptionOrResult(T&& value, Error error)
    54     {
    55         auto result = errorToException(error);
    56         if (result.hasException())
    57             return result.releaseException();
    58         return std::forward<T>(value);
    59     }
    60 
    61     WEBCORE_EXPORT static bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
    62 
    63     using ResponseBody = Variant<std::nullptr_t, Ref<FormData>, Ref<SharedBuffer>>;
    64     static ResponseBody isolatedResponseBody(const ResponseBody&);
    65 
    66     struct Record {
    67         WEBCORE_EXPORT Record copy() const;
    68 
    69         uint64_t identifier;
    70         uint64_t updateResponseCounter;
    71 
    72         FetchHeaders::Guard requestHeadersGuard;
    73         ResourceRequest request;
    74         FetchOptions options;
    75         String referrer;
    76 
    77         FetchHeaders::Guard responseHeadersGuard;
    78         ResourceResponse response;
    79         ResponseBody responseBody;
    80     };
    81 
    82     struct CacheInfo {
    83         uint64_t identifier;
    84         String name;
    85     };
    86 
    87     using OpenRemoveCallback = WTF::Function<void(uint64_t, Error)>;
    88     using CachesCallback = WTF::Function<void(Vector<CacheInfo>&&)>;
    89     using RecordsCallback = WTF::Function<void(Vector<Record>&&)>;
    90     using BatchOperationCallback = WTF::Function<void(Vector<uint64_t>&&, Error)>;
    91 
    92     void open(const String& /* origin */, const String& /* cacheName */, OpenRemoveCallback&&);
    93     void remove(uint64_t /* cacheIdentifier */, OpenRemoveCallback&&);
    94     void retrieveCaches(const String& /* origin */, CachesCallback&&);
    95 
    96     void retrieveRecords(uint64_t /* cacheIdentifier */, RecordsCallback&&);
    97     void batchDeleteOperation(uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&, BatchOperationCallback&&);
    98     void batchPutOperation(uint64_t /* cacheIdentifier */, Vector<Record>&&, BatchOperationCallback&&);
     44    void retrieveRecords(uint64_t cacheIdentifier, DOMCache::RecordsCallback&&);
     45    void batchDeleteOperation(uint64_t cacheIdentifier, const ResourceRequest&, CacheQueryOptions&&, DOMCache::RecordIdentifiersCallback&&);
     46    void batchPutOperation(uint64_t cacheIdentifier, Vector<DOMCache::Record>&&, DOMCache::RecordIdentifiersCallback&&);
    9947
    10048protected:
    10149    CacheStorageConnection() =  default;
    10250
    103     void openCompleted(uint64_t identifier, uint64_t cacheIdentifier, Error error) { openOrRemoveCompleted(identifier, cacheIdentifier, error); }
    104     void removeCompleted(uint64_t identifier, uint64_t cacheIdentifier, Error error) { openOrRemoveCompleted(identifier, cacheIdentifier, error); }
    105     WEBCORE_EXPORT void updateCaches(uint64_t requestIdentifier, Vector<CacheInfo>&&);
     51    void openCompleted(uint64_t identifier, const DOMCache::CacheIdentifierOrError& result) { openOrRemoveCompleted(identifier, result); }
     52    void removeCompleted(uint64_t identifier, const DOMCache::CacheIdentifierOrError& result) { openOrRemoveCompleted(identifier, result); }
     53    WEBCORE_EXPORT void updateCaches(uint64_t requestIdentifier, DOMCache::CacheInfosOrError&&);
    10654
    107     WEBCORE_EXPORT void updateRecords(uint64_t requestIdentifier, Vector<Record>&&);
    108     WEBCORE_EXPORT void deleteRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&&, Error);
    109     WEBCORE_EXPORT void putRecordsCompleted(uint64_t requestIdentifier, Vector<uint64_t>&&, Error);
     55    WEBCORE_EXPORT void updateRecords(uint64_t requestIdentifier, DOMCache::RecordsOrError&&);
     56    WEBCORE_EXPORT void deleteRecordsCompleted(uint64_t requestIdentifier, DOMCache::RecordIdentifiersOrError&&);
     57    WEBCORE_EXPORT void putRecordsCompleted(uint64_t requestIdentifier, DOMCache::RecordIdentifiersOrError&&);
    11058
    11159private:
    112     virtual void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) { openCompleted(requestIdentifier, 0, Error::NotImplemented); }
    113     virtual void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { removeCompleted(requestIdentifier, 0, Error::NotImplemented); }
     60    virtual void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) { openCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
     61    virtual void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { removeCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
    11462    virtual void doRetrieveCaches(uint64_t requestIdentifier, const String& /* origin */) { updateCaches(requestIdentifier, { }); }
    11563
    11664    virtual void doRetrieveRecords(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) { updateRecords(requestIdentifier, { }); }
    117     virtual void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&) { deleteRecordsCompleted(requestIdentifier, { }, Error::NotImplemented); }
    118     virtual void doBatchPutOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, Vector<Record>&&) { putRecordsCompleted(requestIdentifier, { }, Error::NotImplemented); }
     65    virtual void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, const ResourceRequest&, CacheQueryOptions&&) { deleteRecordsCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
     66    virtual void doBatchPutOperation(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */, Vector<DOMCache::Record>&&) { putRecordsCompleted(requestIdentifier, makeUnexpected(DOMCache::Error::NotImplemented)); }
    11967
    120     WEBCORE_EXPORT void openOrRemoveCompleted(uint64_t requestIdentifier, uint64_t cacheIdentifier, Error);
     68    WEBCORE_EXPORT void openOrRemoveCompleted(uint64_t requestIdentifier, const DOMCache::CacheIdentifierOrError&);
    12169
    122     HashMap<uint64_t, OpenRemoveCallback> m_openAndRemoveCachePendingRequests;
    123     HashMap<uint64_t, CachesCallback> m_retrieveCachesPendingRequests;
    124     HashMap<uint64_t, RecordsCallback> m_retrieveRecordsPendingRequests;
    125     HashMap<uint64_t, BatchOperationCallback> m_batchDeleteAndPutPendingRequests;
     70    HashMap<uint64_t, DOMCache::CacheIdentifierCallback> m_openAndRemoveCachePendingRequests;
     71    HashMap<uint64_t, DOMCache::CacheInfosCallback> m_retrieveCachesPendingRequests;
     72    HashMap<uint64_t, DOMCache::RecordsCallback> m_retrieveRecordsPendingRequests;
     73    HashMap<uint64_t, DOMCache::RecordIdentifiersCallback> m_batchDeleteAndPutPendingRequests;
    12674
    12775    uint64_t m_lastRequestIdentifier { 0 };
    12876};
    129 
    13077} // namespace WebCore
    131 
  • trunk/Source/WebCore/Modules/cache/DOMCache.h

    r221111 r221112  
     1
    12/*
    23 * Copyright (C) 2017 Apple Inc. All rights reserved.
     
    2627#pragma once
    2728
    28 #include "WebCoreArgumentCoders.h"
    29 #include <WebCore/CacheStorageConnection.h>
    30 #include <wtf/EnumTraits.h>
     29#include "FetchHeaders.h"
     30#include "FetchOptions.h"
     31#include "ResourceRequest.h"
     32#include "ResourceResponse.h"
     33#include "SharedBuffer.h"
    3134
    32 namespace WebKit {
     35namespace WebCore {
    3336
    34 namespace CacheStorage {
     37struct CacheQueryOptions;
     38
     39namespace DOMCache {
    3540
    3641enum class Error {
     42    NotImplemented,
    3743    Internal
    3844};
    3945
    40 using Record = WebCore::CacheStorageConnection::Record;
     46Exception errorToException(Error);
     47
     48WEBCORE_EXPORT bool queryCacheMatch(const ResourceRequest& request, const ResourceRequest& cachedRequest, const ResourceResponse&, const CacheQueryOptions&);
     49
     50using ResponseBody = Variant<std::nullptr_t, Ref<FormData>, Ref<SharedBuffer>>;
     51ResponseBody isolatedResponseBody(const ResponseBody&);
     52
     53struct Record {
     54    WEBCORE_EXPORT Record copy() const;
     55
     56    uint64_t identifier;
     57    uint64_t updateResponseCounter;
     58
     59    FetchHeaders::Guard requestHeadersGuard;
     60    ResourceRequest request;
     61    FetchOptions options;
     62    String referrer;
     63
     64    FetchHeaders::Guard responseHeadersGuard;
     65    ResourceResponse response;
     66    ResponseBody responseBody;
     67};
     68
     69struct CacheInfo {
     70    uint64_t identifier;
     71    String name;
     72};
    4173
    4274using CacheIdentifierOrError = Expected<uint64_t, Error>;
    43 using CacheIdentifierCallback = Function<void(CacheIdentifierOrError&&)>;
     75using CacheIdentifierCallback = WTF::Function<void(const CacheIdentifierOrError&)>;
    4476
    45 using CacheInfosOrError = Expected<Vector<WebCore::CacheStorageConnection::CacheInfo>, Error>;
    46 using CacheInfosCallback = Function<void(CacheInfosOrError&&)>;
     77using RecordIdentifiersOrError = Expected<Vector<uint64_t>, Error>;
     78using RecordIdentifiersCallback = WTF::Function<void(RecordIdentifiersOrError&&)>;
     79
     80using CacheInfosOrError = Expected<Vector<WebCore::DOMCache::CacheInfo>, Error>;
     81using CacheInfosCallback = WTF::Function<void(CacheInfosOrError&&)>;
    4782
    4883using RecordsOrError = Expected<Vector<Record>, Error>;
    49 using RecordsCallback = Function<void(RecordsOrError&&)>;
    50 
    51 using RecordIdentifiersOrError = Expected<Vector<uint64_t>, Error>;
    52 using RecordIdentifiersCallback = Function<void(RecordIdentifiersOrError&&)>;
     84using RecordsCallback = WTF::Function<void(RecordsOrError&&)>;
    5385
    5486using CompletionCallback = Function<void(std::optional<Error>&&)>;
    5587
    56 } // namespace CacheStorage
     88} // namespace DOMCache
    5789
    58 } // namespace WebKit
     90} // namespace WebCore
    5991
    6092namespace WTF {
    61 template<> struct EnumTraits<WebKit::CacheStorage::Error> {
     93template<> struct EnumTraits<WebCore::DOMCache::Error> {
    6294    using values = EnumValues<
    63         WebKit::CacheStorage::Error,
    64         WebKit::CacheStorage::Error::Internal
     95        WebCore::DOMCache::Error,
     96        WebCore::DOMCache::Error::NotImplemented,
     97        WebCore::DOMCache::Error::Internal
    6598    >;
    6699};
  • trunk/Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp

    r221024 r221112  
    3737#include "WorkerThread.h"
    3838
     39using namespace WebCore::DOMCache;
     40
    3941namespace WebCore {
    4042
     
    5153    FetchHeaders::Guard responseHeadersGuard;
    5254    ResourceResponse::CrossThreadData response;
    53     CacheStorageConnection::ResponseBody responseBody;
     55    ResponseBody responseBody;
    5456};
    5557
    56 static CrossThreadRecordData toCrossThreadRecordData(const CacheStorageConnection::Record& record)
     58static CrossThreadRecordData toCrossThreadRecordData(const Record& record)
    5759{
    5860    return CrossThreadRecordData {
     
    6567        record.responseHeadersGuard,
    6668        record.response.crossThreadData(),
    67         CacheStorageConnection::isolatedResponseBody(record.responseBody)
     69        isolatedResponseBody(record.responseBody)
    6870    };
    6971}
    7072
    71 static CacheStorageConnection::Record fromCrossThreadRecordData(CrossThreadRecordData&& data)
    72 {
    73     return CacheStorageConnection::Record {
     73static Record fromCrossThreadRecordData(CrossThreadRecordData&& data)
     74{
     75    return Record {
    7476        data.identifier,
    7577        data.updateResponseCounter,
     
    116118        ASSERT(m_mainThreadConnection);
    117119
    118         m_mainThreadConnection->open(origin, cacheName, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](uint64_t cacheIdentifier, Error error) mutable {
    119             m_proxy.postTaskForModeToWorkerGlobalScope([this, error, cacheIdentifier, protectedThis = WTFMove(protectedThis), requestIdentifier](ScriptExecutionContext& context) mutable {
    120                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    121                 openCompleted(requestIdentifier, cacheIdentifier, error);
     120        m_mainThreadConnection->open(origin, cacheName, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](const CacheIdentifierOrError& result) mutable {
     121            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result](ScriptExecutionContext& context) mutable {
     122                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     123                openCompleted(requestIdentifier, result);
    122124            }, m_taskMode);
    123125        });
     
    131133        ASSERT(m_mainThreadConnection);
    132134
    133         m_mainThreadConnection->remove(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier](uint64_t removedCacheIdentifier, Error error) mutable {
    134             ASSERT_UNUSED(removedCacheIdentifier, removedCacheIdentifier == cacheIdentifier);
    135             m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier, error](ScriptExecutionContext& context) mutable {
    136                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    137                 removeCompleted(requestIdentifier, cacheIdentifier, error);
     135        m_mainThreadConnection->remove(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier, cacheIdentifier](const CacheIdentifierOrError& result) mutable {
     136            ASSERT(!result.hasValue() || result.value() == cacheIdentifier);
     137            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result](ScriptExecutionContext& context) mutable {
     138                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     139                removeCompleted(requestIdentifier, result);
    138140            }, m_taskMode);
    139141        });
     
    147149        ASSERT(m_mainThreadConnection);
    148150
    149         m_mainThreadConnection->retrieveCaches(origin, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](const Vector<CacheInfo>& caches) mutable {
    150             Vector<CacheInfo> isolatedCaches;
    151             isolatedCaches.reserveInitialCapacity(caches.size());
    152             for (const auto& cache : caches)
    153                 isolatedCaches.uncheckedAppend(CacheInfo { cache.identifier, cache.name.isolatedCopy() });
    154 
    155             m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), caches = WTFMove(isolatedCaches), requestIdentifier](ScriptExecutionContext& context) mutable {
    156                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    157                 updateCaches(requestIdentifier, WTFMove(caches));
    158             }, m_taskMode);
    159         });
    160     });
    161 }
    162 
    163 static inline Vector<CrossThreadRecordData> recordsDataFromRecords(const Vector<CacheStorageConnection::Record>& records)
     151        m_mainThreadConnection->retrieveCaches(origin, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](CacheInfosOrError&& result) mutable {
     152            CacheInfosOrError isolatedResult;
     153            if (!result.hasValue())
     154                isolatedResult = WTFMove(result);
     155            else {
     156                Vector<CacheInfo> isolatedCaches;
     157                isolatedCaches.reserveInitialCapacity(result.value().size());
     158                for (const auto& cache : result.value())
     159                    isolatedCaches.uncheckedAppend(CacheInfo { cache.identifier, cache.name.isolatedCopy() });
     160                isolatedResult = WTFMove(isolatedCaches);
     161            }
     162            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(isolatedResult)](ScriptExecutionContext& context) mutable {
     163                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     164                updateCaches(requestIdentifier, WTFMove(result));
     165            }, m_taskMode);
     166        });
     167    });
     168}
     169
     170static inline Vector<CrossThreadRecordData> recordsDataFromRecords(const Vector<Record>& records)
    164171{
    165172    Vector<CrossThreadRecordData> recordsData;
     
    170177}
    171178
    172 static inline Vector<CacheStorageConnection::Record> recordsFromRecordsData(Vector<CrossThreadRecordData>&& recordsData)
    173 {
    174     Vector<CacheStorageConnection::Record> records;
     179static inline Expected<Vector<CrossThreadRecordData>, Error> recordsDataOrErrorFromRecords(const RecordsOrError& result)
     180{
     181    if (!result.hasValue())
     182        return makeUnexpected(result.error());
     183
     184    return recordsDataFromRecords(result.value());
     185}
     186
     187static inline Vector<Record> recordsFromRecordsData(Vector<CrossThreadRecordData>&& recordsData)
     188{
     189    Vector<Record> records;
    175190    records.reserveInitialCapacity(recordsData.size());
    176191    for (auto& recordData : recordsData)
     
    179194}
    180195
     196static inline RecordsOrError recordsOrErrorFromRecordsData(Expected<Vector<CrossThreadRecordData>, Error>&& recordsData)
     197{
     198    if (!recordsData.hasValue())
     199        return makeUnexpected(recordsData.error());
     200    return recordsFromRecordsData(WTFMove(recordsData.value()));
     201}
     202
    181203void WorkerCacheStorageConnection::doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier)
    182204{
     
    185207        ASSERT(m_mainThreadConnection);
    186208
    187         m_mainThreadConnection->retrieveRecords(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<Record>&& records) mutable {
    188             m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), recordsData = recordsDataFromRecords(records), requestIdentifier](ScriptExecutionContext& context) mutable {
    189                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    190                 updateRecords(requestIdentifier, recordsFromRecordsData(WTFMove(recordsData)));
     209        m_mainThreadConnection->retrieveRecords(cacheIdentifier, [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordsOrError&& result) mutable {
     210            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), result = recordsDataOrErrorFromRecords(result), requestIdentifier](ScriptExecutionContext& context) mutable {
     211                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     212                updateRecords(requestIdentifier, recordsOrErrorFromRecordsData(WTFMove(result)));
    191213            }, m_taskMode);
    192214        });
     
    200222        ASSERT(m_mainThreadConnection);
    201223
    202         m_mainThreadConnection->batchDeleteOperation(cacheIdentifier, request, WTFMove(options), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<uint64_t>&& records, Error error) mutable {
    203 
    204             m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), records = WTFMove(records), error, requestIdentifier](ScriptExecutionContext& context) mutable {
    205                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    206                 deleteRecordsCompleted(requestIdentifier, WTFMove(records), error);
     224        m_mainThreadConnection->batchDeleteOperation(cacheIdentifier, request, WTFMove(options), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordIdentifiersOrError&& result) mutable {
     225
     226            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(result)](ScriptExecutionContext& context) mutable {
     227                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     228                deleteRecordsCompleted(requestIdentifier, WTFMove(result));
    207229            }, m_taskMode);
    208230        });
     
    216238        ASSERT(m_mainThreadConnection);
    217239
    218         m_mainThreadConnection->batchPutOperation(cacheIdentifier, recordsFromRecordsData(WTFMove(recordsData)), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](Vector<uint64_t>&& records, Error error) mutable {
    219 
    220             m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), records = WTFMove(records), error, requestIdentifier](ScriptExecutionContext& context) mutable {
    221                 ASSERT_UNUSED(context, context.isWorkerGlobalScope());
    222                 putRecordsCompleted(requestIdentifier, WTFMove(records), error);
     240        m_mainThreadConnection->batchPutOperation(cacheIdentifier, recordsFromRecordsData(WTFMove(recordsData)), [this, protectedThis = WTFMove(protectedThis), requestIdentifier](RecordIdentifiersOrError&& result) mutable {
     241
     242            m_proxy.postTaskForModeToWorkerGlobalScope([this, protectedThis = WTFMove(protectedThis), requestIdentifier, result = WTFMove(result)](ScriptExecutionContext& context) mutable {
     243                ASSERT_UNUSED(context, context.isWorkerGlobalScope());
     244                putRecordsCompleted(requestIdentifier, WTFMove(result));
    223245            }, m_taskMode);
    224246        });
  • trunk/Source/WebCore/Modules/cache/WorkerCacheStorageConnection.h

    r220810 r221112  
    4343
    4444    // WebCore::CacheStorageConnection
    45     void doOpen(uint64_t requestIdentifier, const String& /* origin */, const String& /* cacheName */) final;
    46     void doRemove(uint64_t requestIdentifier, uint64_t /* cacheIdentifier */) final;
    47     void doRetrieveCaches(uint64_t requestIdentifier, const String& /* origin */) final;
     45    void doOpen(uint64_t requestIdentifier, const String& origin, const String& cacheName) final;
     46    void doRemove(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
     47    void doRetrieveCaches(uint64_t requestIdentifier, const String& origin) final;
    4848
    4949    void doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
    5050    void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, const WebCore::ResourceRequest&, WebCore::CacheQueryOptions&&) final;
    51     void doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&&) final;
     51    void doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<DOMCache::Record>&&) final;
    5252
    5353    WorkerGlobalScope& m_scope;
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r220979 r221112  
    17931793                41FA303E1316C29C00C0BFC5 /* RenderMediaControls.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */; };
    17941794                41FA303F1316C29C00C0BFC5 /* RenderMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FA303D1316C29C00C0BFC5 /* RenderMediaControls.h */; };
     1795                41FABD2D1F4DFE4A006A6C97 /* DOMCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD2B1F4DFE42006A6C97 /* DOMCache.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1796                41FABD2F1F4E02CB006A6C97 /* DOMCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */; };
    17951797                41FB279C1F34DB8A00795487 /* DOMWindowCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */; };
    17961798                41FB279D1F34DB8E00795487 /* WorkerGlobalScopeCaches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41FB278F1F34C28200795487 /* WorkerGlobalScopeCaches.cpp */; };
     
    94809482                41FA303C1316C29C00C0BFC5 /* RenderMediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMediaControls.cpp; sourceTree = "<group>"; };
    94819483                41FA303D1316C29C00C0BFC5 /* RenderMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMediaControls.h; sourceTree = "<group>"; };
     9484                41FABD2B1F4DFE42006A6C97 /* DOMCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMCache.h; sourceTree = "<group>"; };
     9485                41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMCache.cpp; sourceTree = "<group>"; };
    94829486                41FB278C1F34C28200795487 /* DOMWindowCaches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DOMWindowCaches.h; sourceTree = "<group>"; };
    94839487                41FB278D1F34C28200795487 /* WorkerGlobalScopeCaches.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WorkerGlobalScopeCaches.h; sourceTree = "<group>"; };
     
    1769117695                                41D129CC1F3D0EE300D15E47 /* CacheStorageConnection.h */,
    1769217696                                41D129CA1F3D0EE300D15E47 /* CacheStorageRecord.h */,
     17697                                41FABD2E1F4E0251006A6C97 /* DOMCache.cpp */,
     17698                                41FABD2B1F4DFE42006A6C97 /* DOMCache.h */,
    1769317699                                41FB278E1F34C28200795487 /* DOMWindowCaches.cpp */,
    1769417700                                41FB278C1F34C28200795487 /* DOMWindowCaches.h */,
     
    2723227238                                973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */,
    2723327239                                1A8F6BC30DB55CDC001DB794 /* DOMApplicationCache.h in Headers */,
     27240                                41FABD2D1F4DFE4A006A6C97 /* DOMCache.h in Headers */,
    2723427241                                FC9A0F75164094CF003D6B8D /* DOMCSSNamespace.h in Headers */,
    2723527242                                9B3A8872145632F9003AE8F5 /* DOMDOMSettableTokenList.h in Headers */,
     
    3126431271                                973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */,
    3126531272                                1A8F6BC20DB55CDC001DB794 /* DOMApplicationCache.cpp in Sources */,
     31273                                41FABD2F1F4E02CB006A6C97 /* DOMCache.cpp in Sources */,
    3126631274                                FD677738195CAF3D0072E0D3 /* DOMCSSNamespace.cpp in Sources */,
    3126731275                                7AABA25914BC613300AA9A11 /* DOMEditor.cpp in Sources */,
  • trunk/Source/WebKit/ChangeLog

    r221102 r221112  
     12017-08-23  Youenn Fablet  <youenn@apple.com>
     2
     3        [Cache API] Unify WebCore and WebKit error handling
     4        https://bugs.webkit.org/show_bug.cgi?id=175902
     5
     6        Reviewed by Alex Christensen.
     7
     8        Removing all callbacks and error definitions from WebKit
     9        and reusing DOMCache ones instead.
     10
     11        * NetworkProcess/cache/CacheStorage.h: Removed.
     12        * NetworkProcess/cache/CacheStorageEngine.cpp:
     13        (WebKit::CacheStorage::Engine::caches const):
     14        (WebKit::CacheStorage::Engine::queryCache):
     15        * NetworkProcess/cache/CacheStorageEngine.h:
     16        * NetworkProcess/cache/CacheStorageEngineCache.h:
     17        * NetworkProcess/cache/CacheStorageEngineConnection.cpp:
     18        (WebKit::CacheStorageEngineConnection::open):
     19        (WebKit::CacheStorageEngineConnection::remove):
     20        (WebKit::CacheStorageEngineConnection::putRecords):
     21        * NetworkProcess/cache/CacheStorageEngineConnection.h:
     22        * NetworkProcess/cache/CacheStorageEngineConnection.messages.in:
     23        * Shared/WebCoreArgumentCoders.cpp:
     24        (IPC::ArgumentCoder<DOMCache::CacheInfo>::encode):
     25        (IPC::ArgumentCoder<DOMCache::CacheInfo>::decode):
     26        (IPC::ArgumentCoder<DOMCache::Record>::encode):
     27        (IPC::ArgumentCoder<DOMCache::Record>::decode):
     28        * Shared/WebCoreArgumentCoders.h:
     29        * WebProcess/Cache/WebCacheStorageConnection.cpp:
     30        (WebKit::WebCacheStorageConnection::doBatchPutOperation):
     31        (WebKit::WebCacheStorageConnection::openCompleted):
     32        (WebKit::WebCacheStorageConnection::removeCompleted):
     33        (WebKit::WebCacheStorageConnection::updateCaches):
     34        (WebKit::WebCacheStorageConnection::updateRecords):
     35        (WebKit::WebCacheStorageConnection::deleteRecordsCompleted):
     36        (WebKit::WebCacheStorageConnection::putRecordsCompleted):
     37        * WebProcess/Cache/WebCacheStorageConnection.h:
     38        * WebProcess/Cache/WebCacheStorageConnection.messages.in:
     39
    1402017-08-23  Alex Christensen  <achristensen@webkit.org>
    241
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

    r221093 r221112  
    3333#include <wtf/text/StringHash.h>
    3434
     35using namespace WebCore::DOMCache;
     36
    3537namespace WebKit {
    3638
     
    127129        auto& caches = cachesOrError.value().get();
    128130
    129         Vector<WebCore::CacheStorageConnection::CacheInfo> cachesInfo;
     131        Vector<CacheInfo> cachesInfo;
    130132        cachesInfo.reserveInitialCapacity(caches.size());
    131133        for (auto& cache : caches)
    132             cachesInfo.uncheckedAppend(WebCore::CacheStorageConnection::CacheInfo { cache.identifier, cache.name});
     134            cachesInfo.uncheckedAppend(CacheInfo { cache.identifier, cache.name});
    133135
    134136        callback(WTFMove(cachesInfo));
     
    298300    Vector<uint64_t> results;
    299301    for (const auto& record : records) {
    300         if (WebCore::CacheStorageConnection::queryCacheMatch(request, record.request, record.response, options))
     302        if (WebCore::DOMCache::queryCacheMatch(request, record.request, record.response, options))
    301303            results.append(record.identifier);
    302304    }
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h

    r221093 r221112  
    4646    static void destroyEngine(PAL::SessionID);
    4747
    48     void open(const String& origin, const String& cacheName, CacheIdentifierCallback&&);
    49     void remove(uint64_t cacheIdentifier, CacheIdentifierCallback&&);
    50     void retrieveCaches(const String& origin, CacheInfosCallback&&);
     48    void open(const String& origin, const String& cacheName, WebCore::DOMCache::CacheIdentifierCallback&&);
     49    void remove(uint64_t cacheIdentifier, WebCore::DOMCache::CacheIdentifierCallback&&);
     50    void retrieveCaches(const String& origin, WebCore::DOMCache::CacheInfosCallback&&);
    5151
    52     void retrieveRecords(uint64_t cacheIdentifier, RecordsCallback&&);
    53     void putRecords(uint64_t cacheIdentifier, Vector<Record>&&, RecordIdentifiersCallback&&);
    54     void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, RecordIdentifiersCallback&&);
     52    void retrieveRecords(uint64_t cacheIdentifier, WebCore::DOMCache::RecordsCallback&&);
     53    void putRecords(uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
     54    void deleteMatchingRecords(uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
    5555
    5656private:
    5757    static Engine& defaultEngine();
    5858
    59     void writeCachesToDisk(CompletionCallback&&);
     59    void writeCachesToDisk(WebCore::DOMCache::CompletionCallback&&);
    6060
    61     using CachesOrError = Expected<std::reference_wrapper<Vector<Cache>>, Error>;
    62     using CachesCallback = Function<void(CachesOrError&&)>;
    63     void readCachesFromDisk(const String& origin, Function<void(CachesOrError&&)>&&);
     61    using CachesOrError = Expected<std::reference_wrapper<Vector<Cache>>, WebCore::DOMCache::Error>;
     62    using CachesCallback = WTF::Function<void(CachesOrError&&)>;
     63    void readCachesFromDisk(const String& origin, CachesCallback&&);
    6464
    65     using CacheOrError = Expected<std::reference_wrapper<Cache>, Error>;
    66     using CacheCallback = Function<void(CacheOrError&&)>;
     65    using CacheOrError = Expected<std::reference_wrapper<Cache>, WebCore::DOMCache::Error>;
     66    using CacheCallback = WTF::Function<void(CacheOrError&&)>;
     67    void readCache(uint64_t cacheIdentifier, CacheCallback&&);
    6768
    68     void readCache(uint64_t cacheIdentifier, CacheCallback&&);
    69     void writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, RecordIdentifiersCallback&&);
    70     void removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, RecordIdentifiersCallback&&);
     69    void writeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
     70    void removeCacheRecords(uint64_t cacheIdentifier, Vector<uint64_t>&&, WebCore::DOMCache::RecordIdentifiersCallback&&);
    7171
    72     Vector<uint64_t> queryCache(const Vector<Record>&, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&);
     72    Vector<uint64_t> queryCache(const Vector<WebCore::DOMCache::Record>&, const WebCore::ResourceRequest&, const WebCore::CacheQueryOptions&);
    7373
    7474    Cache* cache(uint64_t cacheIdentifier);
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h

    r221093 r221112  
    2626#pragma once
    2727
    28 #include "CacheStorage.h"
     28#include <WebCore/DOMCache.h>
    2929#include <wtf/Vector.h>
    3030#include <wtf/text/WTFString.h>
     
    3737    uint64_t identifier { 0 };
    3838    String name;
    39     Vector<Record> records;
     39    Vector<WebCore::DOMCache::Record> records;
    4040    uint64_t nextRecordIdentifier { 0 };
    4141};
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.cpp

    r221093 r221112  
    3030#include "NetworkConnectionToWebProcess.h"
    3131#include "WebCacheStorageConnectionMessages.h"
     32#include "WebCoreArgumentCoders.h"
    3233#include <WebCore/CacheQueryOptions.h>
    3334
     35using namespace WebCore::DOMCache;
    3436using namespace WebKit::CacheStorage;
    3537
     
    4345void CacheStorageEngineConnection::open(PAL::SessionID sessionID, uint64_t requestIdentifier, const String& origin, const String& cacheName)
    4446{
    45     Engine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
     47    Engine::from(sessionID).open(origin, cacheName, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
    4648        m_connection.connection().send(Messages::WebCacheStorageConnection::OpenCompleted(requestIdentifier, result), sessionID.sessionID());
    4749    });
     
    5052void CacheStorageEngineConnection::remove(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier)
    5153{
    52     Engine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](CacheIdentifierOrError&& result) {
     54    Engine::from(sessionID).remove(cacheIdentifier, [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](const CacheIdentifierOrError& result) {
    5355        m_connection.connection().send(Messages::WebCacheStorageConnection::RemoveCompleted(requestIdentifier, result), sessionID.sessionID());
    5456    });
     
    7678}
    7779
    78 void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records)
     80void CacheStorageEngineConnection::putRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
    7981{
    8082    Engine::from(sessionID).putRecords(cacheIdentifier, WTFMove(records), [protectedThis = makeRef(*this), this, sessionID, requestIdentifier](RecordIdentifiersOrError&& result) {
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.h

    r220917 r221112  
    5757    void records(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier);
    5858    void deleteMatchingRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest&&, WebCore::CacheQueryOptions&&);
    59     void putRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&&);
     59    void putRecords(PAL::SessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&);
    6060
    6161    NetworkConnectionToWebProcess& m_connection;
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineConnection.messages.in

    r220917 r221112  
    2828    Records(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier);
    2929    DeleteMatchingRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, WebCore::ResourceRequest request, struct WebCore::CacheQueryOptions options);
    30     PutRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record> record);
     30    PutRecords(PAL::SessionID sessionID, uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record> record);
    3131}
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r221086 r221112  
    215215}
    216216
    217 void ArgumentCoder<CacheStorageConnection::CacheInfo>::encode(Encoder& encoder, const CacheStorageConnection::CacheInfo& info)
     217void ArgumentCoder<DOMCache::CacheInfo>::encode(Encoder& encoder, const DOMCache::CacheInfo& info)
    218218{
    219219    encoder << info.identifier;
     
    221221}
    222222
    223 bool ArgumentCoder<CacheStorageConnection::CacheInfo>::decode(Decoder& decoder, CacheStorageConnection::CacheInfo& record)
     223bool ArgumentCoder<DOMCache::CacheInfo>::decode(Decoder& decoder, DOMCache::CacheInfo& record)
    224224{
    225225    uint64_t identifier;
     
    237237}
    238238
    239 void ArgumentCoder<CacheStorageConnection::Record>::encode(Encoder& encoder, const CacheStorageConnection::Record& record)
     239void ArgumentCoder<DOMCache::Record>::encode(Encoder& encoder, const DOMCache::Record& record)
    240240{
    241241    encoder << record.identifier;
     
    263263}
    264264
    265 bool ArgumentCoder<CacheStorageConnection::Record>::decode(Decoder& decoder, CacheStorageConnection::Record& record)
     265bool ArgumentCoder<DOMCache::Record>::decode(Decoder& decoder, DOMCache::Record& record)
    266266{
    267267    uint64_t identifier;
     
    297297        return false;
    298298
    299     WebCore::CacheStorageConnection::ResponseBody responseBody;
     299    WebCore::DOMCache::ResponseBody responseBody;
    300300    bool hasSharedBufferBody;
    301301    if (!decoder.decode(hasSharedBufferBody))
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h

    r221086 r221112  
    201201};
    202202
    203 template<> struct ArgumentCoder<WebCore::CacheStorageConnection::CacheInfo> {
    204     static void encode(Encoder&, const WebCore::CacheStorageConnection::CacheInfo&);
    205     static bool decode(Decoder&, WebCore::CacheStorageConnection::CacheInfo&);
    206 };
    207 
    208 template<> struct ArgumentCoder<WebCore::CacheStorageConnection::Record> {
    209     static void encode(Encoder&, const WebCore::CacheStorageConnection::Record&);
    210     static bool decode(Decoder&, WebCore::CacheStorageConnection::Record&);
     203template<> struct ArgumentCoder<WebCore::DOMCache::CacheInfo> {
     204    static void encode(Encoder&, const WebCore::DOMCache::CacheInfo&);
     205    static bool decode(Decoder&, WebCore::DOMCache::CacheInfo&);
     206};
     207
     208template<> struct ArgumentCoder<WebCore::DOMCache::Record> {
     209    static void encode(Encoder&, const WebCore::DOMCache::Record&);
     210    static bool decode(Decoder&, WebCore::DOMCache::Record&);
    211211};
    212212
     
    787787};
    788788
    789 template<> struct EnumTraits<WebCore::CacheStorageConnection::Error> {
    790     using values = EnumValues<
    791         WebCore::CacheStorageConnection::Error,
    792         WebCore::CacheStorageConnection::Error::None,
    793         WebCore::CacheStorageConnection::Error::NotImplemented
    794     >;
    795 };
    796 
    797789} // namespace WTF
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r221093 r221112  
    907907                41DC459F1E3DBDA500B11F51 /* WebRTCSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */; };
    908908                41DC45A11E3DC53F00B11F51 /* WebRTCResolver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41DC45A01E3DC53C00B11F51 /* WebRTCResolver.cpp */; };
    909                 41FABD291F4DE001006A6C97 /* CacheStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD271F4DDFDC006A6C97 /* CacheStorage.h */; };
    910909                41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */; };
    911910                41FAF5F51E3C0649001AE678 /* WebRTCResolver.h in Headers */ = {isa = PBXBuildFile; fileRef = 41FAF5F41E3C0641001AE678 /* WebRTCResolver.h */; };
     
    31803179                41DC459D1E3DBCF000B11F51 /* WebRTCSocket.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCSocket.cpp; path = Network/webrtc/WebRTCSocket.cpp; sourceTree = "<group>"; };
    31813180                41DC45A01E3DC53C00B11F51 /* WebRTCResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebRTCResolver.cpp; path = Network/webrtc/WebRTCResolver.cpp; sourceTree = "<group>"; };
    3182                 41FABD271F4DDFDC006A6C97 /* CacheStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorage.h; sourceTree = "<group>"; };
    31833181                41FABD281F4DDFDC006A6C97 /* CacheStorageEngineCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CacheStorageEngineCache.h; sourceTree = "<group>"; };
    31843182                41FAF5F31E3BFE7F001AE678 /* WebRTCSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebRTCSocket.h; path = Network/webrtc/WebRTCSocket.h; sourceTree = "<group>"; };
     
    81958193                        isa = PBXGroup;
    81968194                        children = (
    8197                                 41FABD271F4DDFDC006A6C97 /* CacheStorage.h */,
    81988195                                41897ED61F415D860016FA42 /* CacheStorageEngine.cpp */,
    81998196                                41897ED21F415D850016FA42 /* CacheStorageEngine.h */,
     
    84318428                                1A5705111BE410E600874AF1 /* BlockSPI.h in Headers */,
    84328429                                BC3065FA1259344E00E71278 /* CacheModel.h in Headers */,
    8433                                 41FABD291F4DE001006A6C97 /* CacheStorage.h in Headers */,
    84348430                                41897ED81F415D8A0016FA42 /* CacheStorageEngine.h in Headers */,
    84358431                                41FABD2A1F4DE001006A6C97 /* CacheStorageEngineCache.h in Headers */,
  • trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.cpp

    r221093 r221112  
    2727#include "WebCacheStorageConnection.h"
    2828
     29#include "CacheStorageEngine.h"
    2930#include "CacheStorageEngineConnectionMessages.h"
    3031#include "NetworkConnectionToWebProcessMessages.h"
     
    3536#include <wtf/MainThread.h>
    3637
     38using namespace WebCore::DOMCache;
    3739using namespace WebKit::CacheStorage;
    3840
     
    8082}
    8183
    82 void WebCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::CacheStorageConnection::Record>&& records)
     84void WebCacheStorageConnection::doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&& records)
    8385{
    8486    connection().send(Messages::CacheStorageEngineConnection::PutRecords(m_sessionID, requestIdentifier, cacheIdentifier, records), 0);
    8587}
    8688
    87 void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
     89void WebCacheStorageConnection::openCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
    8890{
    89     CacheStorageConnection::openCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
     91    CacheStorageConnection::openCompleted(requestIdentifier, result);
    9092}
    9193
    92 void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, CacheIdentifierOrError&& result)
     94void WebCacheStorageConnection::removeCompleted(uint64_t requestIdentifier, const CacheIdentifierOrError& result)
    9395{
    94     CacheStorageConnection::removeCompleted(requestIdentifier, result.hasValue() ? result.value() : 0, !result.hasValue() ? Error::Internal : Error::None);
     96    CacheStorageConnection::removeCompleted(requestIdentifier, result);
    9597}
    9698
    9799void WebCacheStorageConnection::updateCaches(uint64_t requestIdentifier, CacheInfosOrError&& result)
    98100{
    99     CacheStorageConnection::updateCaches(requestIdentifier, result.hasValue() ? result.value() : Vector<CacheInfo>());
     101    CacheStorageConnection::updateCaches(requestIdentifier, WTFMove(result));
    100102}
    101103
    102104void WebCacheStorageConnection::updateRecords(uint64_t requestIdentifier, RecordsOrError&& result)
    103105{
    104     CacheStorageConnection::updateRecords(requestIdentifier, result.hasValue() ? WTFMove(result.value()) : Vector<Record>());
     106    CacheStorageConnection::updateRecords(requestIdentifier, WTFMove(result));
    105107}
    106108
    107109void WebCacheStorageConnection::deleteRecordsCompleted(uint64_t requestIdentifier, RecordIdentifiersOrError&& result)
    108110{
    109     CacheStorageConnection::deleteRecordsCompleted(requestIdentifier, result.hasValue() ? result.value() : Vector<uint64_t>(), !result.hasValue() ? Error::Internal : Error::None);
     111    CacheStorageConnection::deleteRecordsCompleted(requestIdentifier, WTFMove(result));
    110112}
    111113
    112114void WebCacheStorageConnection::putRecordsCompleted(uint64_t requestIdentifier, RecordIdentifiersOrError&& result)
    113115{
    114     CacheStorageConnection::putRecordsCompleted(requestIdentifier, result.hasValue() ? result.value() : Vector<uint64_t>(), !result.hasValue() ? Error::Internal : Error::None);
     116    CacheStorageConnection::putRecordsCompleted(requestIdentifier, WTFMove(result));
    115117}
    116118
  • trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.h

    r221093 r221112  
    2626#pragma once
    2727
    28 #include "CacheStorage.h"
    2928#include <WebCore/CacheStorageConnection.h>
    3029#include <wtf/HashMap.h>
     
    6059    void doRetrieveRecords(uint64_t requestIdentifier, uint64_t cacheIdentifier) final;
    6160    void doBatchDeleteOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, const WebCore::ResourceRequest&, WebCore::CacheQueryOptions&&) final;
    62     void doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<Record>&&) final;
     61    void doBatchPutOperation(uint64_t requestIdentifier, uint64_t cacheIdentifier, Vector<WebCore::DOMCache::Record>&&) final;
    6362
    64     void openCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
    65     void removeCompleted(uint64_t requestIdentifier, CacheStorage::CacheIdentifierOrError&&);
    66     void updateCaches(uint64_t requestIdentifier, CacheStorage::CacheInfosOrError&&);
     63    void openCompleted(uint64_t requestIdentifier, const WebCore::DOMCache::CacheIdentifierOrError&);
     64    void removeCompleted(uint64_t requestIdentifier, const WebCore::DOMCache::CacheIdentifierOrError&);
     65    void updateCaches(uint64_t requestIdentifier, WebCore::DOMCache::CacheInfosOrError&&);
    6766
    68     void updateRecords(uint64_t requestIdentifier, CacheStorage::RecordsOrError&&);
    69     void deleteRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
    70     void putRecordsCompleted(uint64_t requestIdentifier, CacheStorage::RecordIdentifiersOrError&&);
     67    void updateRecords(uint64_t requestIdentifier, WebCore::DOMCache::RecordsOrError&&);
     68    void deleteRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError&&);
     69    void putRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError&&);
    7170
    7271    WebCacheStorageProvider& m_provider;
  • trunk/Source/WebKit/WebProcess/Cache/WebCacheStorageConnection.messages.in

    r221093 r221112  
    2222
    2323messages -> WebCacheStorageConnection {
    24     OpenCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
    25     RemoveCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::CacheIdentifierOrError result);
    26     UpdateCaches(uint64_t requestIdentifier, WebKit::CacheStorage::CacheInfosOrError result);
     24    OpenCompleted(uint64_t requestIdentifier, WebCore::DOMCache::CacheIdentifierOrError result);
     25    RemoveCompleted(uint64_t requestIdentifier, WebCore::DOMCache::CacheIdentifierOrError result);
     26    UpdateCaches(uint64_t requestIdentifier, WebCore::DOMCache::CacheInfosOrError result);
    2727
    28     UpdateRecords(uint64_t requestIdentifier, WebKit::CacheStorage::RecordsOrError result);
    29     DeleteRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::RecordIdentifiersOrError result);
    30     PutRecordsCompleted(uint64_t requestIdentifier, WebKit::CacheStorage::RecordIdentifiersOrError result);
     28    UpdateRecords(uint64_t requestIdentifier, WebCore::DOMCache::RecordsOrError result);
     29    DeleteRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError result);
     30    PutRecordsCompleted(uint64_t requestIdentifier, WebCore::DOMCache::RecordIdentifiersOrError result);
    3131}
Note: See TracChangeset for help on using the changeset viewer.