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

Changeset 243812 in webkit


Ignore:
Timestamp:
Apr 3, 2019, 10:45:17 AM (7 years ago)
Author:
youenn@apple.com
Message:

Clear WorkerCacheStorageConnection callbacks on WorkerGlobalScope termination
https://bugs.webkit.org/show_bug.cgi?id=196521

Reviewed by Alex Christensen.

When the worker global scope is preparing for termination,
all ActiveDOMObjects are stopped.
At that time, the completion handlers related to
WorkerCacheStorageConnection should be cleared to be able to free
memory, and as they are now no-op anyway.

We clear the completion handlers once the active DOM objects are stopped
to limit the processing triggered by clearing them.

Introducing a new Stopped error code to handle this case.
Add an assertion so that this error does not surface to JS.

Covered by existing tests.

  • Modules/cache/CacheStorageConnection.cpp:

(WebCore::CacheStorageConnection::clearPendingRequests):

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

(WebCore::DOMCacheEngine::errorToException):

  • Modules/cache/DOMCacheEngine.h:
  • workers/WorkerGlobalScope.cpp:

(WebCore::WorkerGlobalScope::prepareForTermination):
(WebCore::WorkerGlobalScope::stopIndexedDatabase):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r243811 r243812  
     12019-04-03  Youenn Fablet  <youenn@apple.com>
     2
     3        Clear WorkerCacheStorageConnection callbacks on WorkerGlobalScope termination
     4        https://bugs.webkit.org/show_bug.cgi?id=196521
     5
     6        Reviewed by Alex Christensen.
     7
     8        When the worker global scope is preparing for termination,
     9        all ActiveDOMObjects are stopped.
     10        At that time, the completion handlers related to
     11        WorkerCacheStorageConnection should be cleared to be able to free
     12        memory, and as they are now no-op anyway.
     13
     14        We clear the completion handlers once the active DOM objects are stopped
     15        to limit the processing triggered by clearing them.
     16
     17        Introducing a new Stopped error code to handle this case.
     18        Add an assertion so that this error does not surface to JS.
     19
     20        Covered by existing tests.
     21
     22        * Modules/cache/CacheStorageConnection.cpp:
     23        (WebCore::CacheStorageConnection::clearPendingRequests):
     24        * Modules/cache/CacheStorageConnection.h:
     25        * Modules/cache/DOMCacheEngine.cpp:
     26        (WebCore::DOMCacheEngine::errorToException):
     27        * Modules/cache/DOMCacheEngine.h:
     28        * workers/WorkerGlobalScope.cpp:
     29        (WebCore::WorkerGlobalScope::prepareForTermination):
     30        (WebCore::WorkerGlobalScope::stopIndexedDatabase):
     31
    1322019-04-03  Youenn Fablet  <youenn@apple.com>
    233
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.cpp

    r226481 r243812  
    3333namespace WebCore {
    3434using namespace WebCore::DOMCacheEngine;
     35
     36void CacheStorageConnection::clearPendingRequests()
     37{
     38    auto openAndRemoveCachePendingRequests = WTFMove(m_openAndRemoveCachePendingRequests);
     39    for (auto& callback : openAndRemoveCachePendingRequests.values())
     40        callback(makeUnexpected(DOMCacheEngine::Error::Stopped));
     41
     42    auto retrieveCachesPendingRequests = WTFMove(m_retrieveCachesPendingRequests);
     43    for (auto& callback : retrieveCachesPendingRequests.values())
     44        callback(makeUnexpected(DOMCacheEngine::Error::Stopped));
     45
     46    auto retrieveRecordsPendingRequests = WTFMove(m_retrieveRecordsPendingRequests);
     47    for (auto& callback : retrieveRecordsPendingRequests.values())
     48        callback(makeUnexpected(DOMCacheEngine::Error::Stopped));
     49
     50    auto batchDeleteAndPutPendingRequests = WTFMove(m_batchDeleteAndPutPendingRequests);
     51    for (auto& callback : batchDeleteAndPutPendingRequests.values())
     52        callback(makeUnexpected(DOMCacheEngine::Error::Stopped));
     53}
    3554
    3655void CacheStorageConnection::open(const ClientOrigin& origin, const String& cacheName, CacheIdentifierCallback&& callback)
  • trunk/Source/WebCore/Modules/cache/CacheStorageConnection.h

    r243276 r243812  
    5858    virtual void updateQuotaBasedOnSpaceUsage(const ClientOrigin&) { }
    5959
     60    void clearPendingRequests();
     61
    6062protected:
    6163    CacheStorageConnection() =  default;
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.cpp

    r234278 r243812  
    4747    case Error::QuotaExceeded:
    4848        return Exception { QuotaExceededError, "Quota exceeded"_s };
     49    case Error::Internal:
     50        return Exception { TypeError, "Internal error"_s };
    4951    default:
    50         return Exception { TypeError, "Internal error"_s };
     52        ASSERT_NOT_REACHED();
     53        return Exception { TypeError, "Connection stopped"_s };
    5154    }
    5255}
  • trunk/Source/WebCore/Modules/cache/DOMCacheEngine.h

    r239427 r243812  
    4545    WriteDisk,
    4646    QuotaExceeded,
    47     Internal
     47    Internal,
     48    Stopped
    4849};
    4950
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r239569 r243812  
    114114    stopActiveDOMObjects();
    115115
     116    if (m_cacheStorageConnection)
     117        m_cacheStorageConnection->clearPendingRequests();
     118
    116119    m_inspectorController->workerTerminating();
    117120
Note: See TracChangeset for help on using the changeset viewer.