Changeset 252227 in webkit


Ignore:
Timestamp:
Nov 7, 2019 6:35:32 PM (5 years ago)
Author:
Chris Dumez
Message:

Use ActiveDOMObject::queueTaskKeepingObjectAlive() in DOMCache
https://bugs.webkit.org/show_bug.cgi?id=203985

Reviewed by Ryosuke Niwa.

Use ActiveDOMObject::queueTaskKeepingObjectAlive() in DOMCache and drop DOMCache::enqueueTask().

  • Modules/cache/DOMCache.cpp:

(WebCore::DOMCache::match):
(WebCore::DOMCache::matchAll):
(WebCore::DOMCache::addAll):
(WebCore::DOMCache::putWithResponseData):
(WebCore::DOMCache::put):
(WebCore::DOMCache::remove):
(WebCore::DOMCache::keys):
(WebCore::DOMCache::enqueueTask): Deleted.

  • Modules/cache/DOMCache.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r252226 r252227  
     12019-11-07  Chris Dumez  <cdumez@apple.com>
     2
     3        Use ActiveDOMObject::queueTaskKeepingObjectAlive() in DOMCache
     4        https://bugs.webkit.org/show_bug.cgi?id=203985
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Use ActiveDOMObject::queueTaskKeepingObjectAlive() in DOMCache and drop DOMCache::enqueueTask().
     9
     10        * Modules/cache/DOMCache.cpp:
     11        (WebCore::DOMCache::match):
     12        (WebCore::DOMCache::matchAll):
     13        (WebCore::DOMCache::addAll):
     14        (WebCore::DOMCache::putWithResponseData):
     15        (WebCore::DOMCache::put):
     16        (WebCore::DOMCache::remove):
     17        (WebCore::DOMCache::keys):
     18        (WebCore::DOMCache::enqueueTask): Deleted.
     19        * Modules/cache/DOMCache.h:
     20
    1212019-11-07  Kenneth Russell  <kbr@chromium.org>
    222
  • trunk/Source/WebCore/Modules/cache/DOMCache.cpp

    r251968 r252227  
    6060{
    6161    doMatch(WTFMove(info), WTFMove(options), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](ExceptionOr<RefPtr<FetchResponse>>&& result) mutable {
    62         enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     62        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    6363            if (result.hasException()) {
    6464                promise->reject(result.releaseException());
     
    124124    if (!request) {
    125125        retrieveRecords(URL { }, [this, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable {
    126             enqueueTask([this, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable {
     126            queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [this, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable {
    127127                if (exception) {
    128128                    promise.reject(WTFMove(exception.value()));
     
    135135    }
    136136    queryCache(request.releaseNonNull(), WTFMove(options), [this, promise = WTFMove(promise)](ExceptionOr<Vector<CacheStorageRecord>>&& result) mutable {
    137         enqueueTask([this, promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     137        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [this, promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    138138            if (result.hasException()) {
    139139                promise.reject(result.releaseException());
     
    243243    auto taskHandler = FetchTasksHandler::create(*this, [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](ExceptionOr<Vector<Record>>&& result) mutable {
    244244        if (result.hasException()) {
    245             enqueueTask([promise = WTFMove(promise), exception = result.releaseException()]() mutable {
     245            queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), exception = result.releaseException()]() mutable {
    246246                promise.reject(WTFMove(exception));
    247247            });
     
    249249        }
    250250        batchPutOperation(result.releaseReturnValue(), [this, protectedThis = WTFMove(protectedThis), promise = WTFMove(promise)](ExceptionOr<void>&& result) mutable {
    251             enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     251            queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    252252                promise.settle(WTFMove(result));
    253253            });
     
    314314{
    315315    if (responseBody.hasException()) {
    316         enqueueTask([promise = WTFMove(promise), exception = responseBody.releaseException()]() mutable {
     316        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), exception = responseBody.releaseException()]() mutable {
    317317            promise.reject(WTFMove(exception));
    318318        });
     
    324324        body = buffer.releaseNonNull();
    325325    batchPutOperation(request.get(), response.get(), WTFMove(body), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](ExceptionOr<void>&& result) mutable {
    326         enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     326        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    327327            promise.settle(WTFMove(result));
    328328        });
     
    390390
    391391    batchPutOperation(request.get(), response.get(), response->consumeBody(), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](ExceptionOr<void>&& result) mutable {
    392         enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     392        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    393393            promise.settle(WTFMove(result));
    394394        });
     
    408408
    409409    batchDeleteOperation(requestOrException.releaseReturnValue(), WTFMove(options), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](ExceptionOr<bool>&& result) mutable {
    410         enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     410        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    411411            promise.settle(WTFMove(result));
    412412        });
     
    436436    if (!request) {
    437437        retrieveRecords(URL { }, [this, promise = WTFMove(promise)](Optional<Exception>&& exception) mutable {
    438             enqueueTask([this, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable {
     438            queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [this, promise = WTFMove(promise), exception = WTFMove(exception)]() mutable {
    439439                if (exception) {
    440440                    promise.reject(WTFMove(exception.value()));
     
    448448
    449449    queryCache(request.releaseNonNull(), WTFMove(options), [this, protectedThis = makeRef(*this), promise = WTFMove(promise)](auto&& result) mutable {
    450         enqueueTask([promise = WTFMove(promise), result = WTFMove(result)]() mutable {
     450        queueTaskKeepingObjectAlive(*this, TaskSource::DOMManipulation, [promise = WTFMove(promise), result = WTFMove(result)]() mutable {
    451451            if (result.hasException()) {
    452452                promise.reject(result.releaseException());
     
    608608}
    609609
    610 void DOMCache::enqueueTask(Function<void()>&& task)
    611 {
    612     auto* context = scriptExecutionContext();
    613     if (!context)
    614         return;
    615     context->eventLoop().queueTask(TaskSource::DOMManipulation, *context, [protectedThis = makeRef(*this), pendingActivity = makePendingActivity(*this), task = WTFMove(task)] {
    616         task();
    617     });
    618 }
    619 
    620610} // namespace WebCore
  • trunk/Source/WebCore/Modules/cache/DOMCache.h

    r251968 r252227  
    8585    DOMCacheEngine::Record toConnectionRecord(const FetchRequest&, FetchResponse&, DOMCacheEngine::ResponseBody&&);
    8686
    87     void enqueueTask(Function<void()>&&);
    88 
    8987    String m_name;
    9088    uint64_t m_identifier;
Note: See TracChangeset for help on using the changeset viewer.