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

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

Issue 1021053003: Delivering the FIRST_NONEMPTY_PAINT phase changing event to base/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@phase_splitting
Patch Set: More asvitkine@ comments. Created 5 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
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/process/process_handle.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"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 DCHECK(!subscriber_); 65 DCHECK(!subscriber_);
66 subscriber_ = subscriber; 66 subscriber_ = subscriber;
67 } 67 }
68 68
69 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) { 69 void ProfilerControllerImpl::Unregister(const ProfilerSubscriber* subscriber) {
70 DCHECK_EQ(subscriber_, subscriber); 70 DCHECK_EQ(subscriber_, subscriber);
71 subscriber_ = NULL; 71 subscriber_ = NULL;
72 } 72 }
73 73
74 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses( 74 void ProfilerControllerImpl::GetProfilerDataFromChildProcesses(
75 int sequence_number) { 75 int sequence_number,
76 int current_profiling_phase) {
76 DCHECK_CURRENTLY_ON(BrowserThread::IO); 77 DCHECK_CURRENTLY_ON(BrowserThread::IO);
77 78
78 int pending_processes = 0; 79 int pending_processes = 0;
79 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { 80 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
80 // In some cases, there may be no child process of the given type (for 81 // In some cases, there may be no child process of the given type (for
81 // example, the GPU process may not exist and there may instead just be a 82 // example, the GPU process may not exist and there may instead just be a
82 // GPU thread in the browser process). If that's the case, then the process 83 // GPU thread in the browser process). If that's the case, then the process
83 // handle will be base::kNullProcessHandle and we shouldn't ask it for data. 84 // handle will be base::kNullProcessHandle and we shouldn't ask it for data.
84 if (iter.GetData().handle == base::kNullProcessHandle) 85 if (iter.GetData().handle == base::kNullProcessHandle)
85 continue; 86 continue;
86 87
87 ++pending_processes; 88 ++pending_processes;
88 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(sequence_number))) 89 if (!iter.Send(new ChildProcessMsg_GetChildProfilerData(
90 sequence_number, current_profiling_phase))) {
89 --pending_processes; 91 --pending_processes;
92 }
90 } 93 }
91 94
92 BrowserThread::PostTask( 95 BrowserThread::PostTask(
93 BrowserThread::UI, 96 BrowserThread::UI,
94 FROM_HERE, 97 FROM_HERE,
95 base::Bind( 98 base::Bind(
96 &ProfilerControllerImpl::OnPendingProcesses, 99 &ProfilerControllerImpl::OnPendingProcesses,
97 base::Unretained(this), 100 base::Unretained(this),
98 sequence_number, 101 sequence_number,
99 pending_processes, 102 pending_processes,
100 true)); 103 true));
101 } 104 }
102 105
103 void ProfilerControllerImpl::GetProfilerData(int sequence_number) { 106 void ProfilerControllerImpl::NotifyChildProcessesOfProfilingPhaseCompletion(
107 int profiling_phase) {
104 DCHECK_CURRENTLY_ON(BrowserThread::UI); 108 DCHECK_CURRENTLY_ON(BrowserThread::UI);
105 109
110 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
111 // In some cases, there may be no child process of the given type (for
112 // example, the GPU process may not exist and there may instead just be a
113 // GPU thread in the browser process). If that's the case, then the process
114 // handle will be base::kNullProcessHandle and we shouldn't send it a
115 // message.
116 if (iter.GetData().handle == base::kNullProcessHandle)
117 continue;
118
119 iter.Send(new ChildProcessMsg_OnProfilingPhase(profiling_phase));
120 }
121 }
122
123 void ProfilerControllerImpl::GetProfilerData(int sequence_number,
124 int current_profiling_phase) {
125 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
126
106 int pending_processes = 0; 127 int pending_processes = 0;
107 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 128 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
108 !it.IsAtEnd(); it.Advance()) { 129 !it.IsAtEnd(); it.Advance()) {
109 ++pending_processes; 130 ++pending_processes;
110 if (!it.GetCurrentValue()->Send( 131 if (!it.GetCurrentValue()->Send(new ChildProcessMsg_GetChildProfilerData(
111 new ChildProcessMsg_GetChildProfilerData(sequence_number))) { 132 sequence_number, current_profiling_phase))) {
112 --pending_processes; 133 --pending_processes;
113 } 134 }
114 } 135 }
115 OnPendingProcesses(sequence_number, pending_processes, false); 136 OnPendingProcesses(sequence_number, pending_processes, false);
116 137
117 BrowserThread::PostTask( 138 BrowserThread::PostTask(
118 BrowserThread::IO, 139 BrowserThread::IO, FROM_HERE,
119 FROM_HERE,
120 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, 140 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses,
121 base::Unretained(this), 141 base::Unretained(this), sequence_number,
122 sequence_number)); 142 current_profiling_phase));
143 }
144
145 void ProfilerControllerImpl::OnProfilingPhaseCompletion(int profiling_phase) {
Alexei Svitkine (slow) 2015/04/02 16:59:31 Should probably have a comment in this function ex
vadimt 2015/04/06 23:25:12 Hmm. I don't wait for any result simply because th
146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
147
148 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
Alexei Svitkine (slow) 2015/04/02 16:59:31 Hmm, I realise you're just following the same patt
vadimt 2015/04/06 23:25:12 I checked that everything works correctly, and tha
Alexei Svitkine (slow) 2015/04/09 15:39:05 Sorry, forgot to follow-up on this earlier. When y
vadimt 2015/04/09 21:28:39 I've set a breakpoint in the renderer, and checked
149 !it.IsAtEnd(); it.Advance()) {
150 it.GetCurrentValue()->Send(
151 new ChildProcessMsg_OnProfilingPhase(profiling_phase));
152 }
153
154 BrowserThread::PostTask(
155 BrowserThread::IO, FROM_HERE,
156 base::Bind(&ProfilerControllerImpl::
157 NotifyChildProcessesOfProfilingPhaseCompletion,
158 base::Unretained(this), profiling_phase));
123 } 159 }
124 160
125 } // namespace content 161 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698