Changeset 243818 in webkit
- Timestamp:
- Apr 3, 2019, 12:38:51 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
Modules/cache/DOMCache.cpp (modified) (3 diffs)
-
Modules/cache/DOMCacheStorage.cpp (modified) (2 diffs)
-
Modules/cache/DOMCacheStorage.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243817 r243818 1 2019-04-03 Youenn Fablet <youenn@apple.com> 2 3 Use makePendingActivity in DOMCache 4 https://bugs.webkit.org/show_bug.cgi?id=196515 5 6 Reviewed by Geoffrey Garen. 7 8 No change of behavior, just modernizing the code. 9 10 * Modules/cache/DOMCache.cpp: 11 (WebCore::DOMCache::retrieveRecords): 12 (WebCore::DOMCache::batchDeleteOperation): 13 (WebCore::DOMCache::batchPutOperation): 14 * Modules/cache/DOMCacheStorage.cpp: 15 (WebCore::DOMCacheStorage::match): 16 1 17 2019-04-03 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebCore/Modules/cache/DOMCache.cpp
r240237 r243818 432 432 void DOMCache::retrieveRecords(const URL& url, WTF::Function<void(Optional<Exception>&&)>&& callback) 433 433 { 434 setPendingActivity(*this);435 436 434 URL retrieveURL = url; 437 435 retrieveURL.removeQueryAndFragmentIdentifier(); 438 436 439 m_connection->retrieveRecords(m_identifier, retrieveURL, [this, callback = WTFMove(callback)](RecordsOrError&& result) { 440 if (!m_isStopped) { 441 if (!result.has_value()) { 442 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 443 return; 444 } 445 446 if (result.has_value()) 447 updateRecords(WTFMove(result.value())); 448 callback(WTF::nullopt); 449 } 450 unsetPendingActivity(*this); 437 m_connection->retrieveRecords(m_identifier, retrieveURL, [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordsOrError&& result) { 438 if (m_isStopped) 439 return; 440 441 if (!result.has_value()) { 442 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 443 return; 444 } 445 446 updateRecords(WTFMove(result.value())); 447 callback(WTF::nullopt); 451 448 }); 452 449 } … … 485 482 void DOMCache::batchDeleteOperation(const FetchRequest& request, CacheQueryOptions&& options, WTF::Function<void(ExceptionOr<bool>&&)>&& callback) 486 483 { 487 setPendingActivity(*this);488 m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {489 if (!m_isStopped) {490 if (!result.has_value()) 491 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));492 else493 callback(!result.value().isEmpty());494 } 495 unsetPendingActivity(*this);484 m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordIdentifiersOrError&& result) { 485 if (m_isStopped) 486 return; 487 488 if (!result.has_value()) { 489 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 490 return; 491 } 492 callback(!result.value().isEmpty()); 496 493 }); 497 494 } … … 528 525 void DOMCache::batchPutOperation(Vector<Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback) 529 526 { 530 setPendingActivity(*this); 531 m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) { 532 if (!m_isStopped) { 533 if (!result.has_value()) 534 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 535 else 536 callback({ }); 537 } 538 unsetPendingActivity(*this); 527 m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordIdentifiersOrError&& result) { 528 if (m_isStopped) 529 return; 530 if (!result.has_value()) { 531 callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error())); 532 return; 533 } 534 callback({ }); 539 535 }); 540 536 } -
trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp
r240237 r243818 84 84 } 85 85 86 void DOMCacheStorage::doSequentialMatch(DOMCache::RequestInfo&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise) 87 { 88 startSequentialMatch(WTF::map(m_caches, copyCache), WTFMove(info), WTFMove(options), [this, pendingActivity = makePendingActivity(*this), promise = WTFMove(promise)](ExceptionOr<FetchResponse*>&& result) mutable { 89 if (m_isStopped) 90 return; 91 if (result.hasException()) { 92 promise->reject(result.releaseException()); 93 return; 94 } 95 if (!result.returnValue()) { 96 promise->resolve(); 97 return; 98 } 99 promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue()); 100 }); 101 } 102 86 103 void DOMCacheStorage::match(DOMCache::RequestInfo&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise) 87 104 { … … 102 119 } 103 120 104 setPendingActivity(*this); 105 startSequentialMatch(WTF::map(m_caches, copyCache), WTFMove(info), WTFMove(options), [this, promise = WTFMove(promise)](ExceptionOr<FetchResponse*>&& result) mutable { 106 if (!m_isStopped) { 107 if (result.hasException()) { 108 promise->reject(result.releaseException()); 109 return; 110 } 111 if (!result.returnValue()) 112 promise->resolve(); 113 else 114 promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue()); 115 } 116 unsetPendingActivity(*this); 117 }); 121 this->doSequentialMatch(WTFMove(info), WTFMove(options), WTFMove(promise)); 118 122 }); 119 123 } -
trunk/Source/WebCore/Modules/cache/DOMCacheStorage.h
r239427 r243818 55 55 void doOpen(const String& name, DOMPromiseDeferred<IDLInterface<DOMCache>>&&); 56 56 void doRemove(const String&, DOMPromiseDeferred<IDLBoolean>&&); 57 void doSequentialMatch(DOMCache::RequestInfo&&, CacheQueryOptions&&, Ref<DeferredPromise>&&); 57 58 void retrieveCaches(WTF::Function<void(Optional<Exception>&&)>&&); 58 59 Ref<DOMCache> findCacheOrCreate(DOMCacheEngine::CacheInfo&&);
Note:
See TracChangeset
for help on using the changeset viewer.