Index: content/child/service_worker/web_service_worker_impl.cc |
diff --git a/content/child/service_worker/web_service_worker_impl.cc b/content/child/service_worker/web_service_worker_impl.cc |
index 626aa0bd31b5b376594627403f95b91e6c6fd964..02f877951c3b512f14045ac98fc498282eab6f54 100644 |
--- a/content/child/service_worker/web_service_worker_impl.cc |
+++ b/content/child/service_worker/web_service_worker_impl.cc |
@@ -44,17 +44,31 @@ WebServiceWorkerImpl::~WebServiceWorkerImpl() { |
dispatcher->RemoveServiceWorker(handle_id_); |
} |
-void WebServiceWorkerImpl::SetState(blink::WebServiceWorkerState new_state) { |
- state_ = new_state; |
- if (!proxy_) |
- return; |
- proxy_->dispatchStateChangeEvent(); |
+void WebServiceWorkerImpl::OnStateChanged( |
+ blink::WebServiceWorkerState new_state) { |
+ DCHECK(proxy_); |
+ if (proxy_->isReady()) |
+ ChangeState(new_state); |
+ else |
+ queued_states_.push_back(new_state); |
} |
void WebServiceWorkerImpl::setProxy(blink::WebServiceWorkerProxy* proxy) { |
proxy_ = proxy; |
} |
+void WebServiceWorkerImpl::proxyReadyChanged() { |
+ if (!proxy_->isReady()) |
+ return; |
+ for (std::vector<blink::WebServiceWorkerState>::iterator it = |
+ queued_states_.begin(); |
+ it != queued_states_.end(); |
+ ++it) { |
+ ChangeState(*it); |
+ } |
+ queued_states_.clear(); |
+} |
+ |
blink::WebURL WebServiceWorkerImpl::scope() const { |
return scope_; |
} |
@@ -75,4 +89,11 @@ void WebServiceWorkerImpl::postMessage(const WebString& message, |
WebMessagePortChannelImpl::ExtractMessagePortIDs(channels))); |
} |
+void WebServiceWorkerImpl::ChangeState(blink::WebServiceWorkerState new_state) { |
+ DCHECK(proxy_); |
+ DCHECK(proxy_->isReady()); |
+ state_ = new_state; |
+ proxy_->dispatchStateChangeEvent(); |
+} |
+ |
} // namespace content |