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

Side by Side Diff: content/browser/frame_host/frame_tree_node_blame_context.cc

Issue 1901023003: Introduce browser side FrameTreeNodeBlameContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove thread safety handling (and its doc) Created 4 years, 7 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 2016 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/frame_tree_node_blame_context.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "base/trace_event/trace_event_argument.h"
9 #include "content/browser/frame_host/frame_tree.h"
10 #include "url/gurl.h"
11
12 namespace content {
13
14 const char kFrameTreeNodeBlameContextCategory[] = "navigation";
15 const char kFrameTreeNodeBlameContextName[] = "FrameTreeNode";
16 const char kFrameTreeNodeBlameContextType[] = "Frame";
17 const char kFrameTreeNodeBlameContextScope[] = "FrameTreeNode";
18
19 FrameTreeNodeBlameContext::FrameTreeNodeBlameContext(FrameTreeNode* node)
20 : base::trace_event::BlameContext(kFrameTreeNodeBlameContextCategory,
21 kFrameTreeNodeBlameContextName,
22 kFrameTreeNodeBlameContextType,
23 kFrameTreeNodeBlameContextScope,
24 node->frame_tree_node_id(),
25 node->parent()
26 ? node->parent()->blame_context()
27 : nullptr),
28 owner_(node) {
29 UpdateArguments();
30 }
31
32 FrameTreeNodeBlameContext::~FrameTreeNodeBlameContext() {
33 UnregisterFromTraceLog();
34 }
35
36 void FrameTreeNodeBlameContext::UpdateArguments() {
37 RenderFrameHostImpl* current_frame_host = owner_->current_frame_host();
38 if (!current_frame_host) {
39 process_id_ = -1;
40 routing_id_ = -1;
41 url_ = GURL();
42 return;
43 }
44
45 // On Windows, |rph->GetHandle()| does not duplicate ownership of the
46 // process handle and the render host still retains it. Therefore, we
47 // cannot create a base::Process object, which provides a proper way to get
48 // a process id, from the handle. For a stopgap, we use this deprecated
49 // function that does not require the ownership (http://crbug.com/417532).
50 process_id_ = base::GetProcId(current_frame_host->GetProcess()->GetHandle());
51
52 routing_id_ = current_frame_host->GetRoutingID();
53 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
54
55 url_ = current_frame_host->last_committed_url();
56 }
57
58 void FrameTreeNodeBlameContext::AsValueInto(
59 base::trace_event::TracedValue* value) {
60 BlameContext::AsValueInto(value);
61 if (process_id_ >= 0) {
62 value->BeginDictionary("RenderFrame");
63 value->SetInteger("pid_ref", process_id_);
64 value->SetString("id_ref", base::StringPrintf("0x%x", routing_id_));
65 value->SetString("scope", "RenderFrame");
66 value->EndDictionary();
67 }
68 if (url_.is_valid())
69 value->SetString("url", url_.spec());
70 }
71
72 } // content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698