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

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

Issue 2181553003: Stop passing const-reference of SWRegistration in all GetRegistrationsCallbacks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix ServiceWorkerContextCore::DidFindRegistrationForCheckHasServiceWorker() Created 4 years, 5 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_storage.cc
diff --git a/content/browser/service_worker/service_worker_storage.cc b/content/browser/service_worker/service_worker_storage.cc
index 7fe900830c9308030e0719fd23069cc400e1bc6e..8cf5ce3f148112c568528b41e340aef8cf621e57 100644
--- a/content/browser/service_worker/service_worker_storage.cc
+++ b/content/browser/service_worker/service_worker_storage.cc
@@ -39,7 +39,7 @@ void RunSoon(const tracked_objects::Location& from_here,
}
void CompleteFindNow(
- const scoped_refptr<ServiceWorkerRegistration>& registration,
+ scoped_refptr<ServiceWorkerRegistration> registration,
ServiceWorkerStatusCode status,
const ServiceWorkerStorage::FindRegistrationCallback& callback) {
if (registration && registration->is_deleted()) {
@@ -47,16 +47,16 @@ void CompleteFindNow(
callback.Run(SERVICE_WORKER_ERROR_NOT_FOUND, nullptr);
return;
}
- callback.Run(status, registration);
+ callback.Run(status, std::move(registration));
}
void CompleteFindSoon(
const tracked_objects::Location& from_here,
- const scoped_refptr<ServiceWorkerRegistration>& registration,
+ scoped_refptr<ServiceWorkerRegistration> registration,
ServiceWorkerStatusCode status,
const ServiceWorkerStorage::FindRegistrationCallback& callback) {
- RunSoon(from_here,
- base::Bind(&CompleteFindNow, registration, status, callback));
+ RunSoon(from_here, base::Bind(&CompleteFindNow, std::move(registration),
+ status, callback));
}
const base::FilePath::CharType kDatabaseName[] =
@@ -167,9 +167,7 @@ void ServiceWorkerStorage::FindRegistrationForDocument(
TRACE_EVENT_SCOPE_THREAD,
"URL", document_url.spec(),
"Status", ServiceWorkerStatusToString(status));
- CompleteFindNow(installing_registration,
- status,
- callback);
+ CompleteFindNow(std::move(installing_registration), status, callback);
return;
}
@@ -214,10 +212,11 @@ void ServiceWorkerStorage::FindRegistrationForPattern(
// Look for something currently being installed.
scoped_refptr<ServiceWorkerRegistration> installing_registration =
FindInstallingRegistrationForPattern(scope);
- CompleteFindSoon(FROM_HERE, installing_registration,
- installing_registration ? SERVICE_WORKER_OK
- : SERVICE_WORKER_ERROR_NOT_FOUND,
- callback);
+ ServiceWorkerStatusCode installing_status =
+ installing_registration ? SERVICE_WORKER_OK
+ : SERVICE_WORKER_ERROR_NOT_FOUND;
+ CompleteFindSoon(FROM_HERE, std::move(installing_registration),
+ installing_status, callback);
return;
}
@@ -277,7 +276,7 @@ void ServiceWorkerStorage::FindRegistrationForId(
scoped_refptr<ServiceWorkerRegistration> registration =
context_->GetLiveRegistration(registration_id);
if (registration) {
- CompleteFindNow(registration, SERVICE_WORKER_OK, callback);
+ CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, callback);
return;
}
@@ -896,7 +895,7 @@ void ServiceWorkerStorage::DidFindRegistrationForDocument(
ServiceWorkerStatusCode installing_status =
installing_registration ? SERVICE_WORKER_OK
: SERVICE_WORKER_ERROR_NOT_FOUND;
- callback.Run(installing_status, installing_registration);
+ callback.Run(installing_status, std::move(installing_registration));
TRACE_EVENT_ASYNC_END2(
"ServiceWorker",
"ServiceWorkerStorage::FindRegistrationForDocument",
@@ -933,9 +932,10 @@ void ServiceWorkerStorage::DidFindRegistrationForPattern(
if (status == ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) {
scoped_refptr<ServiceWorkerRegistration> installing_registration =
FindInstallingRegistrationForPattern(scope);
- callback.Run(installing_registration ? SERVICE_WORKER_OK
- : SERVICE_WORKER_ERROR_NOT_FOUND,
- installing_registration);
+ ServiceWorkerStatusCode installing_status =
+ installing_registration ? SERVICE_WORKER_OK
+ : SERVICE_WORKER_ERROR_NOT_FOUND;
+ callback.Run(installing_status, std::move(installing_registration));
return;
}
@@ -973,7 +973,7 @@ void ServiceWorkerStorage::ReturnFoundRegistration(
DCHECK(!resources.empty());
scoped_refptr<ServiceWorkerRegistration> registration =
GetOrCreateRegistration(data, resources);
- CompleteFindNow(registration, SERVICE_WORKER_OK, callback);
+ CompleteFindNow(std::move(registration), SERVICE_WORKER_OK, callback);
}
void ServiceWorkerStorage::DidGetRegistrations(
@@ -1012,7 +1012,7 @@ void ServiceWorkerStorage::DidGetRegistrations(
}
}
- callback.Run(SERVICE_WORKER_OK, registrations);
+ callback.Run(SERVICE_WORKER_OK, std::move(registrations));
}
void ServiceWorkerStorage::DidGetRegistrationsInfos(

Powered by Google App Engine
This is Rietveld 408576698