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

Side by Side Diff: content/browser/profiler_controller_impl.cc

Issue 10077001: [UMA] Use proper C++ objects to serialize tracked_objects across process boundaries. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix yet another IWYU in the chromeos/ code... Created 8 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 | Annotate | Revision Log
« no previous file with comments | « content/browser/profiler_controller_impl.h ('k') | content/browser/profiler_message_filter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/profiler_controller_impl.h" 5 #include "content/browser/profiler_controller_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/tracked_objects.h"
9 #include "content/common/child_process_messages.h" 9 #include "content/common/child_process_messages.h"
10 #include "content/public/browser/browser_child_process_host_iterator.h" 10 #include "content/public/browser/browser_child_process_host_iterator.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/child_process_data.h" 12 #include "content/public/browser/child_process_data.h"
13 #include "content/public/browser/profiler_subscriber.h" 13 #include "content/public/browser/profiler_subscriber.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/common/process_type.h"
16 15
17 using content::BrowserChildProcessHostIterator; 16 using content::BrowserChildProcessHostIterator;
18 using content::BrowserThread; 17 using content::BrowserThread;
19 18
20 namespace content { 19 namespace content {
21 20
22 content::ProfilerController* content::ProfilerController::GetInstance() { 21 content::ProfilerController* content::ProfilerController::GetInstance() {
23 return ProfilerControllerImpl::GetInstance(); 22 return ProfilerControllerImpl::GetInstance();
24 } 23 }
25 24
(...skipping 10 matching lines...) Expand all
36 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number, 35 void ProfilerControllerImpl::OnPendingProcesses(int sequence_number,
37 int pending_processes, 36 int pending_processes,
38 bool end) { 37 bool end) {
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
40 if (subscriber_) 39 if (subscriber_)
41 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end); 40 subscriber_->OnPendingProcesses(sequence_number, pending_processes, end);
42 } 41 }
43 42
44 void ProfilerControllerImpl::OnProfilerDataCollected( 43 void ProfilerControllerImpl::OnProfilerDataCollected(
45 int sequence_number, 44 int sequence_number,
46 base::DictionaryValue* profiler_data) { 45 const tracked_objects::ProcessDataSnapshot& profiler_data,
46 content::ProcessType process_type) {
47 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { 47 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
48 BrowserThread::PostTask( 48 BrowserThread::PostTask(
49 BrowserThread::UI, FROM_HERE, 49 BrowserThread::UI, FROM_HERE,
50 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected, 50 base::Bind(&ProfilerControllerImpl::OnProfilerDataCollected,
51 base::Unretained(this), 51 base::Unretained(this),
52 sequence_number, 52 sequence_number,
53 profiler_data)); 53 profiler_data,
54 process_type));
54 return; 55 return;
55 } 56 }
56 57
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 if (subscriber_) 59 if (subscriber_) {
59 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data); 60 subscriber_->OnProfilerDataCollected(sequence_number, profiler_data,
61 process_type);
62 }
60 } 63 }
61 64
62 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) { 65 void ProfilerControllerImpl::Register(ProfilerSubscriber* subscriber) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 66 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 DCHECK(!subscriber_); 67 DCHECK(!subscriber_);
65 subscriber_ = subscriber; 68 subscriber_ = subscriber;
66 } 69 }
67 70
68 void ProfilerControllerImpl::Unregister(ProfilerSubscriber* subscriber) { 71 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) {
69 if (subscriber == subscriber_) 72 DCHECK_EQ(subscriber_, subscriber);
70 subscriber_ = NULL; 73 subscriber_ = NULL;
71 } 74 }
72 75
73 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( 76 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses(
74 int sequence_number) { 77 int sequence_number) {
75 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
76 79
77 int pending_processes = 0; 80 int pending_processes = 0;
78 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { 81 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
79 const std::string process_type =
80 content::GetProcessTypeNameInEnglish(iter.GetData().type);
81 ++pending_processes; 82 ++pending_processes;
82 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData( 83 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number)))
83 sequence_number, process_type))) {
84 --pending_processes; 84 --pending_processes;
85 }
86 } 85 }
87 86
88 BrowserThread::PostTask( 87 BrowserThread::PostTask(
89 BrowserThread::UI, 88 BrowserThread::UI,
90 FROM_HERE, 89 FROM_HERE,
91 base::Bind( 90 base::Bind(
92 &ProfilerControllerImpl::OnPendingProcesses, 91 &ProfilerControllerImpl::OnPendingProcesses,
93 base::Unretained(this), 92 base::Unretained(this),
94 sequence_number, 93 sequence_number,
95 pending_processes, 94 pending_processes,
96 true)); 95 true));
97 } 96 }
98 97
99 void ProfilerControllerImpl::GetProfilerData(int sequence_number) { 98 void ProfilerControllerImpl::GetProfilerData(int sequence_number) {
100 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
101 100
102 int pending_processes = 0; 101 int pending_processes = 0;
103 const std::string render_process_type =
104 content::GetProcessTypeNameInEnglish(content::PROCESS_TYPE_RENDERER);
105
106 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 102 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
107 !it.IsAtEnd(); it.Advance()) { 103 !it.IsAtEnd(); it.Advance()) {
108 ++pending_processes; 104 ++pending_processes;
109 if (!it.GetCurrentValue()->Send(new ChildProcessMsg_GetChildProfilerData( 105 if (!it.GetCurrentValue()->Send(
110 sequence_number, render_process_type))) { 106 new ChildProcessMsg_GetChildProfilerData(sequence_number))) {
111 --pending_processes; 107 --pending_processes;
112 } 108 }
113 } 109 }
114 OnPendingProcesses(sequence_number, pending_processes, false); 110 OnPendingProcesses(sequence_number, pending_processes, false);
115 111
116 BrowserThread::PostTask( 112 BrowserThread::PostTask(
117 BrowserThread::IO, 113 BrowserThread::IO,
118 FROM_HERE, 114 FROM_HERE,
119 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, 115 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses,
120 base::Unretained(this), 116 base::Unretained(this),
121 sequence_number)); 117 sequence_number));
122 } 118 }
123 119
124 void ProfilerControllerImpl::SetProfilerStatusInChildProcesses(
125 tracked_objects::ThreadData::Status status) {
126 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
127
128 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter)
129 iter.Send(new ChildProcessMsg_SetProfilerStatus(status));
130 }
131
132 void ProfilerControllerImpl::SetProfilerStatus(
133 tracked_objects::ThreadData::Status status) {
134 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
135
136 BrowserThread::PostTask(
137 BrowserThread::IO,
138 FROM_HERE,
139 base::Bind(&ProfilerControllerImpl::SetProfilerStatusInChildProcesses,
140 base::Unretained(this),
141 status));
142
143 for (content::RenderProcessHost::iterator it(
144 content::RenderProcessHost::AllHostsIterator());
145 !it.IsAtEnd(); it.Advance()) {
146 it.GetCurrentValue()->Send(new ChildProcessMsg_SetProfilerStatus(status));
147 }
148 }
149 } // namespace content 120 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/profiler_controller_impl.h ('k') | content/browser/profiler_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698