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

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

Issue 2449673002: Refactor InspectorWebPerfAgent: update lifecycle management to be per Local Frame root; replace hea… (Closed)
Patch Set: Created 4 years, 2 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 abfaffecadc78123316515dd844a43b4598daa68..f420f6e8fcae5a0d1a9539edb6de6c8947c79fce 100644
--- a/third_party/WebKit/Source/core/timing/Performance.cpp
+++ b/third_party/WebKit/Source/core/timing/Performance.cpp
@@ -35,7 +35,6 @@
#include "bindings/core/v8/V8ObjectBuilder.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/origin_trials/OriginTrials.h"
@@ -59,9 +58,17 @@ static double toTimeOrigin(LocalFrame* frame) {
}
Performance::Performance(LocalFrame* frame)
- : PerformanceBase(toTimeOrigin(frame)), DOMWindowProperty(frame) {}
-
-Performance::~Performance() {}
+ : PerformanceBase(toTimeOrigin(frame)),
+ DOMWindowProperty(frame),
+ m_observingLongTasks(false) {}
+
+Performance::~Performance() {
+ LocalFrame* localRoot = frame()->localFrameRoot();
+ if (m_observingLongTasks && localRoot && localRoot->inspectorWebPerfAgent()) {
caseq 2016/10/26 21:19:41 We're supposed to always have the agent for a loca
panicker 2016/10/27 23:06:53 Yeah, currently. Though your other suggestion was
panicker 2016/10/28 00:09:24 Done.
+ m_observingLongTasks = false;
+ localRoot->disableInspectorWebPerfAgent();
+ }
+}
ExecutionContext* Performance::getExecutionContext() const {
if (!frame())
@@ -88,16 +95,21 @@ PerformanceTiming* Performance::timing() const {
}
void Performance::updateLongTaskInstrumentation() {
- if (hasObserverFor(PerformanceEntry::LongTask) && !m_longTaskInspectorAgent) {
- if (!frame() || !frame()->document() ||
- !OriginTrials::longTaskObserverEnabled(frame()->document()))
- return;
- m_longTaskInspectorAgent = new InspectorWebPerfAgent(frame());
- m_longTaskInspectorAgent->enable();
- } else if (!hasObserverFor(PerformanceEntry::LongTask) &&
- m_longTaskInspectorAgent) {
- m_longTaskInspectorAgent->disable();
- m_longTaskInspectorAgent = nullptr;
+ DCHECK(frame());
+ if (!frame()->document() ||
+ !OriginTrials::longTaskObserverEnabled(frame()->document()))
+ return;
+ LocalFrame* localRoot = frame()->localFrameRoot();
+ DCHECK(localRoot);
+ DCHECK(localRoot->inspectorWebPerfAgent());
+
+ if (!m_observingLongTasks && hasObserverFor(PerformanceEntry::LongTask)) {
+ m_observingLongTasks = true;
+ localRoot->enableInspectorWebPerfAgent();
+ } else if (m_observingLongTasks &&
+ !hasObserverFor(PerformanceEntry::LongTask)) {
+ m_observingLongTasks = false;
+ localRoot->disableInspectorWebPerfAgent();
}
}
@@ -108,10 +120,13 @@ ScriptValue Performance::toJSONForBinding(ScriptState* scriptState) const {
return result.scriptValue();
}
+bool Performance::observeringLongTasks() {
+ return m_observingLongTasks;
+}
+
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