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

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

Issue 2343553005: enable / disable Long Task instrumentation based on presence of LongTask observer (Closed)
Patch Set: address review comments Created 4 years, 3 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 { 393 {
394 if (!m_userTiming) 394 if (!m_userTiming)
395 m_userTiming = UserTiming::create(*this); 395 m_userTiming = UserTiming::create(*this);
396 m_userTiming->clearMeasures(measureName); 396 m_userTiming->clearMeasures(measureName);
397 } 397 }
398 398
399 void PerformanceBase::registerPerformanceObserver(PerformanceObserver& observer) 399 void PerformanceBase::registerPerformanceObserver(PerformanceObserver& observer)
400 { 400 {
401 m_observerFilterOptions |= observer.filterOptions(); 401 m_observerFilterOptions |= observer.filterOptions();
402 m_observers.add(&observer); 402 m_observers.add(&observer);
403 updateLongTaskInstrumentation();
403 } 404 }
404 405
405 void PerformanceBase::unregisterPerformanceObserver(PerformanceObserver& oldObse rver) 406 void PerformanceBase::unregisterPerformanceObserver(PerformanceObserver& oldObse rver)
406 { 407 {
407 ASSERT(isMainThread()); 408 ASSERT(isMainThread());
408 // Deliver any pending observations on this observer before unregistering. 409 // Deliver any pending observations on this observer before unregistering.
409 if (m_activeObservers.contains(&oldObserver) && !oldObserver.shouldBeSuspend ed()) { 410 if (m_activeObservers.contains(&oldObserver) && !oldObserver.shouldBeSuspend ed()) {
410 oldObserver.deliver(); 411 oldObserver.deliver();
411 m_activeObservers.remove(&oldObserver); 412 m_activeObservers.remove(&oldObserver);
412 } 413 }
413 m_observers.remove(&oldObserver); 414 m_observers.remove(&oldObserver);
414 updatePerformanceObserverFilterOptions(); 415 updatePerformanceObserverFilterOptions();
416 updateLongTaskInstrumentation();
415 } 417 }
416 418
417 void PerformanceBase::updatePerformanceObserverFilterOptions() 419 void PerformanceBase::updatePerformanceObserverFilterOptions()
418 { 420 {
419 m_observerFilterOptions = PerformanceEntry::Invalid; 421 m_observerFilterOptions = PerformanceEntry::Invalid;
420 for (const auto& observer : m_observers) { 422 for (const auto& observer : m_observers) {
421 m_observerFilterOptions |= observer->filterOptions(); 423 m_observerFilterOptions |= observer->filterOptions();
422 } 424 }
425 updateLongTaskInstrumentation();
423 } 426 }
424 427
425 void PerformanceBase::notifyObserversOfEntry(PerformanceEntry& entry) 428 void PerformanceBase::notifyObserversOfEntry(PerformanceEntry& entry)
426 { 429 {
427 for (auto& observer : m_observers) { 430 for (auto& observer : m_observers) {
428 if (observer->filterOptions() & entry.entryTypeEnum()) 431 if (observer->filterOptions() & entry.entryTypeEnum())
429 observer->enqueuePerformanceEntry(entry); 432 observer->enqueuePerformanceEntry(entry);
430 } 433 }
431 } 434 }
432 435
433 bool PerformanceBase::hasObserverFor(PerformanceEntry::EntryType filterType) 436 bool PerformanceBase::hasObserverFor(PerformanceEntry::EntryType filterType) con st
434 { 437 {
435 return m_observerFilterOptions & filterType; 438 return m_observerFilterOptions & filterType;
436 } 439 }
437 440
438 void PerformanceBase::activateObserver(PerformanceObserver& observer) 441 void PerformanceBase::activateObserver(PerformanceObserver& observer)
439 { 442 {
440 if (m_activeObservers.isEmpty()) 443 if (m_activeObservers.isEmpty())
441 m_deliverObservationsTimer.startOneShot(0, BLINK_FROM_HERE); 444 m_deliverObservationsTimer.startOneShot(0, BLINK_FROM_HERE);
442 445
443 m_activeObservers.add(&observer); 446 m_activeObservers.add(&observer);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 visitor->trace(m_resourceTimingBuffer); 509 visitor->trace(m_resourceTimingBuffer);
507 visitor->trace(m_longTaskTimingBuffer); 510 visitor->trace(m_longTaskTimingBuffer);
508 visitor->trace(m_userTiming); 511 visitor->trace(m_userTiming);
509 visitor->trace(m_observers); 512 visitor->trace(m_observers);
510 visitor->trace(m_activeObservers); 513 visitor->trace(m_activeObservers);
511 visitor->trace(m_suspendedObservers); 514 visitor->trace(m_suspendedObservers);
512 EventTargetWithInlineData::trace(visitor); 515 EventTargetWithInlineData::trace(visitor);
513 } 516 }
514 517
515 } // namespace blink 518 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/timing/PerformanceBase.h ('k') | third_party/WebKit/Source/core/timing/PerformanceObserver.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698