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

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: Add locking and documentation Created 4 years, 8 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
34 void FrameTreeNodeBlameContext::ClearArguments() {
35 process_id_ = -1;
benjhayden 2016/04/22 20:34:15 lock?
Xiaocheng 2016/04/25 00:56:28 You're right, this part should also be protected b
36 routing_id_ = -1;
37 url_ = GURL();
38 }
39
40 void FrameTreeNodeBlameContext::UpdateArguments() {
41 RenderFrameHostImpl* current_frame_host = owner_->current_frame_host();
42 if (!current_frame_host) {
43 ClearArguments();
44 return;
45 }
46
47 base::AutoLock lock(lock_);
48
49 // On Windows, |rph->GetHandle()| does not duplicate ownership of the
50 // process handle and the render host still retains it. Therefore, we
51 // cannot create a base::Process object, which provides a proper way to get
52 // a process id, from the handle. For a stopgap, we use this deprecated
53 // function that does not require the ownership (http://crbug.com/417532).
54 process_id_ = base::GetProcId(current_frame_host->GetProcess()->GetHandle());
55
56 routing_id_ = current_frame_host->GetRoutingID();
57 DCHECK_NE(routing_id_, MSG_ROUTING_NONE);
58
59 url_ = current_frame_host->last_committed_url();
60 }
61
62 void FrameTreeNodeBlameContext::AsValueInto(
63 base::trace_event::TracedValue* value) {
64 base::AutoLock lock(lock_);
65
66 BlameContext::AsValueInto(value);
67 if (process_id_ >= 0) {
68 value->BeginDictionary("RenderFrame");
69 value->SetInteger("pid_ref", process_id_);
70 value->SetString("id_ref", base::StringPrintf("0x%x", routing_id_));
71 value->SetString("scope", "RenderFrame");
72 value->EndDictionary();
73 }
74 if (url_.is_valid())
75 value->SetString("url", url_.spec());
76 }
77
78 } // content
OLDNEW
« no previous file with comments | « content/browser/frame_host/frame_tree_node_blame_context.h ('k') | content/browser/frame_host/traced_frame_tree_node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698