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

Side by Side Diff: third_party/WebKit/Source/core/timing/PerformanceBase.cpp

Issue 2858963002: Replace ASSERT with DCHECK in core/ (Closed)
Patch Set: WorkerBackingThread Created 3 years, 7 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Intel Inc. All rights reserved. 3 * Copyright (C) 2012 Intel Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 AddResourceTimingBuffer(*entry); 360 AddResourceTimingBuffer(*entry);
361 return; 361 return;
362 } 362 }
363 363
364 const Vector<ResourceResponse>& redirect_chain = info.RedirectChain(); 364 const Vector<ResourceResponse>& redirect_chain = info.RedirectChain();
365 bool allow_redirect_details = AllowsTimingRedirect( 365 bool allow_redirect_details = AllowsTimingRedirect(
366 redirect_chain, final_response, *security_origin, context); 366 redirect_chain, final_response, *security_origin, context);
367 367
368 if (!allow_redirect_details) { 368 if (!allow_redirect_details) {
369 ResourceLoadTiming* final_timing = final_response.GetResourceLoadTiming(); 369 ResourceLoadTiming* final_timing = final_response.GetResourceLoadTiming();
370 ASSERT(final_timing); 370 DCHECK(final_timing);
371 if (final_timing) 371 if (final_timing)
372 start_time = final_timing->RequestTime(); 372 start_time = final_timing->RequestTime();
373 } 373 }
374 374
375 ResourceLoadTiming* last_redirect_timing = 375 ResourceLoadTiming* last_redirect_timing =
376 redirect_chain.back().GetResourceLoadTiming(); 376 redirect_chain.back().GetResourceLoadTiming();
377 ASSERT(last_redirect_timing); 377 DCHECK(last_redirect_timing);
378 double last_redirect_end_time = last_redirect_timing->ReceiveHeadersEnd(); 378 double last_redirect_end_time = last_redirect_timing->ReceiveHeadersEnd();
379 379
380 PerformanceEntry* entry = PerformanceResourceTiming::Create( 380 PerformanceEntry* entry = PerformanceResourceTiming::Create(
381 info, TimeOrigin(), start_time, last_redirect_end_time, 381 info, TimeOrigin(), start_time, last_redirect_end_time,
382 allow_timing_details, allow_redirect_details); 382 allow_timing_details, allow_redirect_details);
383 NotifyObserversOfEntry(*entry); 383 NotifyObserversOfEntry(*entry);
384 if (!IsResourceTimingBufferFull()) 384 if (!IsResourceTimingBufferFull())
385 AddResourceTimingBuffer(*entry); 385 AddResourceTimingBuffer(*entry);
386 } 386 }
387 387
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 481
482 void PerformanceBase::RegisterPerformanceObserver( 482 void PerformanceBase::RegisterPerformanceObserver(
483 PerformanceObserver& observer) { 483 PerformanceObserver& observer) {
484 observer_filter_options_ |= observer.FilterOptions(); 484 observer_filter_options_ |= observer.FilterOptions();
485 observers_.insert(&observer); 485 observers_.insert(&observer);
486 UpdateLongTaskInstrumentation(); 486 UpdateLongTaskInstrumentation();
487 } 487 }
488 488
489 void PerformanceBase::UnregisterPerformanceObserver( 489 void PerformanceBase::UnregisterPerformanceObserver(
490 PerformanceObserver& old_observer) { 490 PerformanceObserver& old_observer) {
491 ASSERT(IsMainThread()); 491 DCHECK(IsMainThread());
492 // Deliver any pending observations on this observer before unregistering. 492 // Deliver any pending observations on this observer before unregistering.
493 if (active_observers_.Contains(&old_observer) && 493 if (active_observers_.Contains(&old_observer) &&
494 !old_observer.ShouldBeSuspended()) { 494 !old_observer.ShouldBeSuspended()) {
495 old_observer.Deliver(); 495 old_observer.Deliver();
496 active_observers_.erase(&old_observer); 496 active_observers_.erase(&old_observer);
497 } 497 }
498 observers_.erase(&old_observer); 498 observers_.erase(&old_observer);
499 UpdatePerformanceObserverFilterOptions(); 499 UpdatePerformanceObserverFilterOptions();
500 UpdateLongTaskInstrumentation(); 500 UpdateLongTaskInstrumentation();
501 } 501 }
(...skipping 26 matching lines...) Expand all
528 } 528 }
529 529
530 void PerformanceBase::ActivateObserver(PerformanceObserver& observer) { 530 void PerformanceBase::ActivateObserver(PerformanceObserver& observer) {
531 if (active_observers_.IsEmpty()) 531 if (active_observers_.IsEmpty())
532 deliver_observations_timer_.StartOneShot(0, BLINK_FROM_HERE); 532 deliver_observations_timer_.StartOneShot(0, BLINK_FROM_HERE);
533 533
534 active_observers_.insert(&observer); 534 active_observers_.insert(&observer);
535 } 535 }
536 536
537 void PerformanceBase::ResumeSuspendedObservers() { 537 void PerformanceBase::ResumeSuspendedObservers() {
538 ASSERT(IsMainThread()); 538 DCHECK(IsMainThread());
539 if (suspended_observers_.IsEmpty()) 539 if (suspended_observers_.IsEmpty())
540 return; 540 return;
541 541
542 PerformanceObserverVector suspended; 542 PerformanceObserverVector suspended;
543 CopyToVector(suspended_observers_, suspended); 543 CopyToVector(suspended_observers_, suspended);
544 for (size_t i = 0; i < suspended.size(); ++i) { 544 for (size_t i = 0; i < suspended.size(); ++i) {
545 if (!suspended[i]->ShouldBeSuspended()) { 545 if (!suspended[i]->ShouldBeSuspended()) {
546 suspended_observers_.erase(suspended[i]); 546 suspended_observers_.erase(suspended[i]);
547 ActivateObserver(*suspended[i]); 547 ActivateObserver(*suspended[i]);
548 } 548 }
549 } 549 }
550 } 550 }
551 551
552 void PerformanceBase::DeliverObservationsTimerFired(TimerBase*) { 552 void PerformanceBase::DeliverObservationsTimerFired(TimerBase*) {
553 ASSERT(IsMainThread()); 553 DCHECK(IsMainThread());
554 PerformanceObservers observers; 554 PerformanceObservers observers;
555 active_observers_.Swap(observers); 555 active_observers_.Swap(observers);
556 for (const auto& observer : observers) { 556 for (const auto& observer : observers) {
557 if (observer->ShouldBeSuspended()) 557 if (observer->ShouldBeSuspended())
558 suspended_observers_.insert(observer); 558 suspended_observers_.insert(observer);
559 else 559 else
560 observer->Deliver(); 560 observer->Deliver();
561 } 561 }
562 } 562 }
563 563
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 visitor->Trace(navigation_timing_); 599 visitor->Trace(navigation_timing_);
600 visitor->Trace(user_timing_); 600 visitor->Trace(user_timing_);
601 visitor->Trace(server_timing_buffer_); 601 visitor->Trace(server_timing_buffer_);
602 visitor->Trace(observers_); 602 visitor->Trace(observers_);
603 visitor->Trace(active_observers_); 603 visitor->Trace(active_observers_);
604 visitor->Trace(suspended_observers_); 604 visitor->Trace(suspended_observers_);
605 EventTargetWithInlineData::Trace(visitor); 605 EventTargetWithInlineData::Trace(visitor);
606 } 606 }
607 607
608 } // namespace blink 608 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698