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

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

Issue 2724363002: Migrate WTF::LinkedHashSet/ListHashSet::add() to ::insert() (Closed)
Patch Set: Created 3 years, 9 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 void PerformanceBase::clearMeasures(const String& measureName) { 489 void PerformanceBase::clearMeasures(const String& measureName) {
490 if (!m_userTiming) 490 if (!m_userTiming)
491 m_userTiming = UserTiming::create(*this); 491 m_userTiming = UserTiming::create(*this);
492 m_userTiming->clearMeasures(measureName); 492 m_userTiming->clearMeasures(measureName);
493 } 493 }
494 494
495 void PerformanceBase::registerPerformanceObserver( 495 void PerformanceBase::registerPerformanceObserver(
496 PerformanceObserver& observer) { 496 PerformanceObserver& observer) {
497 m_observerFilterOptions |= observer.filterOptions(); 497 m_observerFilterOptions |= observer.filterOptions();
498 m_observers.add(&observer); 498 m_observers.insert(&observer);
499 updateLongTaskInstrumentation(); 499 updateLongTaskInstrumentation();
500 } 500 }
501 501
502 void PerformanceBase::unregisterPerformanceObserver( 502 void PerformanceBase::unregisterPerformanceObserver(
503 PerformanceObserver& oldObserver) { 503 PerformanceObserver& oldObserver) {
504 ASSERT(isMainThread()); 504 ASSERT(isMainThread());
505 // Deliver any pending observations on this observer before unregistering. 505 // Deliver any pending observations on this observer before unregistering.
506 if (m_activeObservers.contains(&oldObserver) && 506 if (m_activeObservers.contains(&oldObserver) &&
507 !oldObserver.shouldBeSuspended()) { 507 !oldObserver.shouldBeSuspended()) {
508 oldObserver.deliver(); 508 oldObserver.deliver();
(...skipping 21 matching lines...) Expand all
530 530
531 bool PerformanceBase::hasObserverFor( 531 bool PerformanceBase::hasObserverFor(
532 PerformanceEntry::EntryType filterType) const { 532 PerformanceEntry::EntryType filterType) const {
533 return m_observerFilterOptions & filterType; 533 return m_observerFilterOptions & filterType;
534 } 534 }
535 535
536 void PerformanceBase::activateObserver(PerformanceObserver& observer) { 536 void PerformanceBase::activateObserver(PerformanceObserver& observer) {
537 if (m_activeObservers.isEmpty()) 537 if (m_activeObservers.isEmpty())
538 m_deliverObservationsTimer.startOneShot(0, BLINK_FROM_HERE); 538 m_deliverObservationsTimer.startOneShot(0, BLINK_FROM_HERE);
539 539
540 m_activeObservers.add(&observer); 540 m_activeObservers.insert(&observer);
541 } 541 }
542 542
543 void PerformanceBase::resumeSuspendedObservers() { 543 void PerformanceBase::resumeSuspendedObservers() {
544 ASSERT(isMainThread()); 544 ASSERT(isMainThread());
545 if (m_suspendedObservers.isEmpty()) 545 if (m_suspendedObservers.isEmpty())
546 return; 546 return;
547 547
548 PerformanceObserverVector suspended; 548 PerformanceObserverVector suspended;
549 copyToVector(m_suspendedObservers, suspended); 549 copyToVector(m_suspendedObservers, suspended);
550 for (size_t i = 0; i < suspended.size(); ++i) { 550 for (size_t i = 0; i < suspended.size(); ++i) {
551 if (!suspended[i]->shouldBeSuspended()) { 551 if (!suspended[i]->shouldBeSuspended()) {
552 m_suspendedObservers.remove(suspended[i]); 552 m_suspendedObservers.remove(suspended[i]);
553 activateObserver(*suspended[i]); 553 activateObserver(*suspended[i]);
554 } 554 }
555 } 555 }
556 } 556 }
557 557
558 void PerformanceBase::deliverObservationsTimerFired(TimerBase*) { 558 void PerformanceBase::deliverObservationsTimerFired(TimerBase*) {
559 ASSERT(isMainThread()); 559 ASSERT(isMainThread());
560 PerformanceObservers observers; 560 PerformanceObservers observers;
561 m_activeObservers.swap(observers); 561 m_activeObservers.swap(observers);
562 for (const auto& observer : observers) { 562 for (const auto& observer : observers) {
563 if (observer->shouldBeSuspended()) 563 if (observer->shouldBeSuspended())
564 m_suspendedObservers.add(observer); 564 m_suspendedObservers.insert(observer);
565 else 565 else
566 observer->deliver(); 566 observer->deliver();
567 } 567 }
568 } 568 }
569 569
570 // static 570 // static
571 double PerformanceBase::clampTimeResolution(double timeSeconds) { 571 double PerformanceBase::clampTimeResolution(double timeSeconds) {
572 const double resolutionSeconds = 0.000005; 572 const double resolutionSeconds = 0.000005;
573 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds; 573 return floor(timeSeconds / resolutionSeconds) * resolutionSeconds;
574 } 574 }
(...skipping 26 matching lines...) Expand all
601 visitor->trace(m_resourceTimingBuffer); 601 visitor->trace(m_resourceTimingBuffer);
602 visitor->trace(m_navigationTiming); 602 visitor->trace(m_navigationTiming);
603 visitor->trace(m_userTiming); 603 visitor->trace(m_userTiming);
604 visitor->trace(m_observers); 604 visitor->trace(m_observers);
605 visitor->trace(m_activeObservers); 605 visitor->trace(m_activeObservers);
606 visitor->trace(m_suspendedObservers); 606 visitor->trace(m_suspendedObservers);
607 EventTargetWithInlineData::trace(visitor); 607 EventTargetWithInlineData::trace(visitor);
608 } 608 }
609 609
610 } // namespace blink 610 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698