Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(509)

Unified Diff: content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc

Issue 544413002: Patch on top of https://codereview.chromium.org/474593002 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@sw-gavin
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/service_worker/service_worker_cache_storage_dispatcher.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc
diff --git a/content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc
index e620a4423a2dfbf8b815cdb44a50e3f2d5d66b4c..7fed7d3ef0cfb1c82a2158a145c5063cce9b69f6 100644
--- a/content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc
+++ b/content/renderer/service_worker/service_worker_cache_storage_dispatcher.cc
@@ -179,34 +179,48 @@ class ServiceWorkerCacheStorageDispatcher::WebCache
: dispatcher_(dispatcher), cache_id_(cache_id) {}
virtual ~WebCache() {
- dispatcher_->onWebCacheDestruction(cache_id_);
+ if (dispatcher_)
+ dispatcher_->onWebCacheDestruction(cache_id_);
}
// From blink::WebServiceWorkerCache:
virtual void dispatchMatch(CacheMatchCallbacks* callbacks,
const blink::WebServiceWorkerRequest& request,
const QueryParams& query_params) {
+ if (!dispatcher_)
+ return;
dispatcher_->dispatchMatchForCache(cache_id_, callbacks, request,
query_params);
}
virtual void dispatchMatchAll(CacheWithResponsesCallbacks* callbacks,
const blink::WebServiceWorkerRequest& request,
const QueryParams& query_params) {
+ if (!dispatcher_)
+ return;
dispatcher_->dispatchMatchAllForCache(cache_id_, callbacks, request,
query_params);
}
virtual void dispatchKeys(CacheWithRequestsCallbacks* callbacks,
const blink::WebServiceWorkerRequest* request,
const QueryParams& query_params) {
+ if (!dispatcher_)
+ return;
dispatcher_->dispatchKeysForCache(cache_id_, callbacks, request,
query_params);
}
virtual void dispatchBatch(
CacheWithResponsesCallbacks* callbacks,
const blink::WebVector<BatchOperation>& batch_operations) {
+ if (!dispatcher_)
+ return;
dispatcher_->dispatchBatchForCache(cache_id_, callbacks, batch_operations);
}
+ void Disconnect() {
+ DCHECK(dispatcher_);
+ dispatcher_ = NULL;
+ }
+
private:
// Not owned. Pointer to a dispatcher to use for sending events.
ServiceWorkerCacheStorageDispatcher* dispatcher_;
@@ -216,7 +230,8 @@ class ServiceWorkerCacheStorageDispatcher::WebCache
ServiceWorkerCacheStorageDispatcher::ServiceWorkerCacheStorageDispatcher(
ServiceWorkerScriptContext* script_context)
- : script_context_(script_context) {}
+ : script_context_(script_context) {
+}
ServiceWorkerCacheStorageDispatcher::~ServiceWorkerCacheStorageDispatcher() {
ClearCallbacksMapWithErrors(&get_callbacks_);
@@ -229,6 +244,13 @@ ServiceWorkerCacheStorageDispatcher::~ServiceWorkerCacheStorageDispatcher() {
ClearCallbacksMapWithErrors(&cache_match_all_callbacks_);
ClearCallbacksMapWithErrors(&cache_keys_callbacks_);
ClearCallbacksMapWithErrors(&cache_batch_callbacks_);
+
+ WebCacheMap::iterator iter(&web_caches_);
+ while (!iter.IsAtEnd()) {
+ iter.GetCurrentValue()->Disconnect();
+ web_caches_.Remove(iter.GetCurrentKey());
+ iter.Advance();
+ }
}
bool ServiceWorkerCacheStorageDispatcher::OnMessageReceived(
« no previous file with comments | « content/renderer/service_worker/service_worker_cache_storage_dispatcher.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698