⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 243339 in webkit


Ignore:
Timestamp:
Mar 21, 2019, 3:52:18 PM (7 years ago)
Author:
youenn@apple.com
Message:

Cache API and IDB space usages should be initialized on first quota check
https://bugs.webkit.org/show_bug.cgi?id=195707

Reviewed by Chris Dumez.

Source/WebCore:

Add a way to require IDBServer to create a quota user for a given origin.
Make sure that removing a user might kick-in processing of pending requests.
In the case of processing pending requests, we should not decide on the first task
except if it is triggered by a request space response.
Update processPendingRequests accordingly.

Tests: http/tests/IndexedDB/storage-limit-1.https.html

http/tests/IndexedDB/storage-limit-2.https.html

  • Modules/indexeddb/server/IDBServer.h:

(WebCore::IDBServer::IDBServer::initializeQuotaUser):

  • storage/StorageQuotaManager.cpp:

(WebCore::StorageQuotaManager::removeUser):
(WebCore::StorageQuotaManager::askForMoreSpace):
(WebCore::StorageQuotaManager::processPendingRequests):

  • storage/StorageQuotaManager.h:

Source/WebKit:

When the quota manager is created, make sure it delays quota check decisions until IDB and Cache API quota users are initialized.
For IDB, the creation is synchronous but it may not be synchronous for Cache API.
For that purpose, add a temporary quota user that will stay uninitialized until these two quota users are added.
Once added, the temporary quota user is removed.
The addition of the real users is made asynchronously as this is triggered by the creation of one of the two quota users.

In the case of a Cache API caches being cleared, make sure to reset the size to zero and to redo the quota user initialization dance.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::QuotaUserInitializer::initialize):
(WebKit::QuotaUserInitializer::~QuotaUserInitializer):
(WebKit::QuotaUserInitializer::QuotaUserInitializer):
(WebKit::NetworkProcess::storageQuotaManager):

  • NetworkProcess/cache/CacheStorageEngine.cpp:

(WebKit::CacheStorage::Engine::initializeQuotaUser):

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

(WebKit::CacheStorage::Caches::clear):

LayoutTests:

Marking http/tests/cache-storage/cache-clearing-origin.https.html as
flaky on iOS as it is already marked flaky in MacOS.

  • platform/mac-wk2/TestExpectations:
  • http/tests/IndexedDB/storage-limit-1.https-expected.txt: Added.
  • http/tests/IndexedDB/storage-limit-1.https.html: Added.
  • http/tests/IndexedDB/storage-limit-2.https-expected.txt: Added.
  • http/tests/IndexedDB/storage-limit-2.https.html: Added.
  • http/tests/IndexedDB/storage-limit.https.html:
  • platform/mac-wk1/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
