Chromium Code Reviews| Index: content/browser/frame_host/traced_frame_tree_node.cc |
| diff --git a/content/browser/frame_host/traced_frame_tree_node.cc b/content/browser/frame_host/traced_frame_tree_node.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c8396b16c93f6b0a58943952f5cfe7aab737a74d |
| --- /dev/null |
| +++ b/content/browser/frame_host/traced_frame_tree_node.cc |
| @@ -0,0 +1,56 @@ |
| +// 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/traced_frame_tree_node.h" |
| + |
| +#include "base/command_line.h" |
| +#include "base/json/json_writer.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "content/browser/frame_host/frame_tree.h" |
| +#include "content/public/common/content_switches.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +TracedFrameTreeNode::TracedFrameTreeNode(const FrameTreeNode& node) |
| + : parent_node_id_(-1), |
| + url_(node.current_url().spec()), |
| + process_id_(-1), |
| + routing_id_(-1) { |
| + FrameTreeNode* parent = node.parent(); |
| + if (parent) |
| + parent_node_id_ = parent->frame_tree_node_id(); |
| + |
| + RenderFrameHostImpl* current_frame_host = node.current_frame_host(); |
| + process_id_ = base::GetProcId(current_frame_host->GetProcess()->GetHandle()); |
|
nasko
2016/03/03 19:03:51
Why are you using GetProcId? It is documented as d
benjhayden
2016/03/03 20:35:43
Done.
|
| + routing_id_ = current_frame_host->GetRoutingID(); |
| + DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
| +} |
| + |
| +TracedFrameTreeNode::~TracedFrameTreeNode() { |
| +} |
| + |
| +void TracedFrameTreeNode::AppendAsTraceFormat(std::string* out) const { |
| + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| + |
| + if (parent_node_id_ >= 0) { |
| + scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue()); |
| + ref->SetString("id_ref", base::StringPrintf("0x%x", parent_node_id_)); |
| + ref->SetString("scope", "FrameTreeNode"); |
| + value->Set("parent", std::move(ref)); |
| + } |
| + |
| + scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue()); |
| + ref->SetInteger("pid_ref", process_id_); |
| + ref->SetString("id_ref", base::StringPrintf("0x%x", routing_id_)); |
| + ref->SetString("scope", "RenderFrame"); |
| + value->Set("RenderFrame", std::move(ref)); |
| + |
| + value->SetString("url", url_); |
| + std::string tmp; |
| + base::JSONWriter::Write(*value, &tmp); |
| + *out += tmp; |
| +} |
| + |
| +} // content |