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

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: 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..b0c102041dea26094488e8803d6fc8116defab45
--- /dev/null
+++ b/content/browser/frame_host/traced_frame_tree.cc
@@ -0,0 +1,53 @@
+// 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) {
clamy 2015/10/12 09:31:06 s/getFrameTreeNodeAsValue/GetFrameTreeNodeAsValue
benjhayden 2015/10/13 00:22:21 Done.
+ base::DictionaryValue* value = new base::DictionaryValue();
+ value->SetString("url", node.current_url().spec());
+ value->SetInteger("ftid", node.frame_tree_node_id());
+ RenderFrameHostImpl* frame_host = node.current_frame_host();
clamy 2015/10/12 09:31:06 Should we also care about the pending_render_frame
benjhayden 2015/10/13 00:22:21 I'm not sure. I admit I've only skimmed go/plznavi
+ 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;
+}
+
+}
clamy 2015/10/12 09:31:06 Add "// namespace" after the {.
benjhayden 2015/10/13 00:22:21 Done.
+
+scoped_refptr<TracedFrameTree> TracedFrameTree::Create(const FrameTree& tree) {
+ return scoped_refptr<TracedFrameTree>(new TracedFrameTree(tree));
+}
+
+TracedFrameTree::TracedFrameTree(const FrameTree& tree)
+ : value_(getFrameTreeNodeAsValue(*tree.root())) {
+}
+
+TracedFrameTree::~TracedFrameTree() {
+}
+
+void TracedFrameTree::AppendAsTraceFormat(std::string* out) const {
+ std::string tmp;
+ base::JSONWriter::Write(*value_, &tmp);
+ *out += tmp;
+}
+
+}
clamy 2015/10/12 09:31:06 Add "// content" after the {.
benjhayden 2015/10/13 00:22:21 Done.

Powered by Google App Engine
This is Rietveld 408576698