Changeset 223073 in webkit


Ignore:
Timestamp:
Oct 9, 2017 3:17:05 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Add quota to cache API
https://bugs.webkit.org/show_bug.cgi?id=177552

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

Source/WebCore:

Tests: http/wpt/cache-storage/cache-quota.any.html

Storing padded opaque response body sizes within FetchResponse and CacheStorageConnection.
See https://github.com/whatwg/storage/issues/31 for the rationale about this padding.
Storing in CacheStorageConnection is needed for handling cloned network fetched created responses.
Storing in FetchResponse is needed for handling cloned cache-storage created opaque responses.

Adding internals to query and set the fuzzed size of a response.

  • Modules/cache/CacheStorageConnection.cpp:

(WebCore::computeRealBodySize):
(WebCore::CacheStorageConnection::computeRecordBodySize):
(WebCore::CacheStorageConnection::setResponseBodySizeWithPadding):
(WebCore::CacheStorageConnection::responseBodySizeWithPadding const):

  • Modules/cache/CacheStorageConnection.h:
  • Modules/cache/DOMCache.cpp:

(WebCore::DOMCache::toConnectionRecord):
(WebCore::DOMCache::updateRecords):

  • Modules/cache/DOMCache.h:
  • Modules/cache/DOMCacheEngine.cpp:

(WebCore::DOMCacheEngine::errorToException):
(WebCore::DOMCacheEngine::Record::copy const):

  • Modules/cache/DOMCacheEngine.h:
  • Modules/cache/WorkerCacheStorageConnection.cpp:

(WebCore::toCrossThreadRecordData):
(WebCore::fromCrossThreadRecordData):

  • Modules/fetch/FetchResponse.cpp:

(WebCore::FetchResponse::clone):
(WebCore::FetchResponse::BodyLoader::didReceiveResponse):

  • Modules/fetch/FetchResponse.h:
  • Modules/fetch/FetchResponse.idl:
  • testing/Internals.cpp:

(WebCore::Internals::setResponseSizeWithPadding):
(WebCore::Internals::responseSizeWithPadding const):

  • testing/Internals.h:
  • testing/Internals.idl:

Source/WebKit:

Adding support for quota checking in CacheStorage::Caches.
It is passed to NetworkProcess at creation time.
Default quota size is configured to 400Ko by origin per default.
This value is suitable for testing.
Future patch should raise this default value and allows configuring it.

Quota is computed based on the response body size.
This size is padded at WebCore for opaque responses.
Size is stored persistently as opaque response padded size should remain stable.
See https://github.com/whatwg/storage/issues/31 for the rationale about this padding.

In case of putting several records at the same time, the size of all records
is computed so that all records will be written or rejected together.

Sending QuotaExceeded error when quota is exceeded.
Future effort should allow asking UIProcess for quota extension.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::cacheStoragePerOriginQuota const):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcessCreationParameters.cpp:

(WebKit::NetworkProcessCreationParameters::encode const):
(WebKit::NetworkProcessCreationParameters::decode):

  • NetworkProcess/NetworkProcessCreationParameters.h:
  • NetworkProcess/cache/CacheStorageEngine.cpp:

(WebKit::CacheStorage::Engine::readCachesFromDisk):

  • NetworkProcess/cache/CacheStorageEngineCache.cpp:

(WebKit::CacheStorage::Cache::toRecordInformation):
(WebKit::CacheStorage::isolatedCopy):
(WebKit::CacheStorage::Cache::open):
(WebKit::CacheStorage::Cache::storeRecords):
(WebKit::CacheStorage::Cache::put):
(WebKit::CacheStorage::Cache::writeRecordToDisk):
(WebKit::CacheStorage::Cache::updateRecordToDisk):
(WebKit::CacheStorage::Cache::removeRecordFromDisk):
(WebKit::CacheStorage::Cache::encode):
(WebKit::CacheStorage::Cache::decodeRecordHeader):
(WebKit::CacheStorage::Cache::decode):

  • NetworkProcess/cache/CacheStorageEngineCache.h:
  • NetworkProcess/cache/CacheStorageEngineCaches.cpp:

(WebKit::CacheStorage::Caches::Caches):
(WebKit::CacheStorage::Caches::initialize):
(WebKit::CacheStorage::Caches::initializeSize):
(WebKit::CacheStorage::Caches::requestSpace):
(WebKit::CacheStorage::Caches::writeRecord):
(WebKit::CacheStorage::Caches::removeRecord):
(WebKit::CacheStorage::Caches::removeCacheEntry):

  • NetworkProcess/cache/CacheStorageEngineCaches.h:

(WebKit::CacheStorage::Caches::create):
(WebKit::CacheStorage::Caches::hasEnoughSpace const):

  • NetworkProcess/cache/NetworkCacheStorage.cpp:

(WebKit::NetworkCache::Storage::traverse):

  • NetworkProcess/cocoa/NetworkProcessCocoa.mm:

(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):

  • Shared/WebCoreArgumentCoders.cpp:

(IPC::ArgumentCoder<DOMCacheEngine::Record>::encode):
(IPC::ArgumentCoder<DOMCacheEngine::Record>::decode):

  • UIProcess/API/APIProcessPoolConfiguration.cpp:

(API::ProcessPoolConfiguration::copy):

  • UIProcess/API/APIProcessPoolConfiguration.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::ensureNetworkProcess):

LayoutTests:

  • http/wpt/cache-storage/cache-quota.https.any-expected.txt: Added.
  • http/wpt/cache-storage/cache-quota.https.any.html: Added.
  • http/wpt/cache-storage/cache-quota.https.any.js: Added.
