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

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

Issue 477593007: ServiceWorker: Make '.ready' return a promise to be resolved with ServiceWorkerRegistration (2/3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 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 3dfcff84e8cbf025ff64f75ee9627d9ec2a14e92..9eb7574151d097d62af3e933850a36409149324b 100644
--- a/content/child/service_worker/service_worker_provider_context.cc
+++ b/content/child/service_worker/service_worker_provider_context.cc
@@ -10,6 +10,7 @@
#include "content/child/child_thread.h"
#include "content/child/service_worker/service_worker_dispatcher.h"
#include "content/child/service_worker/service_worker_handle_reference.h"
+#include "content/child/service_worker/service_worker_registration_handle_reference.h"
#include "content/child/thread_safe_sender.h"
#include "content/child/worker_task_runner.h"
#include "content/common/service_worker/service_worker_messages.h"
@@ -56,6 +57,12 @@ ServiceWorkerHandleReference* ServiceWorkerProviderContext::controller() {
return controller_.get();
}
+ServiceWorkerRegistrationHandleReference*
+ServiceWorkerProviderContext::registration() {
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
+ return registration_.get();
+}
+
void ServiceWorkerProviderContext::OnServiceWorkerStateChanged(
int handle_id,
blink::WebServiceWorkerState state) {
@@ -117,6 +124,16 @@ void ServiceWorkerProviderContext::OnSetControllerServiceWorker(
// when we support navigator.serviceWorker in dedicated workers.
}
+void ServiceWorkerProviderContext::AssociateRegistration(
+ const ServiceWorkerRegistrationObjectInfo& info) {
+ registration_ = ServiceWorkerRegistrationHandleReference::Adopt(
+ info, thread_safe_sender_);
+}
+
+void ServiceWorkerProviderContext::UnassociateRegistration() {
+ registration_.reset();
+}
+
int ServiceWorkerProviderContext::installing_handle_id() const {
DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
return installing_ ? installing_->info().handle_id
@@ -141,4 +158,10 @@ int ServiceWorkerProviderContext::controller_handle_id() const {
: kInvalidServiceWorkerHandleId;
}
+int ServiceWorkerProviderContext::registration_handle_id() const {
+ DCHECK(main_thread_loop_proxy_->RunsTasksOnCurrentThread());
+ return registration_ ? registration_->info().handle_id
+ : kInvalidServiceWorkerRegistrationHandleId;
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698