Chromium Code Reviews| Index: content/child/service_worker/web_service_worker_provider_impl.cc |
| diff --git a/content/child/service_worker/web_service_worker_provider_impl.cc b/content/child/service_worker/web_service_worker_provider_impl.cc |
| index 70285faa2abc43eea9401114a48a325e3c5f167a..6bb1e8a6829eac3ac431f7aed61b5025bff588b8 100644 |
| --- a/content/child/service_worker/web_service_worker_provider_impl.cc |
| +++ b/content/child/service_worker/web_service_worker_provider_impl.cc |
| @@ -34,6 +34,8 @@ void WebServiceWorkerProviderImpl::setClient( |
| RemoveProviderClient(); |
| return; |
| } |
| + if (!context_) |
|
kinuko
2015/06/23 10:55:56
Can we add a comment about when context_ is null,
horo
2015/06/23 13:55:13
After https://codereview.chromium.org/1199183002/,
|
| + return; |
| // TODO(kinuko): Here we could also register the current thread ID |
| // on the provider context so that multiple WebServiceWorkerProviderImpl |
| @@ -53,6 +55,8 @@ void WebServiceWorkerProviderImpl::registerServiceWorker( |
| const WebURL& pattern, |
| const WebURL& script_url, |
| WebServiceWorkerRegistrationCallbacks* callbacks) { |
| + if (!context_) |
| + return; |
|
kinuko
2015/06/23 10:55:56
Hmm, we'll leak callbacks. Also is it ok not to f
horo
2015/06/23 13:55:14
Same as the former
|
| GetDispatcher()->RegisterServiceWorker( |
| context_->provider_id(), pattern, script_url, callbacks); |
| } |
| @@ -60,26 +64,36 @@ void WebServiceWorkerProviderImpl::registerServiceWorker( |
| void WebServiceWorkerProviderImpl::getRegistration( |
| const blink::WebURL& document_url, |
| WebServiceWorkerRegistrationCallbacks* callbacks) { |
| + if (!context_) |
| + return; |
| GetDispatcher()->GetRegistration( |
| context_->provider_id(), document_url, callbacks); |
| } |
| void WebServiceWorkerProviderImpl::getRegistrations( |
| WebServiceWorkerGetRegistrationsCallbacks* callbacks) { |
| + if (!context_) |
| + return; |
| GetDispatcher()->GetRegistrations( |
| context_->provider_id(), callbacks); |
| } |
| void WebServiceWorkerProviderImpl::getRegistrationForReady( |
| WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) { |
| + if (!context_) |
| + return; |
| GetDispatcher()->GetRegistrationForReady(context_->provider_id(), callbacks); |
| } |
| int WebServiceWorkerProviderImpl::provider_id() const { |
| + if (!context_) |
| + return kInvalidServiceWorkerProviderId; |
| return context_->provider_id(); |
| } |
| void WebServiceWorkerProviderImpl::RemoveProviderClient() { |
| + if (!context_) |
| + return; |
| // Remove the provider client, but only if the dispatcher is still there. |
| // (For cleanup path we don't need to bother creating a new dispatcher) |
| ServiceWorkerDispatcher* dispatcher = |