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

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 comments. Created 5 years, 7 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 // static
107 void ProfilerControllerImpl::NotifyChildProcessesOfProfilingPhaseCompletion(
108 int profiling_phase) {
109 DCHECK_CURRENTLY_ON(BrowserThread::IO);
110
111 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) {
112 // In some cases, there may be no child process of the given type (for
113 // example, the GPU process may not exist and there may instead just be a
114 // GPU thread in the browser process). If that's the case, then the process
115 // handle will be base::kNullProcessHandle and we shouldn't send it a
116 // message.
117 if (iter.GetData().handle == base::kNullProcessHandle)
118 continue;
119
120 iter.Send(new ChildProcessMsg_ProfilingPhaseCompleted(profiling_phase));
121 }
122 }
123
124 void ProfilerControllerImpl::GetProfilerData(int sequence_number,
125 int current_profiling_phase) {
104 DCHECK_CURRENTLY_ON(BrowserThread::UI); 126 DCHECK_CURRENTLY_ON(BrowserThread::UI);
105 127
128 // Iterates through renderers in UI thread, and through other child processes
129 // in IO thread, and send them GetChildProfilerData message. Renderers have to
130 // be contacted from UI thread, and other processes - from IO thread.
106 int pending_processes = 0; 131 int pending_processes = 0;
107 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); 132 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
108 !it.IsAtEnd(); it.Advance()) { 133 !it.IsAtEnd(); it.Advance()) {
109 ++pending_processes; 134 ++pending_processes;
110 if (!it.GetCurrentValue()->Send( 135 if (!it.GetCurrentValue()->Send(new ChildProcessMsg_GetChildProfilerData(
111 new ChildProcessMsg_GetChildProfilerData(sequence_number))) { 136 sequence_number, current_profiling_phase))) {
112 --pending_processes; 137 --pending_processes;
113 } 138 }
114 } 139 }
115 OnPendingProcesses(sequence_number, pending_processes, false); 140 OnPendingProcesses(sequence_number, pending_processes, false);
116 141
117 BrowserThread::PostTask( 142 BrowserThread::PostTask(
118 BrowserThread::IO, 143 BrowserThread::IO, FROM_HERE,
119 FROM_HERE,
120 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses, 144 base::Bind(&ProfilerControllerImpl::GetProfilerDataFromChildProcesses,
121 base::Unretained(this), 145 base::Unretained(this), sequence_number,
122 sequence_number)); 146 current_profiling_phase));
147 }
148
149 void ProfilerControllerImpl::OnProfilingPhaseCompleted(int profiling_phase) {
150 DCHECK_CURRENTLY_ON(BrowserThread::UI);
151
152 // Iterates through renderers in UI thread, and through other child processes
153 // in IO thread, and send them OnProfilingPhase message. Renderers have to be
154 // contacted from UI thread, and other processes - from IO thread.
155 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator());
156 !it.IsAtEnd(); it.Advance()) {
157 it.GetCurrentValue()->Send(
158 new ChildProcessMsg_ProfilingPhaseCompleted(profiling_phase));
159 }
160
161 BrowserThread::PostTask(
162 BrowserThread::IO, FROM_HERE,
163 base::Bind(&ProfilerControllerImpl::
164 NotifyChildProcessesOfProfilingPhaseCompletion,
165 profiling_phase));
123 } 166 }
124 167
125 } // namespace content 168 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698