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

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

Issue 535753002: ServiceWorker: Implement navigator.serviceWorker.getRegistration [2/3] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 032dfa2921d3ae5f4d6e83c25e0ee6bc49733a5d..eb05799c13285b6c1133cbf457250f20b6f17d4e 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -56,6 +56,8 @@ void ServiceWorkerDispatcher::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistered, OnRegistered)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerUnregistered,
OnUnregistered)
+ IPC_MESSAGE_HANDLER(ServiceWorkerMsg_DidGetRegistration,
+ OnDidGetRegistration)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerRegistrationError,
OnRegistrationError)
IPC_MESSAGE_HANDLER(ServiceWorkerMsg_ServiceWorkerStateChanged,
@@ -119,6 +121,26 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker(
CurrentWorkerId(), request_id, provider_id, pattern));
}
+void ServiceWorkerDispatcher::GetRegistration(
+ int provider_id,
+ const GURL& document_url,
+ WebServiceWorkerRegistrationCallbacks* callbacks) {
+ DCHECK(callbacks);
+
+ if (document_url.possibly_invalid_spec().size() > GetMaxURLChars()) {
+ scoped_ptr<WebServiceWorkerRegistrationCallbacks>
+ owned_callbacks(callbacks);
+ scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
+ WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
+ callbacks->onError(error.release());
+ return;
+ }
+
+ int request_id = pending_callbacks_.Add(callbacks);
+ thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration(
+ CurrentWorkerId(), request_id, provider_id, document_url));
+}
+
void ServiceWorkerDispatcher::AddProviderContext(
ServiceWorkerProviderContext* provider_context) {
DCHECK(provider_context);
@@ -271,6 +293,28 @@ void ServiceWorkerDispatcher::OnUnregistered(
pending_callbacks_.Remove(request_id);
}
+void ServiceWorkerDispatcher::OnDidGetRegistration(
+ int thread_id,
+ int request_id,
+ const ServiceWorkerRegistrationObjectInfo& info,
+ const ServiceWorkerVersionAttributes& attrs) {
+ WebServiceWorkerRegistrationCallbacks* callbacks =
+ pending_callbacks_.Lookup(request_id);
+ DCHECK(callbacks);
+ if (!callbacks)
+ return;
+
+ WebServiceWorkerRegistrationImpl* registration =
+ GetServiceWorkerRegistration(info, true);
+ if (registration) {
+ registration->SetInstalling(GetServiceWorker(attrs.installing, true));
+ registration->SetWaiting(GetServiceWorker(attrs.waiting, true));
+ registration->SetActive(GetServiceWorker(attrs.active, true));
+ }
+ callbacks->onSuccess(registration);
nhiroki 2014/09/05 04:55:09 I guess this could be resolved with 'null' if a re
Kunihiko Sakamoto 2014/09/09 07:28:10 Done (in Blink side).
+ pending_callbacks_.Remove(request_id);
+}
+
void ServiceWorkerDispatcher::OnRegistrationError(
int thread_id,
int request_id,

Powered by Google App Engine
This is Rietveld 408576698