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/histogram_controller.h" | 5 #include "content/browser/histogram_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
10 #include "content/browser/histogram_subscriber.h" | 10 #include "content/browser/histogram_subscriber.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 } | 82 } |
83 | 83 |
84 // In some cases, there may be no child process of the given type (for | 84 // In some cases, there may be no child process of the given type (for |
85 // example, the GPU process may not exist and there may instead just be a | 85 // example, the GPU process may not exist and there may instead just be a |
86 // GPU thread in the browser process). If that's the case, then the process | 86 // GPU thread in the browser process). If that's the case, then the process |
87 // handle will be base::kNullProcessHandle and we shouldn't ask it for data. | 87 // handle will be base::kNullProcessHandle and we shouldn't ask it for data. |
88 if (data.handle == base::kNullProcessHandle) | 88 if (data.handle == base::kNullProcessHandle) |
89 continue; | 89 continue; |
90 | 90 |
91 ++pending_processes; | 91 ++pending_processes; |
92 if (!iter.Send(new ChildProcessMsg_GetChildNonPersistentHistogramData( | 92 if (!iter.Send(new ChildProcessMsg_GetChildHistogramData(sequence_number))) |
93 sequence_number))) { | |
94 --pending_processes; | 93 --pending_processes; |
95 } | |
96 } | 94 } |
97 | 95 |
98 BrowserThread::PostTask( | 96 BrowserThread::PostTask( |
99 BrowserThread::UI, | 97 BrowserThread::UI, |
100 FROM_HERE, | 98 FROM_HERE, |
101 base::Bind( | 99 base::Bind( |
102 &HistogramController::OnPendingProcesses, | 100 &HistogramController::OnPendingProcesses, |
103 base::Unretained(this), | 101 base::Unretained(this), |
104 sequence_number, | 102 sequence_number, |
105 pending_processes, | 103 pending_processes, |
106 true)); | 104 true)); |
107 } | 105 } |
108 | 106 |
109 void HistogramController::GetHistogramData(int sequence_number) { | 107 void HistogramController::GetHistogramData(int sequence_number) { |
110 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 108 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
111 | 109 |
112 int pending_processes = 0; | 110 int pending_processes = 0; |
113 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); | 111 for (RenderProcessHost::iterator it(RenderProcessHost::AllHostsIterator()); |
114 !it.IsAtEnd(); it.Advance()) { | 112 !it.IsAtEnd(); it.Advance()) { |
115 ++pending_processes; | 113 ++pending_processes; |
116 if (!it.GetCurrentValue()->Send( | 114 if (!it.GetCurrentValue()->Send( |
117 new ChildProcessMsg_GetChildNonPersistentHistogramData( | 115 new ChildProcessMsg_GetChildHistogramData(sequence_number))) { |
118 sequence_number))) { | |
119 --pending_processes; | 116 --pending_processes; |
120 } | 117 } |
121 } | 118 } |
122 OnPendingProcesses(sequence_number, pending_processes, false); | 119 OnPendingProcesses(sequence_number, pending_processes, false); |
123 | 120 |
124 BrowserThread::PostTask( | 121 BrowserThread::PostTask( |
125 BrowserThread::IO, | 122 BrowserThread::IO, |
126 FROM_HERE, | 123 FROM_HERE, |
127 base::Bind(&HistogramController::GetHistogramDataFromChildProcesses, | 124 base::Bind(&HistogramController::GetHistogramDataFromChildProcesses, |
128 base::Unretained(this), | 125 base::Unretained(this), |
129 sequence_number)); | 126 sequence_number)); |
130 } | 127 } |
131 | 128 |
132 } // namespace content | 129 } // namespace content |
OLD | NEW |