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

Side by Side Diff: content/child/service_worker/service_worker_dispatcher.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Fix typo breaking a bunch of trybot builds, oops 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/child/service_worker/service_worker_dispatcher.h" 5 #include "content/child/service_worker/service_worker_dispatcher.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 OnPostMessage) 114 OnPostMessage)
115 IPC_MESSAGE_UNHANDLED(handled = false) 115 IPC_MESSAGE_UNHANDLED(handled = false)
116 IPC_END_MESSAGE_MAP() 116 IPC_END_MESSAGE_MAP()
117 DCHECK(handled) << "Unhandled message:" << msg.type(); 117 DCHECK(handled) << "Unhandled message:" << msg.type();
118 } 118 }
119 119
120 void ServiceWorkerDispatcher::RegisterServiceWorker( 120 void ServiceWorkerDispatcher::RegisterServiceWorker(
121 int provider_id, 121 int provider_id,
122 const GURL& pattern, 122 const GURL& pattern,
123 const GURL& script_url, 123 const GURL& script_url,
124 WebServiceWorkerRegistrationCallbacks* callbacks) { 124 WebServiceWorkerRegistrationCallbacks* callbacks) {
danakj 2016/11/18 00:15:33 it just doesn't stop does it.. and this?
125 DCHECK(callbacks); 125 DCHECK(callbacks);
126 126
127 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars || 127 if (pattern.possibly_invalid_spec().size() > url::kMaxURLChars ||
128 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) { 128 script_url.possibly_invalid_spec().size() > url::kMaxURLChars) {
129 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> owned_callbacks( 129 std::unique_ptr<WebServiceWorkerRegistrationCallbacks> owned_callbacks(
130 callbacks); 130 callbacks);
131 std::string error_message(kServiceWorkerRegisterErrorPrefix); 131 std::string error_message(kServiceWorkerRegisterErrorPrefix);
132 error_message += "The provided scriptURL or scope is too long."; 132 error_message += "The provided scriptURL or scope is too long.";
133 callbacks->onError( 133 callbacks->onError(
134 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, 134 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity,
135 blink::WebString::fromUTF8(error_message))); 135 blink::WebString::fromUTF8(error_message)));
136 return; 136 return;
137 } 137 }
138 138
139 int request_id = pending_registration_callbacks_.Add(callbacks); 139 int request_id = pending_registration_callbacks_.Add(
140 std::unique_ptr<WebServiceWorkerRegistrationCallbacks>(callbacks));
140 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", 141 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker",
141 "ServiceWorkerDispatcher::RegisterServiceWorker", 142 "ServiceWorkerDispatcher::RegisterServiceWorker",
142 request_id, 143 request_id,
143 "Scope", pattern.spec(), 144 "Scope", pattern.spec(),
144 "Script URL", script_url.spec()); 145 "Script URL", script_url.spec());
145 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( 146 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker(
146 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); 147 CurrentWorkerId(), request_id, provider_id, pattern, script_url));
147 } 148 }
148 149
149 void ServiceWorkerDispatcher::UpdateServiceWorker( 150 void ServiceWorkerDispatcher::UpdateServiceWorker(
150 int provider_id, 151 int provider_id,
151 int64_t registration_id, 152 int64_t registration_id,
152 WebServiceWorkerUpdateCallbacks* callbacks) { 153 WebServiceWorkerUpdateCallbacks* callbacks) {
danakj 2016/11/18 00:15:33 etc..
153 DCHECK(callbacks); 154 DCHECK(callbacks);
154 int request_id = pending_update_callbacks_.Add(callbacks); 155 int request_id = pending_update_callbacks_.Add(
156 std::unique_ptr<WebServiceWorkerUpdateCallbacks>(callbacks));
155 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker( 157 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UpdateServiceWorker(
156 CurrentWorkerId(), request_id, provider_id, registration_id)); 158 CurrentWorkerId(), request_id, provider_id, registration_id));
157 } 159 }
158 160
159 void ServiceWorkerDispatcher::UnregisterServiceWorker( 161 void ServiceWorkerDispatcher::UnregisterServiceWorker(
160 int provider_id, 162 int provider_id,
161 int64_t registration_id, 163 int64_t registration_id,
162 WebServiceWorkerUnregistrationCallbacks* callbacks) { 164 WebServiceWorkerUnregistrationCallbacks* callbacks) {
163 DCHECK(callbacks); 165 DCHECK(callbacks);
164 int request_id = pending_unregistration_callbacks_.Add(callbacks); 166 int request_id = pending_unregistration_callbacks_.Add(
167 std::unique_ptr<WebServiceWorkerUnregistrationCallbacks>(callbacks));
165 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", 168 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
166 "ServiceWorkerDispatcher::UnregisterServiceWorker", 169 "ServiceWorkerDispatcher::UnregisterServiceWorker",
167 request_id, "Registration ID", registration_id); 170 request_id, "Registration ID", registration_id);
168 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( 171 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
169 CurrentWorkerId(), request_id, provider_id, registration_id)); 172 CurrentWorkerId(), request_id, provider_id, registration_id));
170 } 173 }
171 174
172 void ServiceWorkerDispatcher::GetRegistration( 175 void ServiceWorkerDispatcher::GetRegistration(
173 int provider_id, 176 int provider_id,
174 const GURL& document_url, 177 const GURL& document_url,
175 WebServiceWorkerGetRegistrationCallbacks* callbacks) { 178 WebServiceWorkerGetRegistrationCallbacks* callbacks) {
176 DCHECK(callbacks); 179 DCHECK(callbacks);
177 180
178 if (document_url.possibly_invalid_spec().size() > url::kMaxURLChars) { 181 if (document_url.possibly_invalid_spec().size() > url::kMaxURLChars) {
179 std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> owned_callbacks( 182 std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks> owned_callbacks(
180 callbacks); 183 callbacks);
181 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix); 184 std::string error_message(kServiceWorkerGetRegistrationErrorPrefix);
182 error_message += "The provided documentURL is too long."; 185 error_message += "The provided documentURL is too long.";
183 callbacks->onError( 186 callbacks->onError(
184 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, 187 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity,
185 blink::WebString::fromUTF8(error_message))); 188 blink::WebString::fromUTF8(error_message)));
186 return; 189 return;
187 } 190 }
188 191
189 int request_id = pending_get_registration_callbacks_.Add(callbacks); 192 int request_id = pending_get_registration_callbacks_.Add(
193 std::unique_ptr<WebServiceWorkerGetRegistrationCallbacks>(callbacks));
190 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", 194 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
191 "ServiceWorkerDispatcher::GetRegistration", 195 "ServiceWorkerDispatcher::GetRegistration",
192 request_id, 196 request_id,
193 "Document URL", document_url.spec()); 197 "Document URL", document_url.spec());
194 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration( 198 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistration(
195 CurrentWorkerId(), request_id, provider_id, document_url)); 199 CurrentWorkerId(), request_id, provider_id, document_url));
196 } 200 }
197 201
198 void ServiceWorkerDispatcher::GetRegistrations( 202 void ServiceWorkerDispatcher::GetRegistrations(
199 int provider_id, 203 int provider_id,
200 WebServiceWorkerGetRegistrationsCallbacks* callbacks) { 204 WebServiceWorkerGetRegistrationsCallbacks* callbacks) {
201 DCHECK(callbacks); 205 DCHECK(callbacks);
202 206
203 int request_id = pending_get_registrations_callbacks_.Add(callbacks); 207 int request_id = pending_get_registrations_callbacks_.Add(
208 std::unique_ptr<WebServiceWorkerGetRegistrationsCallbacks>(callbacks));
209
204 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", 210 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker",
205 "ServiceWorkerDispatcher::GetRegistrations", 211 "ServiceWorkerDispatcher::GetRegistrations",
206 request_id); 212 request_id);
207 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrations( 213 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrations(
208 CurrentWorkerId(), request_id, provider_id)); 214 CurrentWorkerId(), request_id, provider_id));
209 } 215 }
210 216
211 void ServiceWorkerDispatcher::GetRegistrationForReady( 217 void ServiceWorkerDispatcher::GetRegistrationForReady(
212 int provider_id, 218 int provider_id,
213 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) { 219 WebServiceWorkerGetRegistrationForReadyCallbacks* callbacks) {
214 int request_id = get_for_ready_callbacks_.Add(callbacks); 220 int request_id = get_for_ready_callbacks_.Add(
221 std::unique_ptr<WebServiceWorkerGetRegistrationForReadyCallbacks>(
222 callbacks));
215 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker", 223 TRACE_EVENT_ASYNC_BEGIN0("ServiceWorker",
216 "ServiceWorkerDispatcher::GetRegistrationForReady", 224 "ServiceWorkerDispatcher::GetRegistrationForReady",
217 request_id); 225 request_id);
218 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady( 226 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetRegistrationForReady(
219 CurrentWorkerId(), request_id, provider_id)); 227 CurrentWorkerId(), request_id, provider_id));
220 } 228 }
221 229
222 void ServiceWorkerDispatcher::EnableNavigationPreload( 230 void ServiceWorkerDispatcher::EnableNavigationPreload(
223 int provider_id, 231 int provider_id,
224 int64_t registration_id, 232 int64_t registration_id,
225 bool enable, 233 bool enable,
226 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks) { 234 std::unique_ptr<WebEnableNavigationPreloadCallbacks> callbacks) {
danakj 2016/11/18 00:15:33 oh good, some where already done.
227 DCHECK(callbacks); 235 DCHECK(callbacks);
228 int request_id = 236 int request_id =
229 enable_navigation_preload_callbacks_.Add(callbacks.release()); 237 enable_navigation_preload_callbacks_.Add(std::move(callbacks));
230 thread_safe_sender_->Send(new ServiceWorkerHostMsg_EnableNavigationPreload( 238 thread_safe_sender_->Send(new ServiceWorkerHostMsg_EnableNavigationPreload(
231 CurrentWorkerId(), request_id, provider_id, registration_id, enable)); 239 CurrentWorkerId(), request_id, provider_id, registration_id, enable));
232 } 240 }
233 241
234 void ServiceWorkerDispatcher::GetNavigationPreloadState( 242 void ServiceWorkerDispatcher::GetNavigationPreloadState(
235 int provider_id, 243 int provider_id,
236 int64_t registration_id, 244 int64_t registration_id,
237 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) { 245 std::unique_ptr<WebGetNavigationPreloadStateCallbacks> callbacks) {
238 DCHECK(callbacks); 246 DCHECK(callbacks);
239 int request_id = 247 int request_id =
240 get_navigation_preload_state_callbacks_.Add(callbacks.release()); 248 get_navigation_preload_state_callbacks_.Add(std::move(callbacks));
241 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetNavigationPreloadState( 249 thread_safe_sender_->Send(new ServiceWorkerHostMsg_GetNavigationPreloadState(
242 CurrentWorkerId(), request_id, provider_id, registration_id)); 250 CurrentWorkerId(), request_id, provider_id, registration_id));
243 } 251 }
244 252
245 void ServiceWorkerDispatcher::SetNavigationPreloadHeader( 253 void ServiceWorkerDispatcher::SetNavigationPreloadHeader(
246 int provider_id, 254 int provider_id,
247 int64_t registration_id, 255 int64_t registration_id,
248 const std::string& value, 256 const std::string& value,
249 std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks) { 257 std::unique_ptr<WebSetNavigationPreloadHeaderCallbacks> callbacks) {
250 DCHECK(callbacks); 258 DCHECK(callbacks);
251 int request_id = 259 int request_id =
252 set_navigation_preload_header_callbacks_.Add(callbacks.release()); 260 set_navigation_preload_header_callbacks_.Add(std::move(callbacks));
253 thread_safe_sender_->Send(new ServiceWorkerHostMsg_SetNavigationPreloadHeader( 261 thread_safe_sender_->Send(new ServiceWorkerHostMsg_SetNavigationPreloadHeader(
254 CurrentWorkerId(), request_id, provider_id, registration_id, value)); 262 CurrentWorkerId(), request_id, provider_id, registration_id, value));
255 } 263 }
256 264
257 void ServiceWorkerDispatcher::AddProviderContext( 265 void ServiceWorkerDispatcher::AddProviderContext(
258 ServiceWorkerProviderContext* provider_context) { 266 ServiceWorkerProviderContext* provider_context) {
259 DCHECK(provider_context); 267 DCHECK(provider_context);
260 int provider_id = provider_context->provider_id(); 268 int provider_id = provider_context->provider_id();
261 DCHECK(!base::ContainsKey(provider_contexts_, provider_id)); 269 DCHECK(!base::ContainsKey(provider_contexts_, provider_id));
262 provider_contexts_[provider_id] = provider_context; 270 provider_contexts_[provider_id] = provider_context;
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
904 return ServiceWorkerRegistrationHandleReference::Adopt( 912 return ServiceWorkerRegistrationHandleReference::Adopt(
905 info, thread_safe_sender_.get()); 913 info, thread_safe_sender_.get());
906 } 914 }
907 915
908 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt( 916 std::unique_ptr<ServiceWorkerHandleReference> ServiceWorkerDispatcher::Adopt(
909 const ServiceWorkerObjectInfo& info) { 917 const ServiceWorkerObjectInfo& info) {
910 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); 918 return ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get());
911 } 919 }
912 920
913 } // namespace content 921 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698