Chromium Code Reviews| Index: content/browser/profiler_controller_impl.cc |
| diff --git a/content/browser/profiler_controller_impl.cc b/content/browser/profiler_controller_impl.cc |
| index 27c95ed9138ecae2ca4cf5534dd68b87e382b98a..5adef6bf5485fb9aab8f4a664caf596c9bbd8d2e 100644 |
| --- a/content/browser/profiler_controller_impl.cc |
| +++ b/content/browser/profiler_controller_impl.cc |
| @@ -72,7 +72,8 @@ void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { |
| } |
| void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( |
| - int sequence_number) { |
| + int sequence_number, |
| + int profiling_phase) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| int pending_processes = 0; |
| @@ -85,7 +86,8 @@ void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( |
| continue; |
| ++pending_processes; |
| - if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number))) |
| + if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number, |
| + profiling_phase))) |
|
Alexei Svitkine (slow)
2015/03/06 20:06:40
Nit: {}'s
vadimt
2015/03/06 21:34:58
Done.
|
| --pending_processes; |
| } |
| @@ -100,26 +102,58 @@ void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( |
| true)); |
| } |
| -void ProfilerControllerImpl::GetProfilerData(int sequence_number) { |
| +void ProfilerControllerImpl::NotifyChildProcessesOfProfilingPhaseCompletion( |
| + int profiling_phase) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| + |
| + for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
| + // In some cases, there may be no child process of the given type (for |
| + // example, the GPU process may not exist and there may instead just be a |
| + // GPU thread in the browser process). If that's the case, then the process |
| + // handle will be base::kNullProcessHandle and we shouldn't send it a |
| + // message. |
| + if (iter.GetData().handle == base::kNullProcessHandle) |
| + continue; |
| + |
| + iter.Send(new ChildProcessMsg_OnProfilingPhase(profiling_phase)); |
| + } |
| +} |
| + |
| +void ProfilerControllerImpl::GetProfilerData(int sequence_number, |
| + int profiling_phase) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| int pending_processes = 0; |
| for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |
| !it.IsAtEnd(); it.Advance()) { |
| ++pending_processes; |
| - if (!it.GetCurrentValue()->Send( |
| - new ChildProcessMsg_GetChildProfilerData(sequence_number))) { |
| + if (!it.GetCurrentValue()->Send(new ChildProcessMsg_GetChildProfilerData( |
| + sequence_number, profiling_phase))) { |
| --pending_processes; |
| } |
| } |
| OnPendingProcesses(sequence_number, pending_processes, false); |
| BrowserThread::PostTask( |
| - BrowserThread::IO, |
| - FROM_HERE, |
| + BrowserThread::IO, FROM_HERE, |
| base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, |
| - base::Unretained(this), |
| - sequence_number)); |
| + base::Unretained(this), sequence_number, profiling_phase)); |
| +} |
| + |
| +void ProfilerControllerImpl::OnProfilingPhaseCompletion(int profiling_phase) { |
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| + |
| + for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |
| + !it.IsAtEnd(); it.Advance()) { |
| + it.GetCurrentValue()->Send( |
| + new ChildProcessMsg_OnProfilingPhase(profiling_phase)); |
| + } |
| + |
| + BrowserThread::PostTask( |
| + BrowserThread::IO, FROM_HERE, |
| + base::Bind(&ProfilerControllerImpl:: |
| + NotifyChildProcessesOfProfilingPhaseCompletion, |
| + base::Unretained(this), profiling_phase)); |
| } |
| } // namespace content |