| 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
|
|
|