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

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

Issue 2238883005: POC for InspectorInstrumentation adding InspectorWebPerfAgent Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add task observer to WebPerfAgent Created 4 years, 4 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
new file mode 100644
index 0000000000000000000000000000000000000000..75809d82f389c497873c4dfe5ec640bf8e31b7ba
--- /dev/null
+++ b/third_party/WebKit/Source/core/inspector/InspectorWebPerfAgent.cpp
@@ -0,0 +1,78 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/inspector/InspectorWebPerfAgent.h"
+
+#include "core/frame/LocalFrame.h"
+#include "core/frame/Location.h"
+#include "core/inspector/InspectedFrames.h"
+#include "core/timing/DOMWindowPerformance.h"
+#include "public/platform/Platform.h"
+#include "platform/weborigin/SecurityOrigin.h"
+
+namespace blink {
+
+InspectorWebPerfAgent::InspectorWebPerfAgent(InspectedFrames* inspectedFrames)
+ : m_inspectedFrames(inspectedFrames)
+{
+ Platform::current()->currentThread()->addTaskObserver(this);
+}
+
+InspectorWebPerfAgent::~InspectorWebPerfAgent()
+{
+ Platform::current()->currentThread()->removeTaskObserver(this);
+}
+
+DEFINE_TRACE(InspectorWebPerfAgent)
+{
+ visitor->trace(m_inspectedFrames);
+ InspectorAgent::trace(visitor);
+}
+
+void InspectorWebPerfAgent::didCommitLoad(LocalFrame* frame, DocumentLoader* loader)
+{
+ LocalFrame* rootFrame = m_inspectedFrames->root();
+ Location* location = rootFrame->document()->location();
+ fprintf(stderr, "\n\nInspected Frame root: %s: %s!",
+ location->hostname().ascii().data(),
+ location->pathname().ascii().data());
+
+ int i = 0;
+ // InspectedFrames automagically has the child iframe (when local)
+ // so alternatively we could iterate that instead of traversing the tree:
+ // for (LocalFrame* rootFrame : *m_inspectedFrames) {
+ for (Frame* frame = rootFrame; frame; frame = frame->tree().traverseNext()) {
+ if (!frame->isLocalFrame()) {
+ continue;
+ }
+ blink::DOMWindow* domWindow = frame->domWindow();
+ /* Remove me */
+ SecurityOrigin* sorigin = frame->securityContext()->getSecurityOrigin();
+ // Report long tasks to DOMPerformance
+ blink::Performance* performance = DOMWindowPerformance::performance(
+ *domWindow);
+ if (performance) {
+ if (sorigin) {
+ fprintf(stderr, "\n##Invoke performance API [%d] %s : %s!!",
+ ++i, sorigin->host().ascii().data(),
+ sorigin->domain().ascii().data());
+ } else {
+ fprintf(stderr, "\n##Invoke performance API [%d] !", ++i);
+ }
+ }
+ }
+}
+
+void InspectorWebPerfAgent::willProcessTask()
+{
+ fprintf(stderr, "\n[ InspectorWebPerfAgent::willProcessTask ");
+}
+
+void InspectorWebPerfAgent::didProcessTask()
+{
+ fprintf(stderr, "InspectorWebPerfAgent::didProcessTask ]\n");
+}
+
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698