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

Unified Diff: content/browser/frame_host/traced_frame_tree_node.cc

Issue 1775953003: Reland Trace FrameTreeNode Snapshots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 9 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
« no previous file with comments | « content/browser/frame_host/traced_frame_tree_node.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/traced_frame_tree_node.cc
diff --git a/content/browser/frame_host/traced_frame_tree_node.cc b/content/browser/frame_host/traced_frame_tree_node.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0141b38e854fc22a921c9ef4a283fba5113931f5
--- /dev/null
+++ b/content/browser/frame_host/traced_frame_tree_node.cc
@@ -0,0 +1,69 @@
+// Copyright 2016 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_node.h"
+
+#include "base/command_line.h"
+#include "base/json/json_writer.h"
+#include "base/strings/stringprintf.h"
+#include "content/browser/frame_host/frame_tree.h"
+#include "content/public/common/content_switches.h"
+#include "url/gurl.h"
+
+namespace content {
+
+TracedFrameTreeNode::TracedFrameTreeNode(const FrameTreeNode& node)
+ : parent_node_id_(-1),
+ process_id_(-1),
+ routing_id_(-1) {
+ FrameTreeNode* parent = node.parent();
+ if (parent)
+ parent_node_id_ = parent->frame_tree_node_id();
+
+ RenderFrameHostImpl* current_frame_host = node.current_frame_host();
+
+ if (current_frame_host->last_committed_url().is_valid())
+ url_ = current_frame_host->last_committed_url().spec();
+
+ // On Windows, |rph->GetHandle()| does not duplicate ownership
+ // of the process handle and the render host still retains it. Therefore, we
+ // cannot create a base::Process object, which provides a proper way to get a
+ // process id, from the handle. For a stopgap, we use this deprecated
+ // function that does not require the ownership (http://crbug.com/417532).
+ process_id_ = base::GetProcId(current_frame_host->GetProcess()->GetHandle());
+
+ routing_id_ = current_frame_host->GetRoutingID();
+ DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
+}
+
+TracedFrameTreeNode::~TracedFrameTreeNode() {
+}
+
+void TracedFrameTreeNode::AppendAsTraceFormat(std::string* out) const {
+ scoped_ptr<base::DictionaryValue> value(new base::DictionaryValue());
+
+ if (parent_node_id_ >= 0) {
+ scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue());
+ ref->SetString("id_ref", base::StringPrintf("0x%x", parent_node_id_));
+ ref->SetString("scope", "FrameTreeNode");
+ value->Set("parent", std::move(ref));
+ }
+
+ if (process_id_ >= 0) {
+ scoped_ptr<base::DictionaryValue> ref(new base::DictionaryValue());
+ ref->SetInteger("pid_ref", process_id_);
+ ref->SetString("id_ref", base::StringPrintf("0x%x", routing_id_));
+ ref->SetString("scope", "RenderFrame");
+ value->Set("RenderFrame", std::move(ref));
+ }
+
+ if (!url_.empty())
+ value->SetString("url", url_);
+
+ std::string tmp;
+ base::JSONWriter::Write(*value, &tmp);
+ *out += tmp;
+}
+
+} // content
« no previous file with comments | « content/browser/frame_host/traced_frame_tree_node.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698