Location:
trunk
Files:
3 added
31 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r223071 r223073  
     12017-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add quota to cache API
     4        https://bugs.webkit.org/show_bug.cgi?id=177552
     5
     6        Reviewed by Alex Christensen.
     7
     8        * http/wpt/cache-storage/cache-quota.https.any-expected.txt: Added.
     9        * http/wpt/cache-storage/cache-quota.https.any.html: Added.
     10        * http/wpt/cache-storage/cache-quota.https.any.js: Added.
     11
    1122017-10-09  Matt Lewis  <jlewis3@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r223072 r223073  
     12017-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add quota to cache API
     4        https://bugs.webkit.org/show_bug.cgi?id=177552
     5
     6        Reviewed by Alex Christensen.
     7
     8        Tests: http/wpt/cache-storage/cache-quota.any.html
     9
     10        Storing padded opaque response body sizes within FetchResponse and CacheStorageConnection.
     11        See https://github.com/whatwg/storage/issues/31 for the rationale about this padding.
     12        Storing in CacheStorageConnection is needed for handling cloned network fetched created responses.
     13        Storing in FetchResponse is needed for handling cloned cache-storage created opaque responses.
     14
     15        Adding internals to query and set the fuzzed size of a response.
     16
     17        * Modules/cache/CacheStorageConnection.cpp:
     18        (WebCore::computeRealBodySize):
     19        (WebCore::CacheStorageConnection::computeRecordBodySize):
     20        (WebCore::CacheStorageConnection::setResponseBodySizeWithPadding):
     21        (WebCore::CacheStorageConnection::responseBodySizeWithPadding const):
     22        * Modules/cache/CacheStorageConnection.h:
     23        * Modules/cache/DOMCache.cpp:
     24        (WebCore::DOMCache::toConnectionRecord):
     25        (WebCore::DOMCache::updateRecords):
     26        * Modules/cache/DOMCache.h:
     27        * Modules/cache/DOMCacheEngine.cpp:
     28        (WebCore::DOMCacheEngine::errorToException):
     29        (WebCore::DOMCacheEngine::Record::copy const):
     30        * Modules/cache/DOMCacheEngine.h:
     31        * Modules/cache/WorkerCacheStorageConnection.cpp:
     32        (WebCore::toCrossThreadRecordData):
     33        (WebCore::fromCrossThreadRecordData):
     34        * Modules/fetch/FetchResponse.cpp:
     35        (WebCore::FetchResponse::clone):
     36        (WebCore::FetchResponse::BodyLoader::didReceiveResponse):
     37        * Modules/fetch/FetchResponse.h:
     38        * Modules/fetch/FetchResponse.idl:
     39        * testing/Internals.cpp:
     40        (WebCore::Internals::setResponseSizeWithPadding):
     41        (WebCore::Internals::responseSizeWithPadding const):
     42        * testing/Internals.h:
     43        * testing/Internals.idl:
     44
    1452017-10-09  Zalan Bujtas  <zalan@apple.com>
    246
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp

    r221624 r223073  
    2727#include "config.h"
    2828#include "CacheStorageConnection.h"
     29
     30#include "FetchResponse.h"
     31#include <wtf/RandomNumber.h>
    2932
    3033using namespace WebCore::DOMCacheEngine;
     
    7275}
    7376
     77static inline uint64_t computeRealBodySize(const DOMCacheEngine::ResponseBody& body)
     78{
     79    uint64_t result = 0;
     80    WTF::switchOn(body, [&] (const Ref<WebCore::FormData>& formData) {
     81        result = formData->lengthInBytes();
     82    }, [&] (const Ref<WebCore::SharedBuffer>& buffer) {
     83        result = buffer->size();
     84    }, [] (const std::nullptr_t&) {
     85    });
     86    return result;
     87}
     88
     89uint64_t CacheStorageConnection::computeRecordBodySize(const FetchResponse& response, const DOMCacheEngine::ResponseBody& body, ResourceResponse::Tainting tainting)
     90{
     91    if (!response.opaqueLoadIdentifier()) {
     92        ASSERT_UNUSED(tainting, tainting != ResourceResponse::Tainting::Opaque);
     93        return computeRealBodySize(body);
     94    }
     95
     96    return m_opaqueResponseToSizeWithPaddingMap.ensure(response.opaqueLoadIdentifier(), [&] () {
     97        uint64_t realSize = computeRealBodySize(body);
     98
     99        // Padding the size as per https://github.com/whatwg/storage/issues/31.
     100        uint64_t sizeWithPadding = realSize + static_cast<uint64_t>(randomNumber() * 128000);
     101        sizeWithPadding = ((sizeWithPadding / 32000) + 1) * 32000;
     102
     103        m_opaqueResponseToSizeWithPaddingMap.set(response.opaqueLoadIdentifier(), sizeWithPadding);
     104        return sizeWithPadding;
     105    }).iterator->value;
     106}
     107
    74108void CacheStorageConnection::batchPutOperation(uint64_t cacheIdentifier, Vector<Record>&& records, RecordIdentifiersCallback&& callback)
    75109{
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.h

    r221710 r223073  
    3333namespace WebCore {
    3434
     35class FetchResponse;
     36
    3537class CacheStorageConnection : public ThreadSafeRefCounted<CacheStorageConnection> {
    3638public:
     
    4547    void batchDeleteOperation(uint64_t cacheIdentifier, const ResourceRequest&, CacheQueryOptions&&, DOMCacheEngine::RecordIdentifiersCallback&&);
    4648    void batchPutOperation(uint64_t cacheIdentifier, Vector<DOMCacheEngine::Record>&&, DOMCacheEngine::RecordIdentifiersCallback&&);
     49    uint64_t computeRecordBodySize(const FetchResponse&, const DOMCacheEngine::ResponseBody&, ResourceResponse::Tainting);
    4750
    4851    virtual void reference(uint64_t /* cacheIdentifier */) { }
     
    7982    HashMap<uint64_t, DOMCacheEngine::RecordsCallback> m_retrieveRecordsPendingRequests;
    8083    HashMap<uint64_t, DOMCacheEngine::RecordIdentifiersCallback> m_batchDeleteAndPutPendingRequests;
     84    HashMap<uint64_t, uint64_t> m_opaqueResponseToSizeWithPaddingMap;
    8185
    8286    uint64_t m_lastRequestIdentifier { 0 };
  • trunk/Source/WebCore/Modules/cache/DOMCache.cpp

    r222774 r223073  
    3939namespace WebCore {
    4040
    41 static Record toConnectionRecord(const FetchRequest&, FetchResponse&, ResponseBody&&);
    42 
    4341DOMCache::DOMCache(ScriptExecutionContext& context, String&& name, uint64_t identifier, Ref<CacheStorageConnection>&& connection)
    4442    : ActiveDOMObject(&context)
     
    481479}
    482480
    483 Record toConnectionRecord(const FetchRequest& request, FetchResponse& response, DOMCacheEngine::ResponseBody&& responseBody)
     481Record DOMCache::toConnectionRecord(const FetchRequest& request, FetchResponse& response, DOMCacheEngine::ResponseBody&& responseBody)
    484482{
    485483    // FIXME: Add a setHTTPHeaderFields on ResourceResponseBase.
     
    494492    ASSERT(!cachedResponse.isNull());
    495493
     494    auto sizeWithPadding = response.bodySizeWithPadding();
     495    if (!sizeWithPadding) {
     496        sizeWithPadding = m_connection->computeRecordBodySize(response, responseBody, cachedResponse.tainting());
     497        response.setBodySizeWithPadding(sizeWithPadding);
     498    }
     499
    496500    return { 0, 0,
    497501        request.headers().guard(), WTFMove(cachedRequest), request.fetchOptions(), request.internalRequestReferrer(),
    498         response.headers().guard(), WTFMove(cachedResponse), WTFMove(responseBody)
     502        response.headers().guard(), WTFMove(cachedResponse), WTFMove(responseBody), sizeWithPadding
    499503    };
    500504}
     
    534538                auto responseHeaders = FetchHeaders::create(record.responseHeadersGuard, HTTPHeaderMap { record.response.httpHeaderFields() });
    535539                auto response = FetchResponse::create(*scriptExecutionContext(), std::nullopt, WTFMove(responseHeaders), WTFMove(record.response));
    536                 response->setBodyData(WTFMove(record.responseBody));
     540                response->setBodyData(WTFMove(record.responseBody), record.responseBodySize);
    537541
    538542                current.response = WTFMove(response);
     
    546550            auto responseHeaders = FetchHeaders::create(record.responseHeadersGuard, HTTPHeaderMap { record.response.httpHeaderFields() });
    547551            auto response = FetchResponse::create(*scriptExecutionContext(), std::nullopt, WTFMove(responseHeaders), WTFMove(record.response));
    548             response->setBodyData(WTFMove(record.responseBody));
     552            response->setBodyData(WTFMove(record.responseBody), record.responseBodySize);
    549553
    550554            newRecords.append(CacheStorageRecord { record.identifier, record.updateResponseCounter, WTFMove(request), WTFMove(response) });
  • trunk/Source/WebCore/Modules/cache/DOMCache.h

    r222774 r223073  
    8181    void updateRecords(Vector<DOMCacheEngine::Record>&&);
    8282    Vector<Ref<FetchResponse>> cloneResponses(const Vector<CacheStorageRecord>&);
     83    DOMCacheEngine::Record toConnectionRecord(const FetchRequest&, FetchResponse&, DOMCacheEngine::ResponseBody&&);
    8384
    8485    String m_name;
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp

    r222774 r223073  
    4545    case Error::WriteDisk:
    4646        return Exception { TypeError, ASCIILiteral("Failed writing data to the file system") };
     47    case Error::QuotaExceeded:
     48        return Exception { QuotaExceededError, ASCIILiteral("Quota exceeded") };
    4749    default:
    4850        return Exception { TypeError, ASCIILiteral("Internal error") };
     
    136138Record Record::copy() const
    137139{
    138     return Record { identifier, updateResponseCounter, requestHeadersGuard, request, options, referrer, responseHeadersGuard, response, copyResponseBody(responseBody) };
     140    return Record { identifier, updateResponseCounter, requestHeadersGuard, request, options, referrer, responseHeadersGuard, response, copyResponseBody(responseBody), responseBodySize };
    139141}
    140142
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h

    r222233 r223073  
    4343    ReadDisk,
    4444    WriteDisk,
     45    QuotaExceeded,
    4546    Internal
    4647};
     
    6970    ResourceResponse response;
    7071    ResponseBody responseBody;
     72    uint64_t responseBodySize;
    7173};
    7274
     
    122124    if (!infos)
    123125        return std::nullopt;
    124    
     126
    125127    std::optional<uint64_t> updateCounter;
    126128    decoder >> updateCounter;
    127129    if (!updateCounter)
    128130        return std::nullopt;
    129    
     131
    130132    return {{ WTFMove(*infos), WTFMove(*updateCounter) }};
    131133}
     
    143145    if (!identifier)
    144146        return std::nullopt;
    145    
     147
    146148    std::optional<bool> hadStorageError;
    147149    decoder >> hadStorageError;
     
    162164        WebCore::DOMCacheEngine::Error::ReadDisk,
    163165        WebCore::DOMCacheEngine::Error::WriteDisk,
     166        WebCore::DOMCacheEngine::Error::QuotaExceeded,
    164167        WebCore::DOMCacheEngine::Error::Internal
    165168    >;
  • trunk/Source/WebCore/Modules/cache/WorkerCacheStorageConnection.cpp

    r222774 r223073  
    5454    ResourceResponse::CrossThreadData response;
    5555    ResponseBody responseBody;
     56    uint64_t responseBodySize;
    5657};
    5758
     
    6768        record.responseHeadersGuard,
    6869        record.response.crossThreadData(),
    69         isolatedResponseBody(record.responseBody)
     70        isolatedResponseBody(record.responseBody),
     71        record.responseBodySize
    7072    };
    7173}
     
    8284        data.responseHeadersGuard,
    8385        ResourceResponse::fromCrossThreadData(WTFMove(data.response)),
    84         WTFMove(data.responseBody)
     86        WTFMove(data.responseBody),
     87        data.responseBodySize
    8588    };
    8689}
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp

    r222561 r223073  
    160160    if (isBodyOpaque())
    161161        clone->setBodyAsOpaque();
     162    clone->m_opaqueLoadIdentifier = m_opaqueLoadIdentifier;
     163    clone->m_bodySizeWithPadding = m_bodySizeWithPadding;
    162164    return WTFMove(clone);
    163165}
     
    240242}
    241243
     244static uint64_t nextOpaqueLoadIdentifier { 0 };
    242245void FetchResponse::BodyLoader::didReceiveResponse(const ResourceResponse& resourceResponse)
    243246{
    244247    m_response.m_response = ResourceResponseBase::filter(resourceResponse);
    245     if (resourceResponse.tainting() == ResourceResponse::Tainting::Opaque)
     248    if (resourceResponse.tainting() == ResourceResponse::Tainting::Opaque) {
     249        m_response.m_opaqueLoadIdentifier = ++nextOpaqueLoadIdentifier;
    246250        m_response.setBodyAsOpaque();
     251    }
    247252
    248253    m_response.m_headers->filterAndFill(m_response.m_response.httpHeaderFields(), FetchHeaders::Guard::Response);
     
    327332}
    328333
    329 void FetchResponse::setBodyData(ResponseData&& data)
    330 {
     334void FetchResponse::setBodyData(ResponseData&& data, uint64_t bodySizeWithPadding)
     335{
     336    m_bodySizeWithPadding = bodySizeWithPadding;
    331337    WTF::switchOn(data,
    332338        [this](Ref<FormData>& formData) {
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.h

    r221806 r223073  
    8888    using ResponseData = Variant<std::nullptr_t, Ref<FormData>, Ref<SharedBuffer>>;
    8989    ResponseData consumeBody();
    90     void setBodyData(ResponseData&&);
     90    void setBodyData(ResponseData&&, uint64_t bodySizeWithPadding);
    9191
    9292    bool isLoading() const { return !!m_bodyLoader; }
     
    9797
    9898    const ResourceResponse& resourceResponse() const { return m_response; }
     99
     100    uint64_t bodySizeWithPadding() const { return m_bodySizeWithPadding; }
     101    void setBodySizeWithPadding(uint64_t size) { m_bodySizeWithPadding = size; }
     102    uint64_t opaqueLoadIdentifier() const { return m_opaqueLoadIdentifier; }
    99103
    100104private:
     
    139143    std::optional<BodyLoader> m_bodyLoader;
    140144    mutable String m_responseURL;
     145    // Opaque responses will padd their body size when used with Cache API.
     146    uint64_t m_bodySizeWithPadding { 0 };
     147    uint64_t m_opaqueLoadIdentifier { 0 };
    141148};
    142149
  • trunk/Source/WebCore/Modules/fetch/FetchResponse.idl

    r221806 r223073  
    4444    ConstructorMayThrowException,
    4545    EnabledAtRuntime=FetchAPI,
     46    ExportToWrappedFunction,
    4647    Exposed=(Window,Worker),
    4748    InterfaceName=Response,
  • trunk/Source/WebCore/testing/Internals.cpp

    r222946 r223073  
    5959#include "EventHandler.h"
    6060#include "ExtensionStyleSheets.h"
     61#include "FetchResponse.h"
    6162#include "File.h"
    6263#include "FontCache.h"
     
    41754176}
    41764177
     4178void Internals::setResponseSizeWithPadding(FetchResponse& response, uint64_t size)
     4179{
     4180    response.setBodySizeWithPadding(size);
     4181}
     4182
     4183uint64_t Internals::responseSizeWithPadding(FetchResponse& response) const
     4184{
     4185    return response.bodySizeWithPadding();
     4186}
     4187
    41774188} // namespace WebCore
  • trunk/Source/WebCore/testing/Internals.h

    r222858 r223073  
    5151class Document;
    5252class Element;
     53class FetchResponse;
    5354class File;
    5455class Frame;
     
    601602    void clearCacheStorageMemoryRepresentation(DOMPromiseDeferred<void>&&);
    602603    void cacheStorageEngineRepresentation(DOMPromiseDeferred<IDLDOMString>&&);
     604    void setResponseSizeWithPadding(FetchResponse&, uint64_t size);
     605    uint64_t responseSizeWithPadding(FetchResponse&) const;
    603606
    604607    void setConsoleMessageListener(RefPtr<StringCallback>&&);
  • trunk/Source/WebCore/testing/Internals.idl

    r222613 r223073  
    548548    Promise<void> clearCacheStorageMemoryRepresentation();
    549549    Promise<DOMString> cacheStorageEngineRepresentation();
     550    void setResponseSizeWithPadding(FetchResponse response, unsigned long long size);
     551    unsigned long long responseSizeWithPadding(FetchResponse response);
    550552
    551553    void setConsoleMessageListener(StringCallback callback);
  • trunk/Source/WebKit/ChangeLog

    r223061 r223073  
     12017-10-09  Youenn Fablet  <youenn@apple.com>
     2
     3        Add quota to cache API
     4        https://bugs.webkit.org/show_bug.cgi?id=177552
     5
     6        Reviewed by Alex Christensen.
     7
     8        Adding support for quota checking in CacheStorage::Caches.
     9        It is passed to NetworkProcess at creation time.
     10        Default quota size is configured to 400Ko by origin per default.
     11        This value is suitable for testing.
     12        Future patch should raise this default value and allows configuring it.
     13
     14        Quota is computed based on the response body size.
     15        This size is padded at WebCore for opaque responses.
     16        Size is stored persistently as opaque response padded size should remain stable.
     17        See https://github.com/whatwg/storage/issues/31 for the rationale about this padding.
     18
     19        In case of putting several records at the same time, the size of all records
     20        is computed so that all records will be written or rejected together.
     21
     22        Sending QuotaExceeded error when quota is exceeded.
     23        Future effort should allow asking UIProcess for quota extension.
     24
     25        * NetworkProcess/NetworkProcess.cpp:
     26        (WebKit::NetworkProcess::cacheStoragePerOriginQuota const):
     27        * NetworkProcess/NetworkProcess.h:
     28        * NetworkProcess/NetworkProcessCreationParameters.cpp:
     29        (WebKit::NetworkProcessCreationParameters::encode const):
     30        (WebKit::NetworkProcessCreationParameters::decode):
     31        * NetworkProcess/NetworkProcessCreationParameters.h:
     32        * NetworkProcess/cache/CacheStorageEngine.cpp:
     33        (WebKit::CacheStorage::Engine::readCachesFromDisk):
     34        * NetworkProcess/cache/CacheStorageEngineCache.cpp:
     35        (WebKit::CacheStorage::Cache::toRecordInformation):
     36        (WebKit::CacheStorage::isolatedCopy):
     37        (WebKit::CacheStorage::Cache::open):
     38        (WebKit::CacheStorage::Cache::storeRecords):
     39        (WebKit::CacheStorage::Cache::put):
     40        (WebKit::CacheStorage::Cache::writeRecordToDisk):
     41        (WebKit::CacheStorage::Cache::updateRecordToDisk):
     42        (WebKit::CacheStorage::Cache::removeRecordFromDisk):
     43        (WebKit::CacheStorage::Cache::encode):
     44        (WebKit::CacheStorage::Cache::decodeRecordHeader):
     45        (WebKit::CacheStorage::Cache::decode):
     46        * NetworkProcess/cache/CacheStorageEngineCache.h:
     47        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
     48        (WebKit::CacheStorage::Caches::Caches):
     49        (WebKit::CacheStorage::Caches::initialize):
     50        (WebKit::CacheStorage::Caches::initializeSize):
     51        (WebKit::CacheStorage::Caches::requestSpace):
     52        (WebKit::CacheStorage::Caches::writeRecord):
     53        (WebKit::CacheStorage::Caches::removeRecord):
     54        (WebKit::CacheStorage::Caches::removeCacheEntry):
     55        * NetworkProcess/cache/CacheStorageEngineCaches.h:
     56        (WebKit::CacheStorage::Caches::create):
     57        (WebKit::CacheStorage::Caches::hasEnoughSpace const):
     58        * NetworkProcess/cache/NetworkCacheStorage.cpp:
     59        (WebKit::NetworkCache::Storage::traverse):
     60        * NetworkProcess/cocoa/NetworkProcessCocoa.mm:
     61        (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
     62        * Shared/WebCoreArgumentCoders.cpp:
     63        (IPC::ArgumentCoder<DOMCacheEngine::Record>::encode):
     64        (IPC::ArgumentCoder<DOMCacheEngine::Record>::decode):
     65        * UIProcess/API/APIProcessPoolConfiguration.cpp:
     66        (API::ProcessPoolConfiguration::copy):
     67        * UIProcess/API/APIProcessPoolConfiguration.h:
     68        * UIProcess/WebProcessPool.cpp:
     69        (WebKit::WebProcessPool::ensureNetworkProcess):
     70
    1712017-10-09  Sam Weinig  <sam@webkit.org>
    272
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r222673 r223073  
    767767}
    768768
     769uint64_t NetworkProcess::cacheStoragePerOriginQuota() const
     770{
     771    return m_cacheStoragePerOriginQuota;
     772}
     773
    769774#if !PLATFORM(COCOA)
    770775void NetworkProcess::initializeProcess(const ChildProcessInitializationParameters&)
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r222673 r223073  
    146146    Seconds loadThrottleLatency() const { return m_loadThrottleLatency; }
    147147    String cacheStorageDirectory(PAL::SessionID) const;
     148    uint64_t cacheStoragePerOriginQuota() const;
    148149
    149150    void preconnectTo(const WebCore::URL&, WebCore::StoredCredentialsPolicy);
     
    238239
    239240    String m_cacheStorageDirectory;
     241    uint64_t m_cacheStoragePerOriginQuota { 0 };
    240242    String m_diskCacheDirectory;
    241243    bool m_hasSetCacheModel;
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp

    r221175 r223073  
    4747    encoder << canHandleHTTPSServerTrustEvaluation;
    4848    encoder << cacheStorageDirectory;
     49    encoder << cacheStoragePerOriginQuota;
    4950    encoder << cacheStorageDirectoryExtensionHandle;
    5051    encoder << diskCacheDirectory;
     
    117118    if (!decoder.decode(result.cacheStorageDirectory))
    118119        return false;
     120    if (!decoder.decode(result.cacheStoragePerOriginQuota))
     121        return false;
    119122    if (!decoder.decode(result.cacheStorageDirectoryExtensionHandle))
    120123        return false;
  • trunk/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h

    r222309 r223073  
    5757
    5858    String cacheStorageDirectory;
     59    uint64_t cacheStoragePerOriginQuota;
    5960    SandboxExtension::Handle cacheStorageDirectoryExtensionHandle;
    6061    String diskCacheDirectory;
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

    r222880 r223073  
    191191    initialize([this, origin, callback = WTFMove(callback)](std::optional<Error>&& error) mutable {
    192192        auto& caches = m_caches.ensure(origin, [&origin, this] {
    193             return Caches::create(*this, String { origin });
     193            return Caches::create(*this, String { origin }, NetworkProcess::singleton().cacheStoragePerOriginQuota());
    194194        }).iterator->value;
    195195
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.cpp

    r222093 r223073  
    5353namespace CacheStorage {
    5454
    55 static std::optional<std::pair<Record, double>> decodeRecordHeader(const Storage::Record&);
    56 
    5755static inline String computeKeyURL(const URL& url)
    5856{
     
    10199{
    102100    Key key { ASCIILiteral("record"), m_uniqueName, { }, createCanonicalUUIDString(), m_caches.salt() };
    103     RecordInformation recordInformation { WTFMove(key), monotonicallyIncreasingTimeMS(), record.identifier, 0 , record.request.url(), false, { } };
     101    RecordInformation recordInformation { WTFMove(key), monotonicallyIncreasingTimeMS(), record.identifier, 0 , record.responseBodySize, record.request.url(), false, { } };
    104102
    105103    updateVaryInformation(recordInformation, record.request, record.response);
     
    124122void Cache::clearMemoryRepresentation()
    125123{
     124    for (auto& records : m_records.values()) {
     125        for (auto& record : records)
     126            removeRecordFromDisk(record);
     127    }
     128
    126129    m_records = { };
    127130    m_nextRecordIdentifier = 0;
     
    131134static RecordInformation isolatedCopy(const RecordInformation& information)
    132135{
    133     auto result = RecordInformation { information.key, information.insertionTime, information.identifier, information.updateResponseCounter, information.url.isolatedCopy(), information.hasVaryStar, { } };
     136    auto result = RecordInformation { information.key, information.insertionTime, information.identifier, information.updateResponseCounter, information.size, information.url.isolatedCopy(), information.hasVaryStar, { } };
    134137    HashMap<String, String> varyHeaders;
    135138    for (const auto& keyValue : information.varyHeaders)
     
    176179            RunLoop::main().dispatch([caches = WTFMove(caches), callback = WTFMove(callback), traversalResult = isolatedCopy(WTFMove(traversalResult)) ]() mutable {
    177180                for (auto& key : traversalResult.failedRecords)
    178                     caches->removeRecord(key);
     181                    caches->removeCacheEntry(key);
    179182
    180183                auto* cache = caches->find(traversalResult.cacheIdentifier);
     
    195198        }
    196199
    197         auto& record = decoded->first;
    198         auto insertionTime = decoded->second;
    199 
    200         RecordInformation recordInformation { storageRecord->key, insertionTime, 0, 0, record.request.url(), false, { } };
     200        auto& record = decoded->record;
     201        auto insertionTime = decoded->insertionTime;
     202
     203        RecordInformation recordInformation { storageRecord->key, insertionTime, 0, 0, record.responseBodySize, record.request.url(), false, { } };
    201204        updateVaryInformation(recordInformation, record.request, record.response);
    202205
     
    378381};
    379382
    380 void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback)
    381 {
    382     ASSERT(m_state == State::Open);
    383 
     383void Cache::storeRecords(Vector<Record>&& records, RecordIdentifiersCallback&& callback)
     384{
    384385    auto taskCounter = AsynchronousPutTaskCounter::create(WTFMove(callback));
    385386
     
    387388    for (auto& record : records) {
    388389        auto* sameURLRecords = recordsFromURL(record.request.url());
    389 
    390390        auto matchingRecords = queryCache(sameURLRecords, record.request, options);
    391         if (matchingRecords.isEmpty()) {
     391
     392        auto position = !matchingRecords.isEmpty() ? sameURLRecords->findMatching([&](const auto& item) { return item.identifier == matchingRecords[0]; }) : notFound;
     393
     394        if (position == notFound) {
    392395            record.identifier = ++m_nextRecordIdentifier;
    393396            taskCounter->addRecordIdentifier(record.identifier);
    394397
    395398            auto& recordToWrite = addRecord(sameURLRecords, record);
    396             writeRecordToDisk(recordToWrite, WTFMove(record), taskCounter.copyRef());
     399            writeRecordToDisk(recordToWrite, WTFMove(record), taskCounter.copyRef(), 0);
    397400        } else {
    398             auto identifier = matchingRecords[0];
    399             auto position = sameURLRecords->findMatching([&](const auto& item) { return item.identifier == identifier; });
    400             ASSERT(position != notFound);
    401             if (position != notFound) {
    402                 auto& existingRecord = sameURLRecords->at(position);
    403                 taskCounter->addRecordIdentifier(identifier);
    404                 updateRecordToDisk(existingRecord, WTFMove(record), taskCounter.copyRef());
    405             }
     401            auto& existingRecord = sameURLRecords->at(position);
     402            taskCounter->addRecordIdentifier(existingRecord.identifier);
     403            updateRecordToDisk(existingRecord, WTFMove(record), taskCounter.copyRef());
    406404        }
    407405    }
     406}
     407
     408void Cache::put(Vector<Record>&& records, RecordIdentifiersCallback&& callback)
     409{
     410    ASSERT(m_state == State::Open);
     411
     412    WebCore::CacheQueryOptions options;
     413    uint64_t spaceRequired = 0;
     414
     415    for (auto& record : records) {
     416        auto* sameURLRecords = recordsFromURL(record.request.url());
     417        auto matchingRecords = queryCache(sameURLRecords, record.request, options);
     418
     419        auto position = (sameURLRecords && !matchingRecords.isEmpty()) ? sameURLRecords->findMatching([&](const auto& item) { return item.identifier == matchingRecords[0]; }) : notFound;
     420
     421        spaceRequired += record.responseBodySize;
     422        if (position != notFound)
     423            spaceRequired -= sameURLRecords->at(position).size;
     424    }
     425
     426    if (m_caches.hasEnoughSpace(spaceRequired)) {
     427        storeRecords(WTFMove(records), WTFMove(callback));
     428        return;
     429    }
     430
     431    m_caches.requestSpace(spaceRequired, [caches = makeRef(m_caches), identifier = m_identifier, records = WTFMove(records), callback = WTFMove(callback)](std::optional<DOMCacheEngine::Error>&& error) mutable {
     432        if (error) {
     433            callback(makeUnexpected(error.value()));
     434            return;
     435        }
     436        auto* cache = caches->find(identifier);
     437        if (!cache)
     438            return;
     439
     440        cache->storeRecords(WTFMove(records), WTFMove(callback));
     441    });
    408442}
    409443
     
    447481}
    448482
    449 void Cache::writeRecordToDisk(const RecordInformation& recordInformation, Record&& record, Ref<AsynchronousPutTaskCounter>&& taskCounter)
    450 {
    451     m_caches.writeRecord(*this, recordInformation, WTFMove(record), [taskCounter = WTFMove(taskCounter)](std::optional<Error>&& error) {
     483void Cache::writeRecordToDisk(const RecordInformation& recordInformation, Record&& record, Ref<AsynchronousPutTaskCounter>&& taskCounter, uint64_t previousRecordSize)
     484{
     485    m_caches.writeRecord(*this, recordInformation, WTFMove(record), previousRecordSize, [taskCounter = WTFMove(taskCounter)](std::optional<Error>&& error) {
    452486        if (error)
    453487            taskCounter->setError(error.value());
     
    474508            return;
    475509        auto& recordInfo = sameURLRecords->at(position);
     510        auto previousSize = recordInfo.size;
     511        recordInfo.size = record.responseBodySize;
    476512
    477513        auto& recordFromDisk = result.value();
     
    483519        updateVaryInformation(recordInfo, record.request, record.response);
    484520
    485         cache->writeRecordToDisk(recordInfo, WTFMove(record), WTFMove(taskCounter));
     521        cache->writeRecordToDisk(recordInfo, WTFMove(record), WTFMove(taskCounter), previousSize);
    486522    });
    487523}
     
    494530void Cache::removeRecordFromDisk(const RecordInformation& record)
    495531{
    496     m_caches.removeRecord(record.key);
     532    m_caches.removeRecord(record);
    497533}
    498534
     
    501537    WTF::Persistence::Encoder encoder;
    502538    encoder << recordInformation.insertionTime;
     539    encoder << recordInformation.size;
    503540    encoder << record.requestHeadersGuard;
    504541    record.request.encodeWithoutPlatformData(encoder);
     
    508545    encoder << record.responseHeadersGuard;
    509546    encoder << record.response;
     547    encoder << record.responseBodySize;
    510548
    511549    encoder.encodeChecksum();
     
    523561}
    524562
    525 static inline std::optional<std::pair<Record, double>> decodeRecordHeader(const Storage::Record& storage)
     563std::optional<Cache::DecodedRecord> Cache::decodeRecordHeader(const Storage::Record& storage)
    526564{
    527565    WTF::Persistence::Decoder decoder(storage.header.data(), storage.header.size());
     
    533571        return std::nullopt;
    534572
     573    uint64_t size;
     574    if (!decoder.decode(size))
     575        return std::nullopt;
     576
    535577    if (!decoder.decode(record.requestHeadersGuard))
    536578        return std::nullopt;
     
    551593        return std::nullopt;
    552594
     595    if (!decoder.decode(record.responseBodySize))
     596        return std::nullopt;
     597
    553598    if (!decoder.verifyChecksum())
    554599        return std::nullopt;
    555600
    556     return std::make_pair(WTFMove(record), insertionTime);
     601    return DecodedRecord { insertionTime, size, WTFMove(record) };
    557602}
    558603
     
    564609        return std::nullopt;
    565610
    566     auto record = WTFMove(result->first);
     611    auto record = WTFMove(result->record);
    567612    record.responseBody = WebCore::SharedBuffer::create(storage.body.data(), storage.body.size());
    568613
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCache.h

    r222073 r223073  
    4444    uint64_t updateResponseCounter { 0 };
    4545
     46    uint64_t size { 0 };
     47
    4648    WebCore::URL url;
    4749    bool hasVaryStar { false };
     
    7981    static NetworkCache::Storage::Record encode(const RecordInformation&, const WebCore::DOMCacheEngine::Record&);
    8082
     83    struct DecodedRecord {
     84        DecodedRecord(double insertionTime, uint64_t size, WebCore::DOMCacheEngine::Record&& record)
     85            : insertionTime(insertionTime)
     86            , size(size)
     87            , record(WTFMove(record))
     88        { }
     89
     90        double insertionTime { 0 };
     91        uint64_t size { 0 };
     92        WebCore::DOMCacheEngine::Record record;
     93    };
     94    static std::optional<DecodedRecord> decodeRecordHeader(const NetworkCache::Storage::Record&);
     95
    8196private:
    8297    Vector<RecordInformation>* recordsFromURL(const WebCore::URL&);
    8398    const Vector<RecordInformation>* recordsFromURL(const WebCore::URL&) const;
    8499    RecordInformation& addRecord(Vector<RecordInformation>*, const WebCore::DOMCacheEngine::Record&);
     100
     101    void storeRecords(Vector<WebCore::DOMCacheEngine::Record>&&, WebCore::DOMCacheEngine::RecordIdentifiersCallback&&);
    85102
    86103    RecordInformation toRecordInformation(const WebCore::DOMCacheEngine::Record&);
     
    90107
    91108    void readRecordsList(WebCore::DOMCacheEngine::CompletionCallback&&);
    92     void writeRecordToDisk(const RecordInformation&, WebCore::DOMCacheEngine::Record&&, Ref<AsynchronousPutTaskCounter>&&);
     109    void writeRecordToDisk(const RecordInformation&, WebCore::DOMCacheEngine::Record&&, Ref<AsynchronousPutTaskCounter>&&, uint64_t previousRecordSize);
    93110    void updateRecordToDisk(RecordInformation&, WebCore::DOMCacheEngine::Record&&, Ref<AsynchronousPutTaskCounter>&&);
    94111    void removeRecordFromDisk(const RecordInformation&);
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp

    r222073 r223073  
    5252}
    5353
    54 Caches::Caches(Engine& engine, String&& origin)
     54Caches::Caches(Engine& engine, String&& origin, uint64_t quota)
    5555    : m_engine(&engine)
    5656    , m_origin(WTFMove(origin))
    5757    , m_rootPath(cachesRootPath(engine, m_origin))
     58    , m_quota(quota)
    5859{
    5960}
     
    8586    m_storage = storage.releaseNonNull();
    8687    m_storage->writeWithoutWaiting();
    87     readCachesFromDisk([this, callback = WTFMove(callback)](Expected<Vector<Cache>, Error>&& result) {
     88    readCachesFromDisk([this, callback = WTFMove(callback)](Expected<Vector<Cache>, Error>&& result) mutable {
    8889        makeDirty();
    8990
     
    9798        }
    9899        m_caches = WTFMove(result.value());
    99         m_isInitialized = true;
    100         callback(std::nullopt);
    101 
    102         auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
    103         for (auto& callback : pendingCallbacks)
     100        initializeSize(WTFMove(callback));
     101    });
     102}
     103
     104void Caches::initializeSize(WebCore::DOMCacheEngine::CompletionCallback&& callback)
     105{
     106    uint64_t size = 0;
     107    m_storage->traverse({ }, 0, [protectedThis = makeRef(*this), this, protectedStorage = makeRef(*m_storage), callback = WTFMove(callback), size](const auto* storage, const auto& information) mutable {
     108        if (!storage) {
     109            m_size = size;
     110            m_isInitialized = true;
    104111            callback(std::nullopt);
     112
     113            auto pendingCallbacks = WTFMove(m_pendingInitializationCallbacks);
     114            for (auto& callback : pendingCallbacks)
     115                callback(std::nullopt);
     116
     117            return;
     118        }
     119        auto decoded = Cache::decodeRecordHeader(*storage);
     120        if (decoded)
     121            size += decoded->size;
    105122    });
    106123}
     
    300317}
    301318
    302 void Caches::writeRecord(const Cache& cache, const RecordInformation& recordInformation, Record&& record, CompletionCallback&& callback)
    303 {
    304     ASSERT(m_isInitialized);
    305 
    306     // FIXME: Check for storage quota.
     319void Caches::requestSpace(uint64_t spaceRequired, WebCore::DOMCacheEngine::CompletionCallback&& callback)
     320{
     321    // FIXME: Implement quota increase request.
     322    ASSERT(m_quota < m_size + spaceRequired);
     323    callback(Error::QuotaExceeded);
     324}
     325
     326void Caches::writeRecord(const Cache& cache, const RecordInformation& recordInformation, Record&& record, uint64_t previousRecordSize, CompletionCallback&& callback)
     327{
     328    ASSERT(m_isInitialized);
     329
     330    ASSERT(m_size >= previousRecordSize);
     331    m_size += recordInformation.size;
     332    m_size -= previousRecordSize;
     333
     334    ASSERT(m_size <= m_quota);
     335
    307336    if (!shouldPersist()) {
    308337        m_volatileStorage.set(recordInformation.key, WTFMove(record));
     
    346375}
    347376
    348 void Caches::removeRecord(const NetworkCache::Key& key)
     377void Caches::removeRecord(const RecordInformation& record)
     378{
     379    ASSERT(m_isInitialized);
     380
     381    ASSERT(m_size >= record.size);
     382    m_size -= record.size;
     383    removeCacheEntry(record.key);
     384}
     385
     386void Caches::removeCacheEntry(const NetworkCache::Key& key)
    349387{
    350388    ASSERT(m_isInitialized);
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h

    r222073 r223073  
    3737class Caches : public RefCounted<Caches> {
    3838public:
    39     static Ref<Caches> create(Engine& engine, String&& origin) { return adoptRef(*new Caches { engine, WTFMove(origin) }); }
     39    static Ref<Caches> create(Engine& engine, String&& origin, uint64_t quota) { return adoptRef(*new Caches { engine, WTFMove(origin), quota }); }
    4040
    4141    void initialize(WebCore::DOMCacheEngine::CompletionCallback&&);
     
    5555    void readRecordsList(Cache&, NetworkCache::Storage::TraverseHandler&&);
    5656    void readRecord(const NetworkCache::Key&, WTF::Function<void(Expected<WebCore::DOMCacheEngine::Record, WebCore::DOMCacheEngine::Error>&&)>&&);
    57     void writeRecord(const Cache&, const RecordInformation&, WebCore::DOMCacheEngine::Record&&, WebCore::DOMCacheEngine::CompletionCallback&&);
    58     void removeRecord(const NetworkCache::Key&);
     57
     58    bool hasEnoughSpace(uint64_t spaceRequired) const { return m_quota >= m_size + spaceRequired; }
     59    void requestSpace(uint64_t spaceRequired, WebCore::DOMCacheEngine::CompletionCallback&&);
     60    void writeRecord(const Cache&, const RecordInformation&, WebCore::DOMCacheEngine::Record&&, uint64_t previousRecordSize, WebCore::DOMCacheEngine::CompletionCallback&&);
     61
     62    void removeCacheEntry(const NetworkCache::Key&);
     63    void removeRecord(const RecordInformation&);
    5964
    6065    const NetworkCache::Salt& salt() const;
     
    6368
    6469private:
    65     Caches(Engine&, String&& origin);
     70    Caches(Engine&, String&& origin, uint64_t quota);
    6671
     72    void initializeSize(WebCore::DOMCacheEngine::CompletionCallback&&);
    6773    void readCachesFromDisk(WTF::Function<void(Expected<Vector<Cache>, WebCore::DOMCacheEngine::Error>&&)>&&);
    6874    void writeCachesToDisk(WebCore::DOMCacheEngine::CompletionCallback&&);
     
    7884    String m_origin;
    7985    String m_rootPath;
     86    uint64_t m_quota { 0 };
     87    uint64_t m_size { 0 };
    8088    Vector<Cache> m_caches;
    8189    Vector<Cache> m_removedCaches;
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp

    r222073 r223073  
    862862    ioQueue().dispatch([this, &traverseOperation] {
    863863        traverseRecordsFiles(recordsPath(), traverseOperation.type, [this, &traverseOperation](const String& fileName, const String& hashString, const String& type, bool isBlob, const String& recordDirectoryPath) {
    864             ASSERT(type == traverseOperation.type);
     864            ASSERT(type == traverseOperation.type || traverseOperation.type.isEmpty());
    865865            if (isBlob)
    866866                return;
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm

    r222896 r223073  
    108108    if (!parameters.cacheStorageDirectory.isNull()) {
    109109        m_cacheStorageDirectory = parameters.cacheStorageDirectory;
     110        m_cacheStoragePerOriginQuota = parameters.cacheStoragePerOriginQuota;
    110111        SandboxExtension::consumePermanently(parameters.cacheStorageDirectoryExtensionHandle);
    111112    }
  • trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp

    r222886 r223073  
    262262    encoder << record.response;
    263263    encoder << record.updateResponseCounter;
     264    encoder << record.responseBodySize;
    264265
    265266    WTF::switchOn(record.responseBody, [&](const Ref<SharedBuffer>& buffer) {
     
    308309    uint64_t updateResponseCounter;
    309310    if (!decoder.decode(updateResponseCounter))
     311        return std::nullopt;
     312
     313    uint64_t responseBodySize;
     314    if (!decoder.decode(responseBodySize))
    310315        return std::nullopt;
    311316
     
    333338    }
    334339
    335     return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody) }};
     340    return {{ WTFMove(identifier), WTFMove(updateResponseCounter), WTFMove(requestHeadersGuard), WTFMove(request), WTFMove(options), WTFMove(referrer), WTFMove(responseHeadersGuard), WTFMove(response), WTFMove(responseBody), responseBodySize }};
    336341}
    337342
  • trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.cpp

    r222211 r223073  
    112112    copy->m_applicationCacheFlatFileSubdirectoryName = this->m_applicationCacheFlatFileSubdirectoryName;
    113113    copy->m_cacheStorageDirectory = this->m_cacheStorageDirectory;
    114     copy->m_diskCacheDirectory = this->m_diskCacheDirectory;
     114    copy->m_cacheStorageDirectory = this->m_cacheStorageDirectory;
     115    copy->m_cacheStoragePerOriginQuota = this->m_cacheStoragePerOriginQuota;
    115116    copy->m_mediaCacheDirectory = this->m_mediaCacheDirectory;
    116117    copy->m_indexedDBDatabaseDirectory = this->m_indexedDBDatabaseDirectory;
  • trunk/Source/WebKit/UIProcess/API/APIProcessPoolConfiguration.h

    r222309 r223073  
    7070    const WTF::String& cacheStorageDirectory() const { return m_cacheStorageDirectory; }
    7171    void setCacheStorageDirectory(WTF::String&& cacheStorageDirectory) { m_cacheStorageDirectory = WTFMove(cacheStorageDirectory); }
     72    uint64_t cacheStoragePerOriginQuota() const { return m_cacheStoragePerOriginQuota; }
    7273
    7374    const WTF::String& diskCacheDirectory() const { return m_diskCacheDirectory; }
     
    153154    WTF::String m_applicationCacheFlatFileSubdirectoryName;
    154155    WTF::String m_cacheStorageDirectory;
     156    uint64_t m_cacheStoragePerOriginQuota { 400 * 1024 };
    155157    WTF::String m_diskCacheDirectory;
    156158    WTF::String m_mediaCacheDirectory;
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r222664 r223073  
    435435
    436436    parameters.cacheStorageDirectory = m_configuration->cacheStorageDirectory();
     437    parameters.cacheStoragePerOriginQuota = m_configuration->cacheStoragePerOriginQuota();
    437438    if (!parameters.cacheStorageDirectory.isEmpty())
    438439        SandboxExtension::createHandleForReadWriteDirectory(parameters.cacheStorageDirectory, parameters.cacheStorageDirectoryExtensionHandle);
Note: See TracChangeset for help on using the changeset viewer.