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..a27438821fdf6e8c1be0817d1c2696b0adef79ed |
| --- /dev/null |
| +++ b/content/browser/frame_host/traced_frame_tree_node.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
|
nasko
2016/03/02 00:20:20
Same here, 2016.
benjhayden
2016/03/02 18:53:03
Done.
|
| +// 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) |
| + : parentNodeId_(-1), |
| + url_(node.current_url().spec()), |
| + processId_(-1), |
| + routingId_(-1) { |
| + FrameTreeNode* parent = node.parent(); |
| + if (parent) |
| + parentNodeId_ = parent->frame_tree_node_id(); |
| + |
| + RenderFrameHostImpl* current_frame_host = node.current_frame_host(); |
| + if (current_frame_host) { |
|
nasko
2016/03/02 00:20:20
There should always be a current_frame_host.
benjhayden
2016/03/02 18:53:03
Done.
|
| + processId_ = current_frame_host->GetProcess()->GetHandle(); |
| + routingId_ = current_frame_host->GetRoutingID(); |
| + } |
| +} |
| + |
| +TracedFrameTreeNode::~TracedFrameTreeNode() { |
| +} |
| + |
| +void TracedFrameTreeNode::AppendAsTraceFormat(std::string* out) const { |
| + scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue()); |
| + |
| + if (parentNodeId_ >= 0) { |
| + scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue()); |
| + ref->SetString("id_ref", base::StringPrintf("0x%x", parentNodeId_)); |
| + ref->SetString("scope", "FrameTreeNode"); |
| + value->Set("parent", std::move(ref)); |
| + } |
| + |
| + if (routingId_ >= 0) { |
|
nasko
2016/03/02 00:20:20
routing_id != MSG_ROUTING_NONE is more correct com
benjhayden
2016/03/02 18:53:03
Done.
|
| + scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue()); |
| + ref->SetInteger("pid_ref", processId_); |
| + ref->SetString("id_ref", base::StringPrintf("0x%x", routingId_)); |
| + 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 |