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 "content/browser/histogram_subscriber.h" | 10 #include "content/browser/histogram_subscriber.h" |
10 #include "content/common/child_process_messages.h" | 11 #include "content/common/child_process_messages.h" |
11 #include "content/public/browser/browser_child_process_host_iterator.h" | 12 #include "content/public/browser/browser_child_process_host_iterator.h" |
12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/child_process_data.h" | 14 #include "content/public/browser/child_process_data.h" |
14 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
15 #include "content/public/common/process_type.h" | 16 #include "content/public/common/process_type.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 void HistogramController::Unregister( | 64 void HistogramController::Unregister( |
64 const HistogramSubscriber* subscriber) { | 65 const HistogramSubscriber* subscriber) { |
65 DCHECK_EQ(subscriber_, subscriber); | 66 DCHECK_EQ(subscriber_, subscriber); |
66 subscriber_ = NULL; | 67 subscriber_ = NULL; |
67 } | 68 } |
68 | 69 |
69 void HistogramController::GetHistogramDataFromChildProcesses( | 70 void HistogramController::GetHistogramDataFromChildProcesses( |
70 int sequence_number) { | 71 int sequence_number) { |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 72 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
72 | 73 |
| 74 const base::ProcessId current_proc_id = base::GetCurrentProcId(); |
73 int pending_processes = 0; | 75 int pending_processes = 0; |
74 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 76 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
75 int type = iter.GetData().process_type; | 77 const ChildProcessData& data = iter.GetData(); |
| 78 int type = data.process_type; |
76 if (type != PROCESS_TYPE_PLUGIN && | 79 if (type != PROCESS_TYPE_PLUGIN && |
77 type != PROCESS_TYPE_GPU && | 80 type != PROCESS_TYPE_GPU && |
78 type != PROCESS_TYPE_PPAPI_PLUGIN && | 81 type != PROCESS_TYPE_PPAPI_PLUGIN && |
79 type != PROCESS_TYPE_PPAPI_BROKER) { | 82 type != PROCESS_TYPE_PPAPI_BROKER) { |
80 continue; | 83 continue; |
81 } | 84 } |
82 | 85 |
| 86 // In some cases, the child process may be the same as the current process - |
| 87 // for example the GPU process may be the same as the browser process. Don't |
| 88 // ask it for histogram data in that case. |
| 89 if (base::GetProcId(data.handle) == current_proc_id) |
| 90 continue; |
| 91 |
83 ++pending_processes; | 92 ++pending_processes; |
84 if (!iter.Send(new ChildProcessMsg_GetChildHistogramData(sequence_number))) | 93 if (!iter.Send(new ChildProcessMsg_GetChildHistogramData(sequence_number))) |
85 --pending_processes; | 94 --pending_processes; |
86 } | 95 } |
87 | 96 |
88 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
89 BrowserThread::UI, | 98 BrowserThread::UI, |
90 FROM_HERE, | 99 FROM_HERE, |
91 base::Bind( | 100 base::Bind( |
92 &HistogramController::OnPendingProcesses, | 101 &HistogramController::OnPendingProcesses, |
(...skipping 19 matching lines...) Expand all Loading... |
112 | 121 |
113 BrowserThread::PostTask( | 122 BrowserThread::PostTask( |
114 BrowserThread::IO, | 123 BrowserThread::IO, |
115 FROM_HERE, | 124 FROM_HERE, |
116 base::Bind(&HistogramController::GetHistogramDataFromChildProcesses, | 125 base::Bind(&HistogramController::GetHistogramDataFromChildProcesses, |
117 base::Unretained(this), | 126 base::Unretained(this), |
118 sequence_number)); | 127 sequence_number)); |
119 } | 128 } |
120 | 129 |
121 } // namespace content | 130 } // namespace content |
OLD | NEW |