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

Unified Diff: third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp

Issue 2296923004: Track frame context URL using first script heuristic (Closed)
Patch Set: rollforward with fix for unittest issue 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/inspector/InspectorWebPerfAgent.cpp
diff --git a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp
index ad4732b0535a11de6d56e0d585d9b953eb97cfea..3e085f1dad921f58b49bdf0dda7b619061c1993c 100644
--- a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp
@@ -4,22 +4,39 @@
#include "core/inspector/InspectorWebPerfAgent.h"
+#include "core/dom/Document.h"
+#include "core/dom/ExecutionContext.h"
#include "core/frame/LocalFrame.h"
+#include "core/frame/Location.h"
#include "core/inspector/InspectedFrames.h"
+#include "public/platform/Platform.h"
namespace blink {
InspectorWebPerfAgent::InspectorWebPerfAgent(InspectedFrames* inspectedFrames)
: m_inspectedFrames(inspectedFrames)
{
+ Platform::current()->currentThread()->addTaskTimeObserver(this);
+ Platform::current()->currentThread()->addTaskObserver(this);
}
InspectorWebPerfAgent::~InspectorWebPerfAgent()
{
+ Platform::current()->currentThread()->removeTaskTimeObserver(this);
+ Platform::current()->currentThread()->removeTaskObserver(this);
}
void InspectorWebPerfAgent::willExecuteScript(ExecutionContext* context)
{
+ // Heuristic for minimal frame context attribution: note the Location URL
+ // for each script execution. When a long task is encountered,
+ // if there is only one Location URL involved, then report it.
+ // Otherwise don't report Location URL.
+ // NOTE: This heuristic is imperfect and will be improved in V2 API.
+ // In V2, timing of script execution along with style & layout updates will be
+ // accounted for detailed and more accurate attribution.
+ if (context->isDocument())
+ m_frameContextLocations.add(toDocument(context)->location());
}
void InspectorWebPerfAgent::didExecuteScript()
@@ -28,6 +45,9 @@ void InspectorWebPerfAgent::didExecuteScript()
void InspectorWebPerfAgent::willProcessTask()
{
+ // Reset m_frameContextLocations. We don't clear this in didProcessTask
+ // as it is needed in ReportTaskTime which occurs after didProcessTask.
+ m_frameContextLocations.clear();
}
void InspectorWebPerfAgent::didProcessTask()
@@ -41,6 +61,7 @@ void InspectorWebPerfAgent::ReportTaskTime(double startTime, double endTime)
DEFINE_TRACE(InspectorWebPerfAgent)
{
visitor->trace(m_inspectedFrames);
+ visitor->trace(m_frameContextLocations);
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698