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

Unified Diff: third_party/WebKit/Source/core/timing/Performance.cpp

Issue 2343553005: enable / disable Long Task instrumentation based on presence of LongTask observer (Closed)
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/timing/Performance.cpp
diff --git a/third_party/WebKit/Source/core/timing/Performance.cpp b/third_party/WebKit/Source/core/timing/Performance.cpp
index 8b236f6a17d02988229c54ca22ea9e3099acbee9..82ba53ff931730f14e98fce4a060d09eaf4944dc 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -31,8 +31,11 @@
#include "core/timing/Performance.h"
+#include "core/InstrumentingAgents.h"
#include "core/dom/Document.h"
#include "core/frame/LocalFrame.h"
+#include "core/inspector/InspectedFrames.h"
+#include "core/inspector/InspectorWebPerfAgent.h"
#include "core/loader/DocumentLoader.h"
#include "core/timing/PerformanceTiming.h"
@@ -92,10 +95,32 @@ PerformanceTiming* Performance::timing() const
return m_timing.get();
}
+void Performance::enableLongTaskInstrumentation() const
+{
+ if (hasObserverFor(PerformanceEntry::LongTask)
caseq 2016/09/15 23:29:40 nit: we tend to prefer early bail-outs, i.e. "if (
panicker 2016/09/16 17:07:58 Ok. Done.
+ && !m_longTaskInspectorAgent) {
+ m_longTaskInspectorAgent = new InspectorWebPerfAgent(
+ InspectedFrames::create(frame()));
+ frame()->instrumentingAgents()->addInspectorWebPerfAgent(
+ m_longTaskInspectorAgent);
+ }
+}
+
+void Performance::disableLongTaskInstrumentation() const
+{
+ if (!hasObserverFor(PerformanceEntry::LongTask)
+ && m_longTaskInspectorAgent) {
+ frame()->instrumentingAgents()->removeInspectorWebPerfAgent(
+ m_longTaskInspectorAgent);
+ m_longTaskInspectorAgent = nullptr;
+ }
+}
+
DEFINE_TRACE(Performance)
{
visitor->trace(m_navigation);
visitor->trace(m_timing);
+ visitor->trace(m_longTaskInspectorAgent);
DOMWindowProperty::trace(visitor);
PerformanceBase::trace(visitor);
}

Powered by Google App Engine
This is Rietveld 408576698