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

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: comments 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/json/json_writer.h"
8 #include "content/browser/frame_host/frame_tree.h"
9
10 namespace content {
11
12 namespace {
13
14 base::DictionaryValue* GetFrameTreeNodeAsValue(const FrameTreeNode& node) {
15 base::DictionaryValue* value = new base::DictionaryValue();
16 value->SetString("url", node.current_url().spec());
17 value->SetInteger("ftid", node.frame_tree_node_id());
nasko 2015/10/13 23:01:56 nit: "ftnid", since this is a node, not the full t
benjhayden 2015/10/22 17:24:21 Done.
18 RenderFrameHostManager* render_manager = node.render_manager();
19 RenderFrameHostImpl* frame_host = (
clamy 2015/10/13 11:48:17 The problem is that two of them can be non-null at
nasko 2015/10/13 23:01:56 I would suggest checking for the command line flag
benjhayden 2015/10/22 17:24:21 Done.
20 render_manager->speculative_frame_host() ||
21 render_manager->pending_frame_host() ||
22 render_manager->current_frame_host());
23 if (frame_host) {
24 value->SetInteger("pid", frame_host->GetProcess()->GetID());
25 value->SetInteger("rid", frame_host->GetRoutingID());
26 }
27
28 if (node.child_count() != 0) {
29 scoped_ptr<base::ListValue> subframes(new base::ListValue());
30 for (size_t i = 0; i < node.child_count(); ++i) {
31 subframes->Append(GetFrameTreeNodeAsValue(*node.child_at(i)));
32 }
33 value->Set("subframes", subframes.Pass());
34 }
35 return value;
36 }
37
38 } // namespace
39
40 scoped_refptr<TracedFrameTree> TracedFrameTree::Create(const FrameTree& tree) {
41 return scoped_refptr<TracedFrameTree>(new TracedFrameTree(tree));
42 }
43
44 TracedFrameTree::TracedFrameTree(const FrameTree& tree)
45 : value_(GetFrameTreeNodeAsValue(*tree.root())) {
nasko 2015/10/13 23:01:56 I would avoid doing a lot of work in the construct
benjhayden 2015/10/22 17:24:21 I assume "a lot of work" refers to the Value-ifica
nasko 2015/10/23 15:52:04 I meant actually everything. Sorry if I wasn't cle
benjhayden 2015/10/23 20:31:33 I made TracedFrameTree store only the reference to
46 }
47
48 TracedFrameTree::~TracedFrameTree() {
49 }
50
51 void TracedFrameTree::AppendAsTraceFormat(std::string* out) const {
52 std::string tmp;
53 base::JSONWriter::Write(*value_, &tmp);
54 *out += tmp;
55 }
56
57 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698