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

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

Issue 2238883005: POC for InspectorInstrumentation adding InspectorWebPerfAgent Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add task observer to WebPerfAgent Created 4 years, 4 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 static const size_t defaultResourceTimingBufferSize = 150; 51 static const size_t defaultResourceTimingBufferSize = 150;
52 static const size_t defaultFrameTimingBufferSize = 150; 52 static const size_t defaultFrameTimingBufferSize = 150;
53 53
54 PerformanceBase::PerformanceBase(double timeOrigin) 54 PerformanceBase::PerformanceBase(double timeOrigin)
55 : m_frameTimingBufferSize(defaultFrameTimingBufferSize) 55 : m_frameTimingBufferSize(defaultFrameTimingBufferSize)
56 , m_resourceTimingBufferSize(defaultResourceTimingBufferSize) 56 , m_resourceTimingBufferSize(defaultResourceTimingBufferSize)
57 , m_timeOrigin(timeOrigin) 57 , m_timeOrigin(timeOrigin)
58 , m_userTiming(nullptr) 58 , m_userTiming(nullptr)
59 , m_observerFilterOptions(PerformanceEntry::Invalid) 59 , m_observerFilterOptions(PerformanceEntry::Invalid)
60 , m_deliverObservationsTimer(this, &PerformanceBase::deliverObservationsTime rFired) 60 , m_deliverObservationsTimer(this, &PerformanceBase::deliverObservationsTime rFired)
61 , m_inspectorInstrumentationEnabled(false)
61 { 62 {
62 } 63 }
63 64
64 PerformanceBase::~PerformanceBase() 65 PerformanceBase::~PerformanceBase()
65 { 66 {
66 } 67 }
67 68
68 const AtomicString& PerformanceBase::interfaceName() const 69 const AtomicString& PerformanceBase::interfaceName() const
69 { 70 {
70 return EventTargetNames::Performance; 71 return EventTargetNames::Performance;
71 } 72 }
72 73
73 PerformanceTiming* PerformanceBase::timing() const 74 PerformanceTiming* PerformanceBase::timing() const
74 { 75 {
75 return nullptr; 76 return nullptr;
76 } 77 }
77 78
79 void PerformanceBase::enableInspectorInstrumentation() const
80 {
81 }
82
78 PerformanceEntryVector PerformanceBase::getEntries() const 83 PerformanceEntryVector PerformanceBase::getEntries() const
79 { 84 {
80 PerformanceEntryVector entries; 85 PerformanceEntryVector entries;
81 86
82 entries.appendVector(m_resourceTimingBuffer); 87 entries.appendVector(m_resourceTimingBuffer);
83 entries.appendVector(m_frameTimingBuffer); 88 entries.appendVector(m_frameTimingBuffer);
84 89
85 if (m_userTiming) { 90 if (m_userTiming) {
86 entries.appendVector(m_userTiming->getMarks()); 91 entries.appendVector(m_userTiming->getMarks());
87 entries.appendVector(m_userTiming->getMeasures()); 92 entries.appendVector(m_userTiming->getMeasures());
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 { 354 {
350 if (!m_userTiming) 355 if (!m_userTiming)
351 m_userTiming = UserTiming::create(*this); 356 m_userTiming = UserTiming::create(*this);
352 m_userTiming->clearMeasures(measureName); 357 m_userTiming->clearMeasures(measureName);
353 } 358 }
354 359
355 void PerformanceBase::registerPerformanceObserver(PerformanceObserver& observer) 360 void PerformanceBase::registerPerformanceObserver(PerformanceObserver& observer)
356 { 361 {
357 m_observerFilterOptions |= observer.filterOptions(); 362 m_observerFilterOptions |= observer.filterOptions();
358 m_observers.add(&observer); 363 m_observers.add(&observer);
364
365 // If this is the first long task observer then enable tracking of LongTaskT iming.
366 if (!m_inspectorInstrumentationEnabled
367 && hasObserverFor(PerformanceEntry::Mark)) { // PerformanceEntry::LongTa sk
368 fprintf(stderr, "\n^^^On observe(): enableInspectorInstrumentation");
369 enableInspectorInstrumentation();
370 m_inspectorInstrumentationEnabled = true;
371 } else {
372 fprintf(stderr, "\n^^^On observe(): NOT enableInspectorInstrumentation") ;
373 }
359 } 374 }
360 375
361 void PerformanceBase::unregisterPerformanceObserver(PerformanceObserver& oldObse rver) 376 void PerformanceBase::unregisterPerformanceObserver(PerformanceObserver& oldObse rver)
362 { 377 {
363 ASSERT(isMainThread()); 378 ASSERT(isMainThread());
364 // Deliver any pending observations on this observer before unregistering. 379 // Deliver any pending observations on this observer before unregistering.
365 if (m_activeObservers.contains(&oldObserver) && !oldObserver.shouldBeSuspend ed()) { 380 if (m_activeObservers.contains(&oldObserver) && !oldObserver.shouldBeSuspend ed()) {
366 oldObserver.deliver(); 381 oldObserver.deliver();
367 m_activeObservers.remove(&oldObserver); 382 m_activeObservers.remove(&oldObserver);
368 } 383 }
369 m_observers.remove(&oldObserver); 384 m_observers.remove(&oldObserver);
370 updatePerformanceObserverFilterOptions(); 385 updatePerformanceObserverFilterOptions();
386
387 if (m_inspectorInstrumentationEnabled
388 && !hasObserverFor(PerformanceEntry::Mark)) { // PerformanceEntry::Long Task
389 //disableInspectorInstrumentation();
390 }
371 } 391 }
372 392
373 void PerformanceBase::updatePerformanceObserverFilterOptions() 393 void PerformanceBase::updatePerformanceObserverFilterOptions()
374 { 394 {
375 m_observerFilterOptions = PerformanceEntry::Invalid; 395 m_observerFilterOptions = PerformanceEntry::Invalid;
376 for (const auto& observer : m_observers) { 396 for (const auto& observer : m_observers) {
377 m_observerFilterOptions |= observer->filterOptions(); 397 m_observerFilterOptions |= observer->filterOptions();
378 } 398 }
379 } 399 }
380 400
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 visitor->trace(m_frameTimingBuffer); 475 visitor->trace(m_frameTimingBuffer);
456 visitor->trace(m_resourceTimingBuffer); 476 visitor->trace(m_resourceTimingBuffer);
457 visitor->trace(m_userTiming); 477 visitor->trace(m_userTiming);
458 visitor->trace(m_observers); 478 visitor->trace(m_observers);
459 visitor->trace(m_activeObservers); 479 visitor->trace(m_activeObservers);
460 visitor->trace(m_suspendedObservers); 480 visitor->trace(m_suspendedObservers);
461 EventTargetWithInlineData::trace(visitor); 481 EventTargetWithInlineData::trace(visitor);
462 } 482 }
463 483
464 } // namespace blink 484 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698