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

Unified Diff: content/child/service_worker/web_service_worker_impl.cc

Issue 255813003: ServiceWorker: Queue worker state changes until Blink is ready for them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include style Created 6 years, 8 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
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

Powered by Google App Engine
This is Rietveld 408576698