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

Unified Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Make changes requested by danakj, fix a few more headers Created 4 years, 1 month 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/child/service_worker/service_worker_dispatcher.cc
diff --git a/content/child/service_worker/service_worker_dispatcher.cc b/content/child/service_worker/service_worker_dispatcher.cc
index 4e18acab56905da319d2e70acf02de5f1772c540..c1934f515c181edec240f2fc7081ef25eac5cdae 100644
--- a/content/child/service_worker/service_worker_dispatcher.cc
+++ b/content/child/service_worker/service_worker_dispatcher.cc
@@ -121,13 +121,11 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
int provider_id,
const GURL& pattern,
const GURL& script_url,
- WebServiceWorkerRegistrationCallbacks* callbacks) {
+ std::unique_ptr<WebServiceWorkerRegistrationCallbacks> callbacks) {
DCHECK(callbacks);
if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars ||
script_url.possibly_invalid_spec().size() > url::kMaxURLChars) {
- std::unique_ptr<WebServiceWorkerRegistrationCallbacks> owned_callbacks(
- callbacks);
std::string error_message(kServiceWorkerRegisterErrorPrefix);
error_message += "The provided scriptURL or scope is too long.";
callbacks->onError(
@@ -136,7 +134,7 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
return;
}
- int request_id = pending_registration_callbacks_.Add(callbacks);
+ int request_id = pending_registration_callbacks_.Add(std::move(callbacks));
TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker",
"ServiceWorkerDispatcher::RegisterServiceWorker",
request_id,
@@ -149,9 +147,9 @@ void ServiceWorkerDispatcher::RegisterServiceWorker(
void ServiceWorkerDispatcher::UpdateServiceWorker(
int provider_id,
int64_t registration_id,
- WebServiceWorkerUpdateCallbacks* callbacks) {
+ std::unique_ptr<WebServiceWorkerUpdateCallbacks> callbacks) {
DCHECK(callbacks);
- int request_id = pending_update_callbacks_.Add(callbacks);
+ int request_id = pending_update_callbacks_.Add(std::move(callbacks));
thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker(
CurrentWorkerId(), request_id, provider_id, registration_id));
}
@@ -159,9 +157,9 @@ void ServiceWorkerDispatcher::UpdateServiceWorker(
void ServiceWorkerDispatcher::UnregisterServiceWorker(
int provider_id,
int64_t registration_id,
- WebServiceWorkerUnregistrationCallbacks* callbacks) {
+ std::unique_ptr<WebServiceWorkerUnregistrationCallbacks> callbacks) {
DCHECK(callbacks);
- int request_id = pending_unregistration_callbacks_.Add(callbacks);
+ int request_id = pending_unregistration_callbacks_.Add(std::move(callbacks));
TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
"ServiceWorkerDispatcher::UnregisterServiceWorker",
request_id, "Registration ID", registration_id);
@@ -172,12 +170,10 @@ void ServiceWorkerDispatcher::UnregisterServiceWorker(
void ServiceWorkerDispatcher::GetRegistration(
int provider_id,
const GURL& document_url,
- WebServiceWorkerGetRegistrationCallbacks* callbacks) {
+ std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> callbacks) {
DCHECK(callbacks);
if (document_url.possibly_invalid_spec().size() > url::kMaxURLChars) {
- std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> owned_callbacks(
- callbacks);
std::string error_message(kServiceWorkerGetRegistrationErrorPrefix);
error_message += "The provided documentURL is too long.";
callbacks->onError(
@@ -186,7 +182,8 @@ void ServiceWorkerDispatcher::GetRegistration(
return;
}
- int request_id = pending_get_registration_callbacks_.Add(callbacks);
+ int request_id =
+ pending_get_registration_callbacks_.Add(std::move(callbacks));
TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
"ServiceWorkerDispatcher::GetRegistration",
request_id,
@@ -197,10 +194,12 @@ void ServiceWorkerDispatcher::GetRegistration(
void ServiceWorkerDispatcher::GetRegistrations(
int provider_id,
- WebServiceWorkerGetRegistrationsCallbacks* callbacks) {
+ std::unique_ptr<WebServiceWorkerGetRegistrationsCallbacks> callbacks) {
DCHECK(callbacks);
- int request_id = pending_get_registrations_callbacks_.Add(callbacks);
+ int request_id =
+ pending_get_registrations_callbacks_.Add(std::move(callbacks));
+
TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker",
"ServiceWorkerDispatcher::GetRegistrations",
request_id);
@@ -210,8 +209,9 @@ void ServiceWorkerDispatcher::GetRegistrations(
void ServiceWorkerDispatcher::GetRegistrationForReady(
int provider_id,
- WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) {
- int request_id = get_for_ready_callbacks_.Add(callbacks);
+ std::unique_ptr<WebServiceWorkerGetRegistrationForReadyCallbacks>
+ callbacks) {
+ int request_id = get_for_ready_callbacks_.Add(std::move(callbacks));
TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker",
"ServiceWorkerDispatcher::GetRegistrationForReady",
request_id);
@@ -226,7 +226,7 @@ void ServiceWorkerDispatcher::EnableNavigationPreload(
std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks) {
DCHECK(callbacks);
int request_id =
- enable_navigation_preload_callbacks_.Add(callbacks.release());
+ enable_navigation_preload_callbacks_.Add(std::move(callbacks));
thread_safe_sender_->Send(new ServiceWorkerHostMsg_EnableNavigationPreload(
CurrentWorkerId(), request_id, provider_id, registration_id, enable));
}
@@ -237,7 +237,7 @@ void ServiceWorkerDispatcher::GetNavigationPreloadState(
std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) {
DCHECK(callbacks);
int request_id =
- get_navigation_preload_state_callbacks_.Add(callbacks.release());
+ get_navigation_preload_state_callbacks_.Add(std::move(callbacks));
thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetNavigationPreloadState(
CurrentWorkerId(), request_id, provider_id, registration_id));
}
@@ -249,7 +249,7 @@ void ServiceWorkerDispatcher::SetNavigationPreloadHeader(
std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks) {
DCHECK(callbacks);
int request_id =
- set_navigation_preload_header_callbacks_.Add(callbacks.release());
+ set_navigation_preload_header_callbacks_.Add(std::move(callbacks));
thread_safe_sender_->Send(new ServiceWorkerHostMsg_SetNavigationPreloadHeader(
CurrentWorkerId(), request_id, provider_id, registration_id, value));
}

Powered by Google App Engine
This is Rietveld 408576698