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

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

Issue 1390053002: Trace FrameTreeNode Snapshots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: non-copied FrameTree Created 5 years, 2 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 2015 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.h"
6
7 #include "base/command_line.h"
8 #include "base/json/json_writer.h"
9 #include "content/browser/frame_host/frame_tree.h"
10 #include "content/public/common/content_switches.h"
11
12 namespace content {
13
14 namespace {
15
16 base::DictionaryValue* GetFrameTreeNodeAsValue(FrameTreeNode* node) {
17 base::DictionaryValue* value = new base::DictionaryValue();
18 value->SetString("url", node->current_url().spec());
19 value->SetInteger("ftid", node->frame_tree_node_id());
nasko 2015/10/26 15:59:23 "ftnid" or even "ftn_id" or "ftnId", depending on
20
21 RenderFrameHostManager* render_manager = node->render_manager();
22 RenderFrameHostImpl* current_frame_host =
23 render_manager->current_frame_host();
24 if (current_frame_host) {
25 value->SetInteger("cpid", current_frame_host->GetProcess()->GetID());
nasko 2015/10/26 15:59:23 Why not "procId" and "routeId"? I find those a lot
26 value->SetInteger("crid", current_frame_host->GetRoutingID());
27 }
28
29 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
nasko 2015/10/26 15:59:23 I do not think the pending and speculative RFHs ne
clamy 2015/10/26 17:54:03 I think it depends on what this code is supposed t
30 switches::kEnableBrowserSideNavigation)) {
31 RenderFrameHostImpl* speculative_frame_host =
32 render_manager->speculative_frame_host();
33 if (speculative_frame_host) {
34 value->SetInteger("spid", speculative_frame_host->GetProcess()->GetID());
35 value->SetInteger("srid", speculative_frame_host->GetRoutingID());
36 }
37 } else {
38 RenderFrameHostImpl* pending_frame_host =
39 render_manager->pending_frame_host();
40 if (pending_frame_host) {
41 value->SetInteger("ppid", pending_frame_host->GetProcess()->GetID());
42 value->SetInteger("prid", pending_frame_host->GetRoutingID());
43 }
44 }
45
46 if (node->child_count() != 0) {
47 scoped_ptr<base::ListValue> subframes(new base::ListValue());
48 for (size_t i = 0; i < node->child_count(); ++i) {
49 subframes->Append(GetFrameTreeNodeAsValue(node->child_at(i)));
50 }
51 value->Set("subframes", subframes.Pass());
52 }
53 return value;
54 }
55
56 } // namespace
57
58 scoped_refptr<TracedFrameTree> TracedFrameTree::Create(const FrameTree& tree) {
59 return scoped_refptr<TracedFrameTree>(new TracedFrameTree(tree));
60 }
61
62 TracedFrameTree::TracedFrameTree(const FrameTree& tree)
63 : tree_(tree) {
64 }
65
66 TracedFrameTree::~TracedFrameTree() {
67 }
68
69 void TracedFrameTree::AppendAsTraceFormat(std::string* out) const {
70 scoped_ptr<base::DictionaryValue> value(
71 GetFrameTreeNodeAsValue(tree_.root()));
72 std::string tmp;
73 base::JSONWriter::Write(*value, &tmp);
74 *out += tmp;
75 }
76
77 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698