| Index: content/browser/frame_host/frame_tree_node_blame_context.cc
|
| diff --git a/content/browser/frame_host/frame_tree_node_blame_context.cc b/content/browser/frame_host/frame_tree_node_blame_context.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c1fd0f0982e346d56e26c4b1cccd6123e6b4f905
|
| --- /dev/null
|
| +++ b/content/browser/frame_host/frame_tree_node_blame_context.cc
|
| @@ -0,0 +1,72 @@
|
| +// 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 "content/browser/frame_host/frame_tree_node_blame_context.h"
|
| +
|
| +#include "base/strings/stringprintf.h"
|
| +#include "base/trace_event/trace_event_argument.h"
|
| +#include "content/browser/frame_host/frame_tree.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace content {
|
| +
|
| +const char kFrameTreeNodeBlameContextCategory[] = "navigation";
|
| +const char kFrameTreeNodeBlameContextName[] = "FrameTreeNode";
|
| +const char kFrameTreeNodeBlameContextType[] = "Frame";
|
| +const char kFrameTreeNodeBlameContextScope[] = "FrameTreeNode";
|
| +
|
| +FrameTreeNodeBlameContext::FrameTreeNodeBlameContext(FrameTreeNode* node)
|
| + : base::trace_event::BlameContext(kFrameTreeNodeBlameContextCategory,
|
| + kFrameTreeNodeBlameContextName,
|
| + kFrameTreeNodeBlameContextType,
|
| + kFrameTreeNodeBlameContextScope,
|
| + node->frame_tree_node_id(),
|
| + node->parent()
|
| + ? node->parent()->blame_context()
|
| + : nullptr),
|
| + owner_(node) {
|
| + UpdateArguments();
|
| +}
|
| +
|
| +FrameTreeNodeBlameContext::~FrameTreeNodeBlameContext() {
|
| + UnregisterFromTraceLog();
|
| +}
|
| +
|
| +void FrameTreeNodeBlameContext::UpdateArguments() {
|
| + RenderFrameHostImpl* current_frame_host = owner_->current_frame_host();
|
| + if (!current_frame_host) {
|
| + process_id_ = -1;
|
| + routing_id_ = -1;
|
| + url_ = GURL();
|
| + return;
|
| + }
|
| +
|
| + // On Windows, |rph->GetHandle()| does not duplicate ownership of the
|
| + // process handle and the render host still retains it. Therefore, we
|
| + // cannot create a base::Process object, which provides a proper way to get
|
| + // a process id, from the handle. For a stopgap, we use this deprecated
|
| + // function that does not require the ownership (http://crbug.com/417532).
|
| + process_id_ = base::GetProcId(current_frame_host->GetProcess()->GetHandle());
|
| +
|
| + routing_id_ = current_frame_host->GetRoutingID();
|
| + DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
|
| +
|
| + url_ = current_frame_host->last_committed_url();
|
| +}
|
| +
|
| +void FrameTreeNodeBlameContext::AsValueInto(
|
| + base::trace_event::TracedValue* value) {
|
| + BlameContext::AsValueInto(value);
|
| + if (process_id_ >= 0) {
|
| + value->BeginDictionary("RenderFrame");
|
| + value->SetInteger("pid_ref", process_id_);
|
| + value->SetString("id_ref", base::StringPrintf("0x%x", routing_id_));
|
| + value->SetString("scope", "RenderFrame");
|
| + value->EndDictionary();
|
| + }
|
| + if (url_.is_valid())
|
| + value->SetString("url", url_.spec());
|
| +}
|
| +
|
| +} // content
|
|
|