OLD | NEW |
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/command_line.h" | 8 #include "base/process/process_handle.h" |
9 #include "base/tracked_objects.h" | 9 #include "base/tracked_objects.h" |
10 #include "content/common/child_process_messages.h" | 10 #include "content/common/child_process_messages.h" |
11 #include "content/public/browser/browser_child_process_host_iterator.h" | 11 #include "content/public/browser/browser_child_process_host_iterator.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/child_process_data.h" | 13 #include "content/public/browser/child_process_data.h" |
14 #include "content/public/browser/profiler_subscriber.h" | 14 #include "content/public/browser/profiler_subscriber.h" |
15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
16 #include "content/public/common/content_switches.h" | |
17 | 16 |
18 namespace content { | 17 namespace content { |
19 | 18 |
20 ProfilerController* ProfilerController::GetInstance() { | 19 ProfilerController* ProfilerController::GetInstance() { |
21 return ProfilerControllerImpl::GetInstance(); | 20 return ProfilerControllerImpl::GetInstance(); |
22 } | 21 } |
23 | 22 |
24 ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { | 23 ProfilerControllerImpl* ProfilerControllerImpl::GetInstance() { |
25 return Singleton<ProfilerControllerImpl>::get(); | 24 return Singleton<ProfilerControllerImpl>::get(); |
26 } | 25 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 68 |
70 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { | 69 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { |
71 DCHECK_EQ(subscriber_, subscriber); | 70 DCHECK_EQ(subscriber_, subscriber); |
72 subscriber_ = NULL; | 71 subscriber_ = NULL; |
73 } | 72 } |
74 | 73 |
75 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( | 74 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( |
76 int sequence_number) { | 75 int sequence_number) { |
77 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 76 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
78 | 77 |
| 78 const base::ProcessId current_proc_id = base::GetCurrentProcId(); |
79 int pending_processes = 0; | 79 int pending_processes = 0; |
80 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 80 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
81 // Skips requesting profiler data from the "GPU Process" if we are using in | 81 // In some cases, the child process may be the same as the current process - |
82 // process GPU. Those stats should be in the Browser-process's GPU thread. | 82 // for example the GPU process may be the same as the browser process. Don't |
83 if (iter.GetData().process_type == PROCESS_TYPE_GPU && | 83 // ask it for profiler data in that case. |
84 CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessGPU)) { | 84 if (base::GetProcId(iter.GetData().handle) == current_proc_id) |
85 continue; | 85 continue; |
86 } | |
87 | 86 |
88 ++pending_processes; | 87 ++pending_processes; |
89 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number))) | 88 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number))) |
90 --pending_processes; | 89 --pending_processes; |
91 } | 90 } |
92 | 91 |
93 BrowserThread::PostTask( | 92 BrowserThread::PostTask( |
94 BrowserThread::UI, | 93 BrowserThread::UI, |
95 FROM_HERE, | 94 FROM_HERE, |
96 base::Bind( | 95 base::Bind( |
(...skipping 20 matching lines...) Expand all Loading... |
117 | 116 |
118 BrowserThread::PostTask( | 117 BrowserThread::PostTask( |
119 BrowserThread::IO, | 118 BrowserThread::IO, |
120 FROM_HERE, | 119 FROM_HERE, |
121 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, | 120 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, |
122 base::Unretained(this), | 121 base::Unretained(this), |
123 sequence_number)); | 122 sequence_number)); |
124 } | 123 } |
125 | 124 |
126 } // namespace content | 125 } // namespace content |
OLD | NEW |