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

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: rebase 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..df6f784976cf15c4c88ddee17bdfc5f3a9f8bcdd 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -1392,24 +1392,26 @@ 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_)) {
falken 2015/03/23 00:38:57 (unrelated to this patch) I think there might be a
michaeln 2015/03/23 20:02:26 Good question. I think the answer is 'yes', hiroki
xiang 2015/03/24 07:32:51 Thanks for the clarification, yes, the Registratio
+ 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)));
+ return;
michaeln 2015/03/20 19:25:21 this return statement is not needed
xiang 2015/03/24 07:32:51 Done.
}
void ServiceWorkerVersion::OnPongFromWorker() {
@@ -1450,24 +1452,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