Commit d0717890 authored by panicker's avatar panicker Committed by Commit bot

Replace InspectedFrames::root with pointer to directly stored LocalFrame

BUG=635596

Review-Url: https://codereview.chromium.org/2390863002
Cr-Commit-Position: refs/heads/master@{#422916}
parent 93db3c3b
...@@ -32,8 +32,8 @@ bool canAccessOrigin(Frame* frame1, Frame* frame2) { ...@@ -32,8 +32,8 @@ bool canAccessOrigin(Frame* frame1, Frame* frame2) {
} }
} // namespace } // namespace
InspectorWebPerfAgent::InspectorWebPerfAgent(InspectedFrames* inspectedFrames) InspectorWebPerfAgent::InspectorWebPerfAgent(LocalFrame* localFrame)
: m_inspectedFrames(inspectedFrames) {} : m_localFrame(localFrame) {}
InspectorWebPerfAgent::~InspectorWebPerfAgent() { InspectorWebPerfAgent::~InspectorWebPerfAgent() {
DCHECK(!m_enabled); DCHECK(!m_enabled);
...@@ -42,16 +42,14 @@ InspectorWebPerfAgent::~InspectorWebPerfAgent() { ...@@ -42,16 +42,14 @@ InspectorWebPerfAgent::~InspectorWebPerfAgent() {
void InspectorWebPerfAgent::enable() { void InspectorWebPerfAgent::enable() {
Platform::current()->currentThread()->addTaskTimeObserver(this); Platform::current()->currentThread()->addTaskTimeObserver(this);
Platform::current()->currentThread()->addTaskObserver(this); Platform::current()->currentThread()->addTaskObserver(this);
m_inspectedFrames->root()->instrumentingAgents()->addInspectorWebPerfAgent( m_localFrame->instrumentingAgents()->addInspectorWebPerfAgent(this);
this);
m_enabled = true; m_enabled = true;
} }
void InspectorWebPerfAgent::disable() { void InspectorWebPerfAgent::disable() {
Platform::current()->currentThread()->removeTaskTimeObserver(this); Platform::current()->currentThread()->removeTaskTimeObserver(this);
Platform::current()->currentThread()->removeTaskObserver(this); Platform::current()->currentThread()->removeTaskObserver(this);
m_inspectedFrames->root()->instrumentingAgents()->removeInspectorWebPerfAgent( m_localFrame->instrumentingAgents()->removeInspectorWebPerfAgent(this);
this);
m_enabled = false; m_enabled = false;
} }
...@@ -82,14 +80,14 @@ void InspectorWebPerfAgent::ReportTaskTime(scheduler::TaskQueue*, ...@@ -82,14 +80,14 @@ void InspectorWebPerfAgent::ReportTaskTime(scheduler::TaskQueue*,
double endTime) { double endTime) {
if (((endTime - startTime) * 1000) <= kLongTaskThresholdMillis) if (((endTime - startTime) * 1000) <= kLongTaskThresholdMillis)
return; return;
DOMWindow* domWindow = m_inspectedFrames->root()->domWindow(); DOMWindow* domWindow = m_localFrame->domWindow();
if (!domWindow) if (!domWindow)
return; return;
Performance* performance = DOMWindowPerformance::performance(*domWindow); Performance* performance = DOMWindowPerformance::performance(*domWindow);
DCHECK(performance); DCHECK(performance);
performance->addLongTaskTiming( performance->addLongTaskTiming(
startTime, endTime, sanitizedLongTaskName(m_frameContextLocations, startTime, endTime,
m_inspectedFrames->root())); sanitizedLongTaskName(m_frameContextLocations, m_localFrame));
} }
String InspectorWebPerfAgent::sanitizedLongTaskName( String InspectorWebPerfAgent::sanitizedLongTaskName(
...@@ -114,7 +112,7 @@ String InspectorWebPerfAgent::sanitizedLongTaskName( ...@@ -114,7 +112,7 @@ String InspectorWebPerfAgent::sanitizedLongTaskName(
} }
DEFINE_TRACE(InspectorWebPerfAgent) { DEFINE_TRACE(InspectorWebPerfAgent) {
visitor->trace(m_inspectedFrames); visitor->trace(m_localFrame);
visitor->trace(m_frameContextLocations); visitor->trace(m_frameContextLocations);
} }
......
...@@ -27,7 +27,7 @@ class CORE_EXPORT InspectorWebPerfAgent final ...@@ -27,7 +27,7 @@ class CORE_EXPORT InspectorWebPerfAgent final
friend class InspectorWebPerfAgentTest; friend class InspectorWebPerfAgentTest;
public: public:
explicit InspectorWebPerfAgent(InspectedFrames*); explicit InspectorWebPerfAgent(LocalFrame*);
~InspectorWebPerfAgent(); ~InspectorWebPerfAgent();
DECLARE_VIRTUAL_TRACE(); DECLARE_VIRTUAL_TRACE();
...@@ -52,7 +52,7 @@ class CORE_EXPORT InspectorWebPerfAgent final ...@@ -52,7 +52,7 @@ class CORE_EXPORT InspectorWebPerfAgent final
const HeapHashSet<Member<Location>>& frameContextLocations, const HeapHashSet<Member<Location>>& frameContextLocations,
Frame* rootFrame); Frame* rootFrame);
Member<InspectedFrames> m_inspectedFrames; Member<LocalFrame> m_localFrame;
HeapHashSet<Member<Location>> m_frameContextLocations; HeapHashSet<Member<Location>> m_frameContextLocations;
}; };
......
...@@ -45,7 +45,7 @@ class InspectorWebPerfAgentTest : public ::testing::Test { ...@@ -45,7 +45,7 @@ class InspectorWebPerfAgentTest : public ::testing::Test {
void InspectorWebPerfAgentTest::SetUp() { void InspectorWebPerfAgentTest::SetUp() {
m_pageHolder = DummyPageHolder::create(IntSize(800, 600)); m_pageHolder = DummyPageHolder::create(IntSize(800, 600));
m_pageHolder->document().setURL(KURL(KURL(), "https://example.com/foo")); m_pageHolder->document().setURL(KURL(KURL(), "https://example.com/foo"));
m_agent = new InspectorWebPerfAgent(InspectedFrames::create(frame())); m_agent = new InspectorWebPerfAgent(frame());
// Create another dummy page holder and pretend this is the iframe. // Create another dummy page holder and pretend this is the iframe.
m_anotherPageHolder = DummyPageHolder::create(IntSize(400, 300)); m_anotherPageHolder = DummyPageHolder::create(IntSize(400, 300));
......
...@@ -86,8 +86,7 @@ PerformanceTiming* Performance::timing() const { ...@@ -86,8 +86,7 @@ PerformanceTiming* Performance::timing() const {
void Performance::updateLongTaskInstrumentation() { void Performance::updateLongTaskInstrumentation() {
if (hasObserverFor(PerformanceEntry::LongTask) && !m_longTaskInspectorAgent) { if (hasObserverFor(PerformanceEntry::LongTask) && !m_longTaskInspectorAgent) {
m_longTaskInspectorAgent = m_longTaskInspectorAgent = new InspectorWebPerfAgent(frame());
new InspectorWebPerfAgent(InspectedFrames::create(frame()));
m_longTaskInspectorAgent->enable(); m_longTaskInspectorAgent->enable();
} else if (!hasObserverFor(PerformanceEntry::LongTask) && } else if (!hasObserverFor(PerformanceEntry::LongTask) &&
m_longTaskInspectorAgent) { m_longTaskInspectorAgent) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment