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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/traced_frame_tree.cc
diff --git a/content/browser/frame_host/traced_frame_tree.cc b/content/browser/frame_host/traced_frame_tree.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9ecb46532cfd707871fb4834c9f85381ad07ce9c
--- /dev/null
+++ b/content/browser/frame_host/traced_frame_tree.cc
@@ -0,0 +1,57 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// 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.h"
+
+#include "base/json/json_writer.h"
+#include "content/browser/frame_host/frame_tree.h"
+
+namespace content {
+
+namespace {
+
+base::DictionaryValue* GetFrameTreeNodeAsValue(const FrameTreeNode& node) {
+ base::DictionaryValue* value = new base::DictionaryValue();
+ value->SetString("url", node.current_url().spec());
+ 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.
+ RenderFrameHostManager* render_manager = node.render_manager();
+ 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.
+ render_manager->speculative_frame_host() ||
+ render_manager->pending_frame_host() ||
+ render_manager->current_frame_host());
+ if (frame_host) {
+ value->SetInteger("pid", frame_host->GetProcess()->GetID());
+ value->SetInteger("rid", frame_host->GetRoutingID());
+ }
+
+ if (node.child_count() != 0) {
+ scoped_ptr<base::ListValue> subframes(new base::ListValue());
+ for (size_t i = 0; i < node.child_count(); ++i) {
+ subframes->Append(GetFrameTreeNodeAsValue(*node.child_at(i)));
+ }
+ value->Set("subframes", subframes.Pass());
+ }
+ return value;
+}
+
+} // namespace
+
+scoped_refptr<TracedFrameTree> TracedFrameTree::Create(const FrameTree& tree) {
+ return scoped_refptr<TracedFrameTree>(new TracedFrameTree(tree));
+}
+
+TracedFrameTree::TracedFrameTree(const FrameTree& tree)
+ : 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
+}
+
+TracedFrameTree::~TracedFrameTree() {
+}
+
+void TracedFrameTree::AppendAsTraceFormat(std::string* out) const {
+ std::string tmp;
+ base::JSONWriter::Write(*value_, &tmp);
+ *out += tmp;
+}
+
+} // content

Powered by Google App Engine
This is Rietveld 408576698