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

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: TraceSnapshot only in FrameTree Created 5 years, 1 month 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 scoped_ptr<base::DictionaryValue> GetFrameTreeNodeAsValue(FrameTreeNode* node) {
17 scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
18 value->SetString("url", node->current_url().spec());
19 value->SetInteger("nodeId", node->frame_tree_node_id());
20
21 RenderFrameHostImpl* current_frame_host =
22 node->render_manager()->current_frame_host();
23 if (current_frame_host) {
clamy 2015/10/29 17:17:16 We should always have a current RFH, so I think we
24 value->SetInteger("processId", current_frame_host->GetProcess()->GetID());
25 value->SetInteger("routingId", current_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("children", subframes.Pass());
34 }
35 return value.Pass();
36 }
37
38 } // namespace
39
40 scoped_refptr<TracedFrameTree> TracedFrameTree::Create(const FrameTree& tree) {
41 return scoped_refptr<TracedFrameTree>(new TracedFrameTree(
42 GetFrameTreeNodeAsValue(tree.root())));
43 }
44
45 TracedFrameTree::TracedFrameTree(scoped_ptr<base::DictionaryValue> value)
46 : value_(value.Pass()) {
47 }
48
49 TracedFrameTree::~TracedFrameTree() {
50 }
51
52 void TracedFrameTree::AppendAsTraceFormat(std::string* out) const {
53 std::string tmp;
54 base::JSONWriter::Write(*value_, &tmp);
55 *out += tmp;
56 }
57
58 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698