3 added
18 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r243336 r243339  
     12019-03-21  Youenn Fablet  <youenn@apple.com>
     2
     3        Cache API and IDB space usages should be initialized on first quota check
     4        https://bugs.webkit.org/show_bug.cgi?id=195707
     5
     6        Reviewed by Chris Dumez.
     7
     8        * TestExpectations:
     9        Marking http/tests/cache-storage/cache-clearing-origin.https.html as
     10        flaky on iOS as it is already marked flaky in MacOS.
     11        * platform/mac-wk2/TestExpectations:
     12        * http/tests/IndexedDB/storage-limit-1.https-expected.txt: Added.
     13        * http/tests/IndexedDB/storage-limit-1.https.html: Added.
     14        * http/tests/IndexedDB/storage-limit-2.https-expected.txt: Added.
     15        * http/tests/IndexedDB/storage-limit-2.https.html: Added.
     16        * http/tests/IndexedDB/storage-limit.https.html:
     17        * platform/mac-wk1/TestExpectations:
     18        * platform/win/TestExpectations:
     19
    1202019-03-21  Said Abou-Hallawa  <sabouhallawa@apple.com>
    221
  • trunk/LayoutTests/TestExpectations

    r243331 r243339  
    22372237
    22382238webkit.org/b/182928 http/tests/cache-storage/cache-representation.https.html [ Pass Failure ]
     2239webkit.org/b/193976 http/tests/cache-storage/cache-clearing-origin.https.html [ Pass Failure ]
    22392240
    22402241webkit.org/b/116621 fast/replaced/preferred-widths.html [ Pass Failure ]
  • trunk/LayoutTests/http/tests/IndexedDB/storage-limit-1.https.html

    r243338 r243339  
     1<html>
     2<head>
     3<script src="/js-test-resources/js-test.js"></script>
     4<script src="resources/shared.js"></script>
     5</head>
     6<body>
     7<script>
    18if (window.testRunner)
    29    testRunner.setAllowStorageQuotaIncrease(false);
    310
    4 description("This test makes sure that storage of indexedDB does not grow unboundedly.");
     11description("This test makes sure that storage of indexedDB  and Cache API do not grow unboundedly.");
    512
    613window.caches.open("test").then(cache => {
    7     return cache.put(new Request("/test"), new Response(new Uint8Array(204800)));
    8 }).then(() => {
     14    return cache.put(new Request("/test"), new Response(new Uint8Array(200 * 1024)));
     15}).then(async() => {
     16    // Let's terminate the network process so that all the opened quota users are gone for IDB quota check.
     17    if (window.testRunner)
     18        testRunner.terminateNetworkProcess();
     19    while (true) {
     20        try {
     21            await fetch(".");
     22            break;
     23        } catch (e) { }
     24    }
    925    indexedDBTest(prepareDatabase, onOpenSuccess, {'suffix': '-1'});
    1026}).catch(e => {
     
    2036
    2137// Quota for test is 400ko, but IDB is eating some of it when initializing files.
    22 // Let's make sure that 200ko is fine but 200ko after 200ko is not fine.
     38// Let's make sure that 200ko is fine but 300ko after 200ko is not fine.
    2339async function onOpenSuccess(event)
    2440{
    2541    evalAndLog("db = event.target.result");
    2642    evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')");
    27     evalAndLog("request = store.add(new Uint8Array(204800), 'key')");
     43    evalAndLog("request = store.add(new Uint8Array(300 * 1024), 'key')");
    2844    request.onerror = function(event) {
    2945        shouldBeTrue("'error' in request");
     
    3753        finishJSTest();
    3854    }
    39 }
     55}</script>
     56</body>
     57</html>
  • trunk/LayoutTests/http/tests/IndexedDB/storage-limit.https.html

    r242911 r243339  
    55</head>
    66<body>
    7 <script src="resources/storage-limit.js"></script>
     7<script>
     8if (window.testRunner)
     9    testRunner.setAllowStorageQuotaIncrease(false);
     10
     11description("This test makes sure that storage of indexedDB does not grow unboundedly.");
     12
     13window.caches.open("test").then(cache => {
     14    return cache.put(new Request("/test"), new Response(new Uint8Array(204800)));
     15}).then(() => {
     16    indexedDBTest(prepareDatabase, onOpenSuccess, {'suffix': '-1'});
     17}).catch(e => {
     18    testFailed("Cache API store operation failed: " + e);
     19    finishJSTest();
     20});
     21
     22function prepareDatabase(event)
     23{
     24    evalAndLog("db = event.target.result");
     25    evalAndLog("store = db.createObjectStore('store')");
     26}
     27
     28// Quota for test is 400ko, but IDB is eating some of it when initializing files.
     29// Let's make sure that 200ko is fine but 200ko after 200ko is not fine.
     30async function onOpenSuccess(event)
     31{
     32    evalAndLog("db = event.target.result");
     33    evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')");
     34    evalAndLog("request = store.add(new Uint8Array(204800), 'key')");
     35    request.onerror = function(event) {
     36        shouldBeTrue("'error' in request");
     37        shouldBe("request.error.code", "DOMException.QUOTA_EXCEEDED_ERR");
     38        shouldBeEqualToString("request.error.name", "QuotaExceededError");
     39        finishJSTest();
     40    }
     41
     42    request.onsuccess = function(event) {
     43        testFailed("Add operation should fail because storage limit is reached, but succeeded.");
     44        finishJSTest();
     45    }
     46}
     47</script>
    848</body>
    949</html>
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r242920 r243339  
    165165# Quota check missing in WK1
    166166http/tests/IndexedDB/storage-limit.https.html [ Skip ]
     167http/tests/IndexedDB/storage-limit-1.https.html [ Skip ]
     168http/tests/IndexedDB/storage-limit-2.https.html [ Skip ]
    167169storage/indexeddb/storage-limit.html [ Skip ]
    168170
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r243255 r243339  
    913913webkit.org/b/191658 [ Sierra Release ] fast/layers/no-clipping-overflow-hidden-added-after-transform.html [ Pass ImageOnlyFailure ]
    914914
    915 webkit.org/b/193976 http/tests/cache-storage/cache-clearing-origin.https.html [ Pass Failure ]
    916 
    917915webkit.org/b/194826 http/tests/resourceLoadStatistics/do-not-block-top-level-navigation-redirect.html [ Pass Timeout ]
    918916
  • trunk/LayoutTests/platform/win/TestExpectations

    r242986 r243339  
    23762376storage/indexeddb/storage-limit.html [ Skip ]
    23772377http/tests/IndexedDB/storage-limit.https.html [ Skip ]
     2378http/tests/IndexedDB/storage-limit-1.https.html [ Skip ]
     2379http/tests/IndexedDB/storage-limit-2.https.html [ Skip ]
    23782380
    23792381# Assertion failures: Not investigated
  • trunk/Source/WebCore/ChangeLog

    r243338 r243339  
     12019-03-21  Youenn Fablet  <youenn@apple.com>
     2
     3        Cache API and IDB space usages should be initialized on first quota check
     4        https://bugs.webkit.org/show_bug.cgi?id=195707
     5
     6        Reviewed by Chris Dumez.
     7
     8        Add a way to require IDBServer to create a quota user for a given origin.
     9        Make sure that removing a user might kick-in processing of pending requests.
     10        In the case of processing pending requests, we should not decide on the first task
     11        except if it is triggered by a request space response.
     12        Update processPendingRequests accordingly.
     13
     14        Tests: http/tests/IndexedDB/storage-limit-1.https.html
     15               http/tests/IndexedDB/storage-limit-2.https.html
     16
     17        * Modules/indexeddb/server/IDBServer.h:
     18        (WebCore::IDBServer::IDBServer::initializeQuotaUser):
     19        * storage/StorageQuotaManager.cpp:
     20        (WebCore::StorageQuotaManager::removeUser):
     21        (WebCore::StorageQuotaManager::askForMoreSpace):
     22        (WebCore::StorageQuotaManager::processPendingRequests):
     23        * storage/StorageQuotaManager.h:
     24
    1252019-03-21  Alex Christensen  <achristensen@webkit.org>
    226
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp

    r243019 r243339  
    785785}
    786786
    787 IDBServer::QuotaUser& IDBServer::quotaUser(const ClientOrigin& origin)
     787IDBServer::QuotaUser& IDBServer::ensureQuotaUser(const ClientOrigin& origin)
    788788{
    789789    return *m_quotaUsers.ensure(origin, [this, &origin] {
     
    811811void IDBServer::finishComputingSpaceUsedForOrigin(const ClientOrigin& origin, uint64_t spaceUsed)
    812812{
    813     quotaUser(origin).initializeSpaceUsed(spaceUsed);
     813    ensureQuotaUser(origin).initializeSpaceUsed(spaceUsed);
    814814}
    815815
    816816void IDBServer::requestSpace(const ClientOrigin& origin, uint64_t taskSize, CompletionHandler<void(StorageQuotaManager::Decision)>&& callback)
    817817{
    818     auto* quotaManager = quotaUser(origin).manager();
     818    auto* quotaManager = ensureQuotaUser(origin).manager();
    819819    if (!quotaManager) {
    820820        callback(StorageQuotaManager::Decision::Deny);
     
    833833void IDBServer::setSpaceUsed(const ClientOrigin& origin, uint64_t taskSize)
    834834{
    835     quotaUser(origin).setSpaceUsed(taskSize);
     835    ensureQuotaUser(origin).setSpaceUsed(taskSize);
    836836}
    837837
    838838void IDBServer::increasePotentialSpaceUsed(const ClientOrigin& origin, uint64_t taskSize)
    839839{
    840     quotaUser(origin).increasePotentialSpaceUsed(taskSize);
     840    ensureQuotaUser(origin).increasePotentialSpaceUsed(taskSize);
    841841}
    842842
    843843void IDBServer::decreasePotentialSpaceUsed(const ClientOrigin& origin, uint64_t spaceUsed)
    844844{
    845     quotaUser(origin).decreasePotentialSpaceUsed(spaceUsed);
     845    ensureQuotaUser(origin).decreasePotentialSpaceUsed(spaceUsed);
    846846}
    847847
  • trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.h

    r243019 r243339  
    126126    void resetSpaceUsed(const ClientOrigin&);
    127127
     128    void initializeQuotaUser(const ClientOrigin& origin) { ensureQuotaUser(origin); }
     129
    128130private:
    129131    IDBServer(PAL::SessionID, IDBBackingStoreTemporaryFileHandler&, QuotaManagerGetter&&, WTF::Function<void(bool)>&&);
     
    176178    };
    177179
    178     QuotaUser& quotaUser(const ClientOrigin&);
     180    WEBCORE_EXPORT QuotaUser& ensureQuotaUser(const ClientOrigin&);
    179181    void startComputingSpaceUsedForOrigin(const ClientOrigin&);
    180182    void computeSpaceUsedForOrigin(const ClientOrigin&);
  • trunk/Source/WebCore/storage/StorageQuotaManager.cpp

    r243276 r243339  
    7070
    7171        updateQuotaBasedOnSpaceUsage();
    72         processPendingRequests({ });
     72        processPendingRequests({ }, ShouldDequeueFirstPendingRequest::No);
    7373    });
    7474}
     
    8080
    8181    return spaceUsage() + spaceIncrease > m_quota;
     82}
     83
     84void StorageQuotaManager::removeUser(StorageQuotaUser& user)
     85{
     86    ASSERT(m_users.contains(&user) || m_pendingInitializationUsers.contains(&user));
     87    m_users.remove(&user);
     88    if (m_pendingInitializationUsers.remove(&user) && m_pendingInitializationUsers.isEmpty())
     89        processPendingRequests({ }, ShouldDequeueFirstPendingRequest::No);
    8290}
    8391
     
    100108{
    101109    ASSERT(shouldAskForMoreSpace(spaceIncrease));
     110    ASSERT(!m_isWaitingForSpaceIncreaseResponse);
     111    m_isWaitingForSpaceIncreaseResponse = true;
    102112    m_spaceIncreaseRequester(m_quota, spaceUsage(), spaceIncrease, [this, weakThis = makeWeakPtr(*this)](Optional<uint64_t> newQuota) {
    103113        if (!weakThis)
    104114            return;
    105         processPendingRequests(newQuota);
     115        m_isWaitingForSpaceIncreaseResponse = false;
     116        processPendingRequests(newQuota, ShouldDequeueFirstPendingRequest::Yes);
    106117    });
    107118}
    108119
    109 void StorageQuotaManager::processPendingRequests(Optional<uint64_t> newQuota)
     120void StorageQuotaManager::processPendingRequests(Optional<uint64_t> newQuota, ShouldDequeueFirstPendingRequest shouldDequeueFirstPendingRequest)
    110121{
    111122    if (m_pendingRequests.isEmpty())
     
    115126        m_quota = *newQuota;
    116127
    117     auto request = m_pendingRequests.takeFirst();
    118     auto decision = shouldAskForMoreSpace(request.spaceIncrease) ? Decision::Deny : Decision::Grant;
    119     request.callback(decision);
     128    if (m_isWaitingForSpaceIncreaseResponse)
     129        return;
     130
     131    if (!m_pendingInitializationUsers.isEmpty())
     132        return;
     133
     134    if (shouldDequeueFirstPendingRequest == ShouldDequeueFirstPendingRequest::Yes) {
     135        auto request = m_pendingRequests.takeFirst();
     136        auto decision = shouldAskForMoreSpace(request.spaceIncrease) ? Decision::Deny : Decision::Grant;
     137        request.callback(decision);
     138    }
    120139
    121140    while (!m_pendingRequests.isEmpty()) {
  • trunk/Source/WebCore/storage/StorageQuotaManager.h

    r243276 r243339  
    5151
    5252    WEBCORE_EXPORT void addUser(StorageQuotaUser&);
    53     void removeUser(StorageQuotaUser& user)
    54     {
    55         ASSERT(m_users.contains(&user) || m_pendingInitializationUsers.contains(&user));
    56         m_pendingInitializationUsers.remove(&user);
    57         m_users.remove(&user);
    58     }
     53    WEBCORE_EXPORT void removeUser(StorageQuotaUser&);
    5954
    6055    enum class Decision { Deny, Grant };
     
    6964    bool shouldAskForMoreSpace(uint64_t spaceIncrease) const;
    7065    void askForMoreSpace(uint64_t spaceIncrease);
    71     void processPendingRequests(Optional<uint64_t>);
     66
     67    enum class ShouldDequeueFirstPendingRequest { No, Yes };
     68    void processPendingRequests(Optional<uint64_t>, ShouldDequeueFirstPendingRequest);
    7269
    7370    uint64_t m_quota { 0 };
     71
     72    bool m_isWaitingForSpaceIncreaseResponse { false };
    7473    SpaceIncreaseRequester m_spaceIncreaseRequester;
    7574    HashSet<const StorageQuotaUser*> m_pendingInitializationUsers;
  • trunk/Source/WebKit/ChangeLog

    r243329 r243339  
     12019-03-21  Youenn Fablet  <youenn@apple.com>
     2
     3        Cache API and IDB space usages should be initialized on first quota check
     4        https://bugs.webkit.org/show_bug.cgi?id=195707
     5
     6        Reviewed by Chris Dumez.
     7
     8        When the quota manager is created, make sure it delays quota check decisions until IDB and Cache API quota users are initialized.
     9        For IDB, the creation is synchronous but it may not be synchronous for Cache API.
     10        For that purpose, add a temporary quota user that will stay uninitialized until these two quota users are added.
     11        Once added, the temporary quota user is removed.
     12        The addition of the real users is made asynchronously as this is triggered by the creation of one of the two quota users.
     13
     14        In the case of a Cache API caches being cleared, make sure to reset the size to zero and to redo the quota user initialization dance.
     15
     16        * NetworkProcess/NetworkProcess.cpp:
     17        (WebKit::QuotaUserInitializer::initialize):
     18        (WebKit::QuotaUserInitializer::~QuotaUserInitializer):
     19        (WebKit::QuotaUserInitializer::QuotaUserInitializer):
     20        (WebKit::NetworkProcess::storageQuotaManager):
     21        * NetworkProcess/cache/CacheStorageEngine.cpp:
     22        (WebKit::CacheStorage::Engine::initializeQuotaUser):
     23        * NetworkProcess/cache/CacheStorageEngine.h:
     24        * NetworkProcess/cache/CacheStorageEngineCaches.cpp:
     25        (WebKit::CacheStorage::Caches::clear):
     26
    1272019-03-21  Per Arne Vollan  <pvollan@apple.com>
    228
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r243276 r243339  
    23952395}
    23962396
     2397class QuotaUserInitializer final : public WebCore::StorageQuotaUser {
     2398public:
     2399    explicit QuotaUserInitializer(StorageQuotaManager& manager)
     2400        : m_manager(makeWeakPtr(manager))
     2401    {
     2402        manager.addUser(*this);
     2403    }
     2404
     2405    ~QuotaUserInitializer()
     2406    {
     2407        if (m_manager)
     2408            m_manager->removeUser(*this);
     2409        if (m_callback)
     2410            m_callback();
     2411    }
     2412
     2413private:
     2414    // StorageQuotaUser API.
     2415    uint64_t spaceUsed() const final
     2416    {
     2417        ASSERT_NOT_REACHED();
     2418        return 0;
     2419    }
     2420
     2421    void whenInitialized(CompletionHandler<void()>&& callback) final
     2422    {
     2423        m_callback = WTFMove(callback);
     2424    }
     2425
     2426    WeakPtr<StorageQuotaManager> m_manager;
     2427    CompletionHandler<void()> m_callback;
     2428};
     2429
     2430void NetworkProcess::initializeQuotaUsers(StorageQuotaManager& manager, PAL::SessionID sessionID, const ClientOrigin& origin)
     2431{
     2432    RunLoop::main().dispatch([this, weakThis = makeWeakPtr(this), sessionID, origin, user = std::make_unique<QuotaUserInitializer>(manager)]() mutable {
     2433        if (!weakThis)
     2434            return;
     2435        this->idbServer(sessionID).initializeQuotaUser(origin);
     2436        CacheStorage::Engine::initializeQuotaUser(*this, sessionID, origin, [user = WTFMove(user)] { });
     2437    });
     2438}
     2439
    23972440StorageQuotaManager& NetworkProcess::storageQuotaManager(PAL::SessionID sessionID, const ClientOrigin& origin)
    23982441{
     
    24022445    return *storageQuotaManagers.managersPerOrigin.ensure(origin, [this, &storageQuotaManagers, sessionID, &origin] {
    24032446        auto quota = origin.topOrigin == origin.clientOrigin ? storageQuotaManagers.defaultQuota : storageQuotaManagers.defaultThirdPartyQuota;
    2404         return std::make_unique<StorageQuotaManager>(quota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) {
     2447        auto manager = std::make_unique<StorageQuotaManager>(quota, [this, sessionID, origin](uint64_t quota, uint64_t currentSpace, uint64_t spaceIncrease, auto callback) {
    24052448            this->requestStorageSpace(sessionID, origin, quota, currentSpace, spaceIncrease, WTFMove(callback));
    24062449        });
     2450        initializeQuotaUsers(*manager, sessionID, origin);
     2451        return manager;
    24072452    }).iterator->value;
    24082453}
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r243276 r243339  
    384384
    385385    void setCacheStorageParameters(PAL::SessionID, uint64_t quota, String&& cacheStorageDirectory, SandboxExtension::Handle&&);
     386    void initializeQuotaUsers(WebCore::StorageQuotaManager&, PAL::SessionID, const WebCore::ClientOrigin&);
    386387
    387388    // FIXME: This should take a session ID so we can identify which disk cache to delete.
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp

    r242599 r243339  
    186186}
    187187
     188void Engine::initializeQuotaUser(NetworkProcess& networkProcess, PAL::SessionID sessionID, const WebCore::ClientOrigin& clientOrigin, CompletionHandler<void()>&& completionHandler)
     189{
     190    from(networkProcess, sessionID, [clientOrigin, completionHandler = WTFMove(completionHandler)](auto& engine) mutable {
     191        engine.readCachesFromDisk(clientOrigin, [completionHandler = WTFMove(completionHandler)](auto&& cachesOrError) mutable {
     192            completionHandler();
     193        });
     194    });
     195}
     196
    188197Engine::Engine(PAL::SessionID sessionID, NetworkProcess& process, String&& rootPath)
    189198    : m_sessionID(sessionID)
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.h

    r242599 r243339  
    8181    static void clearCachesForOrigin(NetworkProcess&, PAL::SessionID, WebCore::SecurityOriginData&&, CompletionHandler<void()>&&);
    8282
     83    static void initializeQuotaUser(NetworkProcess&, PAL::SessionID, const WebCore::ClientOrigin&, CompletionHandler<void()>&&);
     84
    8385    bool shouldPersist() const { return !!m_ioQueue;}
    8486
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.cpp

    r243276 r243339  
    261261            ASSERT(RunLoop::isMain());
    262262            protectedThis->clearMemoryRepresentation();
     263            protectedThis->resetSpaceUsed();
    263264            completionHandler();
    264265        });
     
    266267    }
    267268    clearMemoryRepresentation();
     269    resetSpaceUsed();
    268270    clearPendingWritingCachesToDiskCallbacks();
    269271    completionHandler();
     
    602604}
    603605
     606void Caches::resetSpaceUsed()
     607{
     608    m_size = 0;
     609    if (m_quotaManager) {
     610        m_quotaManager->removeUser(*this);
     611        m_quotaManager->addUser(*this);
     612    }
     613}
     614
    604615void Caches::clearMemoryRepresentation()
    605616{
  • trunk/Source/WebKit/NetworkProcess/cache/CacheStorageEngineCaches.h

    r243276 r243339  
    7979    void clear(WTF::CompletionHandler<void()>&&);
    8080    void clearMemoryRepresentation();
     81    void resetSpaceUsed();
    8182
    8283    uint64_t storageSize() const;
Note: See TracChangeset for help on using the changeset viewer.