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

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

Issue 603863002: SW: Move TRACE_EVENT_ASYNC_END to avoid early return and fix typo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/browser/service_worker/embedded_worker_instance.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError( 102 scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
103 WebServiceWorkerError::ErrorTypeSecurity, "URL too long")); 103 WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
104 callbacks->onError(error.release()); 104 callbacks->onError(error.release());
105 return; 105 return;
106 } 106 }
107 107
108 int request_id = pending_registration_callbacks_.Add(callbacks); 108 int request_id = pending_registration_callbacks_.Add(callbacks);
109 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker", 109 TRACE_EVENT_ASYNC_BEGIN2("ServiceWorker",
110 "ServiceWorkerDispatcher::RegisterServiceWorker", 110 "ServiceWorkerDispatcher::RegisterServiceWorker",
111 request_id, 111 request_id,
112 "Pettern", pattern.spec(), 112 "Pattern", pattern.spec(),
nhiroki 2014/09/25 05:51:42 "Pattern" is no longer used in the spec, so can yo
shimazu 2014/09/25 07:02:46 Done.
113 "Script URL", script_url.spec()); 113 "Script URL", script_url.spec());
114 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker( 114 thread_safe_sender_->Send(new ServiceWorkerHostMsg_RegisterServiceWorker(
115 CurrentWorkerId(), request_id, provider_id, pattern, script_url)); 115 CurrentWorkerId(), request_id, provider_id, pattern, script_url));
116 } 116 }
117 117
118 void ServiceWorkerDispatcher::UnregisterServiceWorker( 118 void ServiceWorkerDispatcher::UnregisterServiceWorker(
119 int provider_id, 119 int provider_id,
120 const GURL& pattern, 120 const GURL& pattern,
121 WebServiceWorkerUnregistrationCallbacks* callbacks) { 121 WebServiceWorkerUnregistrationCallbacks* callbacks) {
122 DCHECK(callbacks); 122 DCHECK(callbacks);
123 123
124 if (pattern.possibly_invalid_spec().size() > GetMaxURLChars()) { 124 if (pattern.possibly_invalid_spec().size() > GetMaxURLChars()) {
125 scoped_ptr<WebServiceWorkerUnregistrationCallbacks> 125 scoped_ptr<WebServiceWorkerUnregistrationCallbacks>
126 owned_callbacks(callbacks); 126 owned_callbacks(callbacks);
127 scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError( 127 scoped_ptr<WebServiceWorkerError> error(new WebServiceWorkerError(
128 WebServiceWorkerError::ErrorTypeSecurity, "URL too long")); 128 WebServiceWorkerError::ErrorTypeSecurity, "URL too long"));
129 callbacks->onError(error.release()); 129 callbacks->onError(error.release());
130 return; 130 return;
131 } 131 }
132 132
133 int request_id = pending_unregistration_callbacks_.Add(callbacks); 133 int request_id = pending_unregistration_callbacks_.Add(callbacks);
134 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker", 134 TRACE_EVENT_ASYNC_BEGIN1("ServiceWorker",
135 "ServiceWorkerDispatcher::UnregisterServiceWorker", 135 "ServiceWorkerDispatcher::UnregisterServiceWorker",
136 request_id, 136 request_id,
137 "Pettern", pattern.spec()); 137 "Pattern", pattern.spec());
nhiroki 2014/09/25 05:51:42 ditto.
shimazu 2014/09/25 07:02:47 Done.
138 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker( 138 thread_safe_sender_->Send(new ServiceWorkerHostMsg_UnregisterServiceWorker(
139 CurrentWorkerId(), request_id, provider_id, pattern)); 139 CurrentWorkerId(), request_id, provider_id, pattern));
140 } 140 }
141 141
142 void ServiceWorkerDispatcher::GetRegistration( 142 void ServiceWorkerDispatcher::GetRegistration(
143 int provider_id, 143 int provider_id,
144 const GURL& document_url, 144 const GURL& document_url,
145 WebServiceWorkerRegistrationCallbacks* callbacks) { 145 WebServiceWorkerRegistrationCallbacks* callbacks) {
146 DCHECK(callbacks); 146 DCHECK(callbacks);
147 147
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 318
319 void ServiceWorkerDispatcher::OnRegistered( 319 void ServiceWorkerDispatcher::OnRegistered(
320 int thread_id, 320 int thread_id,
321 int request_id, 321 int request_id,
322 const ServiceWorkerRegistrationObjectInfo& info, 322 const ServiceWorkerRegistrationObjectInfo& info,
323 const ServiceWorkerVersionAttributes& attrs) { 323 const ServiceWorkerVersionAttributes& attrs) {
324 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", 324 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
325 "ServiceWorkerDispatcher::RegisterServiceWorker", 325 "ServiceWorkerDispatcher::RegisterServiceWorker",
326 request_id, 326 request_id,
327 "OnRegistered"); 327 "OnRegistered");
328 TRACE_EVENT_ASYNC_END0("ServiceWorker",
329 "ServiceWorkerDispatcher::RegisterServiceWorker",
330 request_id);
328 WebServiceWorkerRegistrationCallbacks* callbacks = 331 WebServiceWorkerRegistrationCallbacks* callbacks =
329 pending_registration_callbacks_.Lookup(request_id); 332 pending_registration_callbacks_.Lookup(request_id);
330 DCHECK(callbacks); 333 DCHECK(callbacks);
331 if (!callbacks) 334 if (!callbacks)
332 return; 335 return;
333 336
334 callbacks->onSuccess(FindOrCreateRegistration(info, attrs)); 337 callbacks->onSuccess(FindOrCreateRegistration(info, attrs));
335 pending_registration_callbacks_.Remove(request_id); 338 pending_registration_callbacks_.Remove(request_id);
336 TRACE_EVENT_ASYNC_END0("ServiceWorker",
337 "ServiceWorkerDispatcher::RegisterServiceWorker",
338 request_id);
339 } 339 }
340 340
341 void ServiceWorkerDispatcher::OnUnregistered(int thread_id, 341 void ServiceWorkerDispatcher::OnUnregistered(int thread_id,
342 int request_id, 342 int request_id,
343 bool is_success) { 343 bool is_success) {
344 WebServiceWorkerUnregistrationCallbacks* callbacks = 344 WebServiceWorkerUnregistrationCallbacks* callbacks =
345 pending_unregistration_callbacks_.Lookup(request_id); 345 pending_unregistration_callbacks_.Lookup(request_id);
346 TRACE_EVENT_ASYNC_STEP_INTO0( 346 TRACE_EVENT_ASYNC_STEP_INTO0(
347 "ServiceWorker", 347 "ServiceWorker",
348 "ServiceWorkerDispatcher::UnregisterServiceWorker", 348 "ServiceWorkerDispatcher::UnregisterServiceWorker",
349 request_id, 349 request_id,
350 "OnUnregistered"); 350 "OnUnregistered");
351 TRACE_EVENT_ASYNC_END0("ServiceWorker",
352 "ServiceWorkerDispatcher::UnregisterServiceWorker",
353 request_id);
nhiroki 2014/09/25 05:51:42 nit: OnUnregistered calls functions as follows:
shimazu 2014/09/25 07:02:47 Done.
351 DCHECK(callbacks); 354 DCHECK(callbacks);
352 if (!callbacks) 355 if (!callbacks)
353 return; 356 return;
354 callbacks->onSuccess(&is_success); 357 callbacks->onSuccess(&is_success);
355 pending_unregistration_callbacks_.Remove(request_id); 358 pending_unregistration_callbacks_.Remove(request_id);
356 TRACE_EVENT_ASYNC_END0("ServiceWorker",
357 "ServiceWorkerDispatcher::UnregisterServiceWorker",
358 request_id);
359 } 359 }
360 360
361 void ServiceWorkerDispatcher::OnDidGetRegistration( 361 void ServiceWorkerDispatcher::OnDidGetRegistration(
362 int thread_id, 362 int thread_id,
363 int request_id, 363 int request_id,
364 const ServiceWorkerRegistrationObjectInfo& info, 364 const ServiceWorkerRegistrationObjectInfo& info,
365 const ServiceWorkerVersionAttributes& attrs) { 365 const ServiceWorkerVersionAttributes& attrs) {
366 WebServiceWorkerRegistrationCallbacks* callbacks = 366 WebServiceWorkerRegistrationCallbacks* callbacks =
367 pending_get_registration_callbacks_.Lookup(request_id); 367 pending_get_registration_callbacks_.Lookup(request_id);
368 TRACE_EVENT_ASYNC_STEP_INTO0( 368 TRACE_EVENT_ASYNC_STEP_INTO0(
369 "ServiceWorker", 369 "ServiceWorker",
370 "ServiceWorkerDispatcher::GetRegistration", 370 "ServiceWorkerDispatcher::GetRegistration",
371 request_id, 371 request_id,
372 "OnDidGetRegistration"); 372 "OnDidGetRegistration");
373 TRACE_EVENT_ASYNC_END0("ServiceWorker",
374 "ServiceWorkerDispatcher::GetRegistration",
375 request_id);
373 DCHECK(callbacks); 376 DCHECK(callbacks);
374 if (!callbacks) 377 if (!callbacks)
375 return; 378 return;
376 379
377 WebServiceWorkerRegistrationImpl* registration = NULL; 380 WebServiceWorkerRegistrationImpl* registration = NULL;
378 if (info.handle_id != kInvalidServiceWorkerHandleId) 381 if (info.handle_id != kInvalidServiceWorkerHandleId)
379 registration = FindOrCreateRegistration(info, attrs); 382 registration = FindOrCreateRegistration(info, attrs);
380 383
381 callbacks->onSuccess(registration); 384 callbacks->onSuccess(registration);
382 pending_get_registration_callbacks_.Remove(request_id); 385 pending_get_registration_callbacks_.Remove(request_id);
383 TRACE_EVENT_ASYNC_END0("ServiceWorker",
384 "ServiceWorkerDispatcher::GetRegistration",
385 request_id);
386 } 386 }
387 387
388 void ServiceWorkerDispatcher::OnRegistrationError( 388 void ServiceWorkerDispatcher::OnRegistrationError(
389 int thread_id, 389 int thread_id,
390 int request_id, 390 int request_id,
391 WebServiceWorkerError::ErrorType error_type, 391 WebServiceWorkerError::ErrorType error_type,
392 const base::string16& message) { 392 const base::string16& message) {
393 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker", 393 TRACE_EVENT_ASYNC_STEP_INTO0("ServiceWorker",
394 "ServiceWorkerDispatcher::RegisterServiceWorker", 394 "ServiceWorkerDispatcher::RegisterServiceWorker",
395 request_id, 395 request_id,
(...skipping 16 matching lines...) Expand all
412 void ServiceWorkerDispatcher::OnUnregistrationError( 412 void ServiceWorkerDispatcher::OnUnregistrationError(
413 int thread_id, 413 int thread_id,
414 int request_id, 414 int request_id,
415 WebServiceWorkerError::ErrorType error_type, 415 WebServiceWorkerError::ErrorType error_type,
416 const base::string16& message) { 416 const base::string16& message) {
417 TRACE_EVENT_ASYNC_STEP_INTO0( 417 TRACE_EVENT_ASYNC_STEP_INTO0(
418 "ServiceWorker", 418 "ServiceWorker",
419 "ServiceWorkerDispatcher::UnregisterServiceWorker", 419 "ServiceWorkerDispatcher::UnregisterServiceWorker",
420 request_id, 420 request_id,
421 "OnUnregistrationError"); 421 "OnUnregistrationError");
422 TRACE_EVENT_ASYNC_END0("ServiceWorker",
423 "ServiceWorkerDispatcher::UnregisterServiceWorker",
424 request_id);
422 WebServiceWorkerUnregistrationCallbacks* callbacks = 425 WebServiceWorkerUnregistrationCallbacks* callbacks =
423 pending_unregistration_callbacks_.Lookup(request_id); 426 pending_unregistration_callbacks_.Lookup(request_id);
424 DCHECK(callbacks); 427 DCHECK(callbacks);
425 if (!callbacks) 428 if (!callbacks)
426 return; 429 return;
427 430
428 scoped_ptr<WebServiceWorkerError> error( 431 scoped_ptr<WebServiceWorkerError> error(
429 new WebServiceWorkerError(error_type, message)); 432 new WebServiceWorkerError(error_type, message));
430 callbacks->onError(error.release()); 433 callbacks->onError(error.release());
431 pending_unregistration_callbacks_.Remove(request_id); 434 pending_unregistration_callbacks_.Remove(request_id);
432 TRACE_EVENT_ASYNC_END0("ServiceWorker",
433 "ServiceWorkerDispatcher::UnregisterServiceWorker",
434 request_id);
435 } 435 }
436 436
437 void ServiceWorkerDispatcher::OnGetRegistrationError( 437 void ServiceWorkerDispatcher::OnGetRegistrationError(
438 int thread_id, 438 int thread_id,
439 int request_id, 439 int request_id,
440 WebServiceWorkerError::ErrorType error_type, 440 WebServiceWorkerError::ErrorType error_type,
441 const base::string16& message) { 441 const base::string16& message) {
442 TRACE_EVENT_ASYNC_STEP_INTO0( 442 TRACE_EVENT_ASYNC_STEP_INTO0(
443 "ServiceWorker", 443 "ServiceWorker",
444 "ServiceWorkerDispatcher::GetRegistration", 444 "ServiceWorkerDispatcher::GetRegistration",
445 request_id, 445 request_id,
446 "OnGetRegistrationError"); 446 "OnGetRegistrationError");
447 WebServiceWorkerGetRegistrationCallbacks* callbacks = 447 WebServiceWorkerGetRegistrationCallbacks* callbacks =
448 pending_get_registration_callbacks_.Lookup(request_id); 448 pending_get_registration_callbacks_.Lookup(request_id);
449 TRACE_EVENT_ASYNC_END0("ServiceWorker",
450 "ServiceWorkerDispatcher::GetRegistration",
451 request_id);
449 DCHECK(callbacks); 452 DCHECK(callbacks);
450 if (!callbacks) 453 if (!callbacks)
451 return; 454 return;
452 455
453 scoped_ptr<WebServiceWorkerError> error( 456 scoped_ptr<WebServiceWorkerError> error(
454 new WebServiceWorkerError(error_type, message)); 457 new WebServiceWorkerError(error_type, message));
455 callbacks->onError(error.release()); 458 callbacks->onError(error.release());
456 pending_get_registration_callbacks_.Remove(request_id); 459 pending_get_registration_callbacks_.Remove(request_id);
457 TRACE_EVENT_ASYNC_END0("ServiceWorker",
458 "ServiceWorkerDispatcher::GetRegistration",
459 request_id);
460 } 460 }
461 461
462 void ServiceWorkerDispatcher::OnServiceWorkerStateChanged( 462 void ServiceWorkerDispatcher::OnServiceWorkerStateChanged(
463 int thread_id, 463 int thread_id,
464 int handle_id, 464 int handle_id,
465 blink::WebServiceWorkerState state) { 465 blink::WebServiceWorkerState state) {
466 TRACE_EVENT2("ServiceWorker", 466 TRACE_EVENT2("ServiceWorker",
467 "ServiceWorkerDispatcher::OnServiceWorkerStateChanged", 467 "ServiceWorkerDispatcher::OnServiceWorkerStateChanged",
468 "Thread ID", thread_id, 468 "Thread ID", thread_id,
469 "State", state); 469 "State", state);
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 attrs.installing, thread_safe_sender_.get()); 730 attrs.installing, thread_safe_sender_.get());
731 ServiceWorkerHandleReference::Adopt( 731 ServiceWorkerHandleReference::Adopt(
732 attrs.waiting, thread_safe_sender_.get()); 732 attrs.waiting, thread_safe_sender_.get());
733 ServiceWorkerHandleReference::Adopt( 733 ServiceWorkerHandleReference::Adopt(
734 attrs.active, thread_safe_sender_.get()); 734 attrs.active, thread_safe_sender_.get());
735 } 735 }
736 return registration; 736 return registration;
737 } 737 }
738 738
739 } // namespace content 739 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/embedded_worker_instance.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698