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

Unified Diff: content/browser/service_worker/service_worker_dispatcher_host.cc

Issue 894973003: ServiceWorker: Make "ready" fetches registration from browser process(2/3). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup Created 5 years, 10 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/browser/service_worker/service_worker_dispatcher_host.cc
diff --git a/content/browser/service_worker/service_worker_dispatcher_host.cc b/content/browser/service_worker/service_worker_dispatcher_host.cc
index e707151e9f77aab3a9fb2ec3028688b3e1abf7e3..cf5b01409b9c642bce74ce0e4b8813bfa07047db 100644
--- a/content/browser/service_worker/service_worker_dispatcher_host.cc
+++ b/content/browser/service_worker/service_worker_dispatcher_host.cc
@@ -163,6 +163,8 @@ bool ServiceWorkerDispatcherHost::OnMessageReceived(
OnUnregisterServiceWorker)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetRegistration,
OnGetRegistration)
+ IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_GetReadyRegistration,
+ OnGetReadyRegistration)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderCreated,
OnProviderCreated)
IPC_MESSAGE_HANDLER(ServiceWorkerHostMsg_ProviderDestroyed,
@@ -507,6 +509,28 @@ void ServiceWorkerDispatcherHost::OnGetRegistration(
request_id));
}
+void ServiceWorkerDispatcherHost::OnGetReadyRegistration(int thread_id,
+ int request_id,
+ int provider_id) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerDispatcherHost::OnGetReadyRegistration");
+ if (!GetContext())
+ return;
+ ServiceWorkerProviderHost* provider_host =
+ GetContext()->GetProviderHost(render_process_id_, provider_id);
+ if (!provider_host || !provider_host->IsContextAlive())
+ return;
+
+ TRACE_EVENT_ASYNC_BEGIN0(
+ "ServiceWorker",
+ "ServiceWorkerDispatcherHost::GetReadyRegistration",
+ request_id);
+
+ provider_host->GetReadyRegistration(
+ base::Bind(&ServiceWorkerDispatcherHost::GetReadyRegistrationComplete,
+ this, thread_id, request_id, provider_host->AsWeakPtr()));
+}
+
void ServiceWorkerDispatcherHost::OnPostMessageToWorker(
int handle_id,
const base::string16& message,
@@ -917,6 +941,27 @@ void ServiceWorkerDispatcherHost::GetRegistrationComplete(
thread_id, request_id, info, attrs));
}
+void ServiceWorkerDispatcherHost::GetReadyRegistrationComplete(
+ int thread_id,
+ int request_id,
+ base::WeakPtr<ServiceWorkerProviderHost> provider_host,
+ ServiceWorkerRegistration* registration) {
+ DCHECK(registration);
+ TRACE_EVENT_ASYNC_END1("ServiceWorker",
+ "ServiceWorkerDispatcherHost::GetReadyRegistration",
+ request_id,
+ "Registration ID",
+ registration ? registration->id()
+ : kInvalidServiceWorkerRegistrationId);
+
+ ServiceWorkerRegistrationObjectInfo info;
+ ServiceWorkerVersionAttributes attrs;
+ GetRegistrationObjectInfoAndVersionAttributes(
+ provider_host, registration, &info, &attrs);
+ Send(new ServiceWorkerMsg_DidGetReadyRegistration(
+ thread_id, request_id, info, attrs));
+}
+
void ServiceWorkerDispatcherHost::SendRegistrationError(
int thread_id,
int request_id,

Powered by Google App Engine
This is Rietveld 408576698