Diff
Modified: trunk/Source/WebCore/ChangeLog (243817 => 243818)
--- trunk/Source/WebCore/ChangeLog 2019-04-03 19:13:49 UTC (rev 243817)
+++ trunk/Source/WebCore/ChangeLog 2019-04-03 19:38:51 UTC (rev 243818)
@@ -1,3 +1,19 @@
+2019-04-03 Youenn Fablet <[email protected]>
+
+ Use makePendingActivity in DOMCache
+ https://bugs.webkit.org/show_bug.cgi?id=196515
+
+ Reviewed by Geoffrey Garen.
+
+ No change of behavior, just modernizing the code.
+
+ * Modules/cache/DOMCache.cpp:
+ (WebCore::DOMCache::retrieveRecords):
+ (WebCore::DOMCache::batchDeleteOperation):
+ (WebCore::DOMCache::batchPutOperation):
+ * Modules/cache/DOMCacheStorage.cpp:
+ (WebCore::DOMCacheStorage::match):
+
2019-04-03 Chris Dumez <[email protected]>
[XML Parser] Insert the error message block when stopping parsing and an error occurred
Modified: trunk/Source/WebCore/Modules/cache/DOMCache.cpp (243817 => 243818)
--- trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2019-04-03 19:13:49 UTC (rev 243817)
+++ trunk/Source/WebCore/Modules/cache/DOMCache.cpp 2019-04-03 19:38:51 UTC (rev 243818)
@@ -431,23 +431,20 @@
void DOMCache::retrieveRecords(const URL& url, WTF::Function<void(Optional<Exception>&&)>&& callback)
{
- setPendingActivity(*this);
-
URL retrieveURL = url;
retrieveURL.removeQueryAndFragmentIdentifier();
- m_connection->retrieveRecords(m_identifier, retrieveURL, [this, callback = WTFMove(callback)](RecordsOrError&& result) {
- if (!m_isStopped) {
- if (!result.has_value()) {
- callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
- return;
- }
+ m_connection->retrieveRecords(m_identifier, retrieveURL, [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordsOrError&& result) {
+ if (m_isStopped)
+ return;
- if (result.has_value())
- updateRecords(WTFMove(result.value()));
- callback(WTF::nullopt);
+ if (!result.has_value()) {
+ callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
+ return;
}
- unsetPendingActivity(*this);
+
+ updateRecords(WTFMove(result.value()));
+ callback(WTF::nullopt);
});
}
@@ -484,15 +481,15 @@
void DOMCache::batchDeleteOperation(const FetchRequest& request, CacheQueryOptions&& options, WTF::Function<void(ExceptionOr<bool>&&)>&& callback)
{
- setPendingActivity(*this);
- m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
- if (!m_isStopped) {
- if (!result.has_value())
- callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
- else
- callback(!result.value().isEmpty());
+ m_connection->batchDeleteOperation(m_identifier, request.internalRequest(), WTFMove(options), [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
+ if (m_isStopped)
+ return;
+
+ if (!result.has_value()) {
+ callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
+ return;
}
- unsetPendingActivity(*this);
+ callback(!result.value().isEmpty());
});
}
@@ -527,15 +524,14 @@
void DOMCache::batchPutOperation(Vector<Record>&& records, WTF::Function<void(ExceptionOr<void>&&)>&& callback)
{
- setPendingActivity(*this);
- m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
- if (!m_isStopped) {
- if (!result.has_value())
- callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
- else
- callback({ });
+ m_connection->batchPutOperation(m_identifier, WTFMove(records), [this, pendingActivity = makePendingActivity(*this), callback = WTFMove(callback)](RecordIdentifiersOrError&& result) {
+ if (m_isStopped)
+ return;
+ if (!result.has_value()) {
+ callback(DOMCacheEngine::convertToExceptionAndLog(scriptExecutionContext(), result.error()));
+ return;
}
- unsetPendingActivity(*this);
+ callback({ });
});
}
Modified: trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp (243817 => 243818)
--- trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp 2019-04-03 19:13:49 UTC (rev 243817)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheStorage.cpp 2019-04-03 19:38:51 UTC (rev 243818)
@@ -83,6 +83,23 @@
return cache.copyRef();
}
+void DOMCacheStorage::doSequentialMatch(DOMCache::RequestInfo&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise)
+{
+ startSequentialMatch(WTF::map(m_caches, copyCache), WTFMove(info), WTFMove(options), [this, pendingActivity = makePendingActivity(*this), promise = WTFMove(promise)](ExceptionOr<FetchResponse*>&& result) mutable {
+ if (m_isStopped)
+ return;
+ if (result.hasException()) {
+ promise->reject(result.releaseException());
+ return;
+ }
+ if (!result.returnValue()) {
+ promise->resolve();
+ return;
+ }
+ promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue());
+ });
+}
+
void DOMCacheStorage::match(DOMCache::RequestInfo&& info, CacheQueryOptions&& options, Ref<DeferredPromise>&& promise)
{
retrieveCaches([this, info = WTFMove(info), options = WTFMove(options), promise = WTFMove(promise)](Optional<Exception>&& exception) mutable {
@@ -101,20 +118,7 @@
return;
}
- setPendingActivity(*this);
- startSequentialMatch(WTF::map(m_caches, copyCache), WTFMove(info), WTFMove(options), [this, promise = WTFMove(promise)](ExceptionOr<FetchResponse*>&& result) mutable {
- if (!m_isStopped) {
- if (result.hasException()) {
- promise->reject(result.releaseException());
- return;
- }
- if (!result.returnValue())
- promise->resolve();
- else
- promise->resolve<IDLInterface<FetchResponse>>(*result.returnValue());
- }
- unsetPendingActivity(*this);
- });
+ this->doSequentialMatch(WTFMove(info), WTFMove(options), WTFMove(promise));
});
}
Modified: trunk/Source/WebCore/Modules/cache/DOMCacheStorage.h (243817 => 243818)
--- trunk/Source/WebCore/Modules/cache/DOMCacheStorage.h 2019-04-03 19:13:49 UTC (rev 243817)
+++ trunk/Source/WebCore/Modules/cache/DOMCacheStorage.h 2019-04-03 19:38:51 UTC (rev 243818)
@@ -54,6 +54,7 @@
void doOpen(const String& name, DOMPromiseDeferred<IDLInterface<DOMCache>>&&);
void doRemove(const String&, DOMPromiseDeferred<IDLBoolean>&&);
+ void doSequentialMatch(DOMCache::RequestInfo&&, CacheQueryOptions&&, Ref<DeferredPromise>&&);
void retrieveCaches(WTF::Function<void(Optional<Exception>&&)>&&);
Ref<DOMCache> findCacheOrCreate(DOMCacheEngine::CacheInfo&&);
Optional<ClientOrigin> origin() const;