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

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

Issue 1013423002: ServiceWorker: Make claim() uses living matching registrations instead of fetching from DB. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for #3 Created 5 years, 9 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
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index 0682c5a81144bde859d5ebea1b03b1a3448f7e5e..056c23d79874520857d9e2fae2f7662830c3c829 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -1392,24 +1392,25 @@ void ServiceWorkerVersion::DidSkipWaiting(int request_id) {
}
void ServiceWorkerVersion::OnClaimClients(int request_id) {
- StatusCallback callback = base::Bind(&ServiceWorkerVersion::DidClaimClients,
- weak_factory_.GetWeakPtr(), request_id);
if (status_ != ACTIVATING && status_ != ACTIVATED) {
- callback.Run(SERVICE_WORKER_ERROR_STATE);
+ embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError(
+ request_id, blink::WebServiceWorkerError::ErrorTypeState,
+ base::ASCIIToUTF16(kClaimClientsStateErrorMesage)));
return;
}
- if (!context_) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
+ if (context_) {
+ if (ServiceWorkerRegistration* registration =
+ context_->GetLiveRegistration(registration_id_)) {
+ registration->ClaimClients();
+ embedded_worker_->SendMessage(
+ ServiceWorkerMsg_DidClaimClients(request_id));
+ return;
+ }
}
- ServiceWorkerRegistration* registration =
- context_->GetLiveRegistration(registration_id_);
- if (!registration) {
- callback.Run(SERVICE_WORKER_ERROR_ABORT);
- return;
- }
- registration->ClaimClients(callback);
+ embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError(
+ request_id, blink::WebServiceWorkerError::ErrorTypeAbort,
+ base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage)));
}
void ServiceWorkerVersion::OnPongFromWorker() {
@@ -1450,24 +1451,6 @@ void ServiceWorkerVersion::DidEnsureLiveRegistrationForStartWorker(
}
}
-void ServiceWorkerVersion::DidClaimClients(
- int request_id, ServiceWorkerStatusCode status) {
- if (status == SERVICE_WORKER_ERROR_STATE) {
- embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError(
- request_id, blink::WebServiceWorkerError::ErrorTypeState,
- base::ASCIIToUTF16(kClaimClientsStateErrorMesage)));
- return;
- }
- if (status == SERVICE_WORKER_ERROR_ABORT) {
- embedded_worker_->SendMessage(ServiceWorkerMsg_ClaimClientsError(
- request_id, blink::WebServiceWorkerError::ErrorTypeAbort,
- base::ASCIIToUTF16(kClaimClientsShutdownErrorMesage)));
- return;
- }
- DCHECK(status == SERVICE_WORKER_OK);
- embedded_worker_->SendMessage(ServiceWorkerMsg_DidClaimClients(request_id));
-}
-
void ServiceWorkerVersion::DidGetClients(
int request_id,
const std::vector<ServiceWorkerClientInfo>& clients) {
« no previous file with comments | « content/browser/service_worker/service_worker_version.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698