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( |