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

Side by Side Diff: content/browser/frame_host/traced_frame_tree_node.cc

Issue 1390053002: Trace FrameTreeNode Snapshots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix segfaults Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "content/browser/frame_host/traced_frame_tree_node.h"
6
7 #include "base/command_line.h"
8 #include "base/json/json_writer.h"
9 #include "base/strings/stringprintf.h"
10 #include "content/browser/frame_host/frame_tree.h"
11 #include "content/public/common/content_switches.h"
12 #include "url/gurl.h"
13
14 namespace content {
15
16 TracedFrameTreeNode::TracedFrameTreeNode(const FrameTreeNode& node)
17 : parent_node_id_(-1),
18 process_id_(-1),
19 routing_id_(-1) {
20 FrameTreeNode* parent = node.parent();
21 if (parent)
22 parent_node_id_ = parent->frame_tree_node_id();
23
24 RenderFrameHostImpl* current_frame_host = node.current_frame_host();
25 if (current_frame_host) {
nasko 2016/03/03 21:41:32 if (!current_frame_host) return;
26 if (current_frame_host->last_committed_url().is_valid())
27 url_ = current_frame_host->last_committed_url().spec();
28
29 base::Process process(current_frame_host->GetProcess()->GetHandle());
30 if (process.IsValid()) {
31 process_id_ = process.Pid();
32 routing_id_ = current_frame_host->GetRoutingID();
33 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
34 }
35 }
36 }
37
38 TracedFrameTreeNode::~TracedFrameTreeNode() {
39 }
40
41 void TracedFrameTreeNode::AppendAsTraceFormat(std::string* out) const {
42 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
43
44 if (parent_node_id_ >= 0) {
45 scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue());
46 ref->SetString("id_ref", base::StringPrintf("0x%x", parent_node_id_));
47 ref->SetString("scope", "FrameTreeNode");
48 value->Set("parent", std::move(ref));
49 }
50
51 if (process_id_ >= 0) {
52 scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue());
53 ref->SetInteger("pid_ref", process_id_);
54 ref->SetString("id_ref", base::StringPrintf("0x%x", routing_id_));
55 ref->SetString("scope", "RenderFrame");
56 value->Set("RenderFrame", std::move(ref));
57 }
58
59 if (!url_.empty())
60 value->SetString("url", url_);
61
62 std::string tmp;
63 base::JSONWriter::Write(*value, &tmp);
64 *out += tmp;
65 }
66
67 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698