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

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

Issue 354643003: ServiceWorker: Support navigator.serviceWorker.active (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fix Created 6 years, 5 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/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 d7763f67ff545b8e967e1f91881ccb94c2ffc81e..222a8611cd682d6a459f166afce81b57bee1f75f 100644
--- a/content/child/service_worker/service_worker_provider_context.cc
+++ b/content/child/service_worker/service_worker_provider_context.cc
@@ -46,6 +46,11 @@ ServiceWorkerHandleReference* ServiceWorkerProviderContext::waiting() {
return waiting_.get();
}
+ServiceWorkerHandleReference* ServiceWorkerProviderContext::active() {
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
+ return active_.get();
+}
+
ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() {
DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
return controller_.get();
@@ -55,13 +60,14 @@ void ServiceWorkerProviderContext::OnServiceWorkerStateChanged(
int handle_id,
blink::WebServiceWorkerState state) {
ServiceWorkerHandleReference* which = NULL;
- if (handle_id == controller_handle_id()) {
+ if (handle_id == controller_handle_id())
which = controller_.get();
- } else if (handle_id == waiting_handle_id()) {
+ else if (handle_id == active_handle_id())
+ which = active_.get();
+ else if (handle_id == waiting_handle_id())
which = waiting_.get();
- } else if (handle_id == installing_handle_id()) {
+ else if (handle_id == installing_handle_id())
which = installing_.get();
- }
// We should only get messages for ServiceWorkers associated with
// this provider.
@@ -87,6 +93,13 @@ void ServiceWorkerProviderContext::OnSetWaitingServiceWorker(
waiting_ = ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_);
}
+void ServiceWorkerProviderContext::OnSetActiveServiceWorker(
+ int provider_id,
+ const ServiceWorkerObjectInfo& info) {
+ DCHECK_EQ(provider_id_, provider_id);
+ active_ = ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_);
+}
+
void ServiceWorkerProviderContext::OnSetControllerServiceWorker(
int provider_id,
const ServiceWorkerObjectInfo& info) {
@@ -112,6 +125,12 @@ int ServiceWorkerProviderContext::waiting_handle_id() const {
: kInvalidServiceWorkerHandleId;
}
+int ServiceWorkerProviderContext::active_handle_id() const {
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
+ return active_ ? active_->info().handle_id
+ : kInvalidServiceWorkerHandleId;
+}
+
int ServiceWorkerProviderContext::controller_handle_id() const {
DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
return controller_ ? controller_->info().handle_id

Powered by Google App Engine
This is Rietveld 408576698