+void ServiceWorkerDispatcherHost::OnGetRegistration(
+ int thread_id,
+ int request_id,
+ int provider_id,
+ const GURL& document_url) {
+ TRACE_EVENT0("ServiceWorker",
+ "ServiceWorkerDispatcherHost::OnGetRegistration");
+ if (!GetContext()) {
+ Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError(
+ thread_id,
+ request_id,
+ blink::WebServiceWorkerError::ErrorTypeAbort,
+ base::ASCIIToUTF16(kShutdownErrorMessage)));
+ return;
+ }
+
+ ServiceWorkerProviderHost* provider_host = GetContext()->GetProviderHost(
+ render_process_id_, provider_id);
+ if (!provider_host) {
+ BadMessageReceived();
+ return;
+ }
+ if (!provider_host->IsContextAlive()) {
+ Send(new ServiceWorkerMsg_ServiceWorkerGetRegistrationError(
+ thread_id,
+ request_id,
+ blink::WebServiceWorkerError::ErrorTypeAbort,
+ base::ASCIIToUTF16(kShutdownErrorMessage)));
+ return;
+ }
+
+ if (!CanGetRegistration(provider_host->document_url(), document_url)) {
+ BadMessageReceived();
+ return;
+ }
+
+ DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ if (GetContext()->storage()->IsDisabled()) {
+ SendGetRegistrationError(thread_id, request_id, SERVICE_WORKER_ERROR_ABORT);
+ return;
+ }
+
+ TRACE_EVENT_ASYNC_BEGIN1(
+ "ServiceWorker",
+ "ServiceWorkerDispatcherHost::GetRegistration",
+ request_id,
+ "Document URL", document_url.spec());
+
+ GetContext()->storage()->FindRegistrationForDocument(
+ document_url,
+ base::Bind(&ServiceWorkerDispatcherHost::GetRegistrationComplete,
+ this,
+ thread_id,
+ provider_id,
+ request_id));
+}
+