Index: content/child/service_worker/service_worker_provider_context.cc |
diff --git a/content/child/service_worker/service_worker_provider_context.cc b/content/child/service_worker/service_worker_provider_context.cc |
index d42b6d82ef1aed22c3d4d5c86cce1e036185d1db..246a19c5c6f00f863b3d022c9708a2893896f903 100644 |
--- a/content/child/service_worker/service_worker_provider_context.cc |
+++ b/content/child/service_worker/service_worker_provider_context.cc |
@@ -36,6 +36,11 @@ ServiceWorkerProviderContext::~ServiceWorkerProviderContext() { |
} |
} |
+ServiceWorkerHandleReference* ServiceWorkerProviderContext::waiting() { |
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
+ return waiting_.get(); |
+} |
+ |
ServiceWorkerHandleReference* ServiceWorkerProviderContext::current() { |
DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
return current_.get(); |
@@ -44,14 +49,30 @@ ServiceWorkerHandleReference* ServiceWorkerProviderContext::current() { |
void ServiceWorkerProviderContext::OnServiceWorkerStateChanged( |
int handle_id, |
blink::WebServiceWorkerState state) { |
- // Currently .current is the only ServiceWorker associated to this provider. |
- DCHECK_EQ(current_handle_id(), handle_id); |
- current_->set_state(state); |
+ ServiceWorkerHandleReference* which = NULL; |
+ if (handle_id == current_handle_id()) { |
+ which = current_.get(); |
+ } else if (handle_id == waiting_handle_id()) { |
+ which = waiting_.get(); |
+ } |
+ |
+ // We should only get messages for ServiceWorkers associated with |
+ // this provider. |
+ DCHECK(which); |
+ |
+ which->set_state(state); |
// TODO(kinuko): We can forward the message to other threads here |
// when we support navigator.serviceWorker in dedicated workers. |
} |
+void ServiceWorkerProviderContext::OnSetWaitingServiceWorker( |
+ int provider_id, |
+ const ServiceWorkerObjectInfo& info) { |
+ DCHECK_EQ(provider_id_, provider_id); |
+ waiting_ = ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_); |
+} |
+ |
void ServiceWorkerProviderContext::OnSetCurrentServiceWorker( |
int provider_id, |
const ServiceWorkerObjectInfo& info) { |
@@ -70,4 +91,9 @@ int ServiceWorkerProviderContext::current_handle_id() const { |
return current_ ? current_->info().handle_id : kInvalidServiceWorkerHandleId; |
} |
+int ServiceWorkerProviderContext::waiting_handle_id() const { |
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread()); |
+ return waiting_ ? waiting_->info().handle_id : kInvalidServiceWorkerHandleId; |
+} |
+ |
} // namespace content |