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..ca99b2cb9c76934327c9efc4c8e86bee3e3a56b1 100644 |
--- a/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp |
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp |
@@ -4,22 +4,40 @@ |
#include "core/inspector/InspectorWebPerfAgent.h" |
+#include "core/InstrumentingAgents.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: for the first script seen |
+ // within a toplevel message loop task - record the URL for the ExecutionContext. |
+ if (m_firstScriptSeen) |
+ return; |
+ m_firstScriptSeen = true; |
+ Location* location = context->isDocument() ? toDocument(context)->location() : nullptr; |
+ if (location) { |
+ m_frameContextURL = std::string(location->protocol().ascii().data()) + "//" |
+ + location->hostname().ascii().data() |
+ + location->pathname().ascii().data(); |
+ } |
} |
void InspectorWebPerfAgent::didExecuteScript() |
@@ -28,6 +46,10 @@ void InspectorWebPerfAgent::didExecuteScript() |
void InspectorWebPerfAgent::willProcessTask() |
{ |
+ // Reset m_frameContextURL. We don't reset this in didProcessTask as |
+ // it is needed in ReportTaskTime which occurs after didProcessTask. |
+ m_firstScriptSeen = false; |
+ m_frameContextURL = ""; |
} |
void InspectorWebPerfAgent::didProcessTask() |