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 "chrome/browser/metrics/tracking_synchronizer.h" | 5 #include "chrome/browser/metrics/tracking_synchronizer.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_util.h" | 9 #include "base/process_util.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
12 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | 12 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" |
| 13 #include "chrome/browser/browser_about_handler.h" |
13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
14 #include "content/public/browser/profiler_controller.h" | 15 #include "content/public/browser/profiler_controller.h" |
15 | 16 |
16 using base::TimeTicks; | 17 using base::TimeTicks; |
17 using content::BrowserThread; | 18 using content::BrowserThread; |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // Negative numbers are never used as sequence numbers. We explicitly pick a | 22 // Negative numbers are never used as sequence numbers. We explicitly pick a |
22 // negative number that is "so negative" that even when we add one (as is done | 23 // negative number that is "so negative" that even when we add one (as is done |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 233 |
233 void TrackingSynchronizer::OnProfilerDataCollected( | 234 void TrackingSynchronizer::OnProfilerDataCollected( |
234 int sequence_number, | 235 int sequence_number, |
235 const tracked_objects::ProcessDataSnapshot& profiler_data, | 236 const tracked_objects::ProcessDataSnapshot& profiler_data, |
236 content::ProcessType process_type) { | 237 content::ProcessType process_type) { |
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
238 DecrementPendingProcessesAndSendData(sequence_number, profiler_data, | 239 DecrementPendingProcessesAndSendData(sequence_number, profiler_data, |
239 process_type); | 240 process_type); |
240 } | 241 } |
241 | 242 |
| 243 #if defined(USE_TCMALLOC) |
| 244 void TrackingSynchronizer::OnTcmallocStatsCollected( |
| 245 base::ProcessId pid, |
| 246 content::ProcessType process_type, |
| 247 const std::string& output) { |
| 248 AboutTcmallocOutputs::GetInstance()->OnStatsForChildProcess( |
| 249 pid, process_type, output); |
| 250 } |
| 251 #endif |
| 252 |
242 int TrackingSynchronizer::RegisterAndNotifyAllProcesses( | 253 int TrackingSynchronizer::RegisterAndNotifyAllProcesses( |
243 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object) { | 254 const base::WeakPtr<TrackingSynchronizerObserver>& callback_object) { |
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
245 | 256 |
246 int sequence_number = GetNextAvailableSequenceNumber(); | 257 int sequence_number = GetNextAvailableSequenceNumber(); |
247 | 258 |
248 RequestContext* request = | 259 RequestContext* request = |
249 RequestContext::Register(sequence_number, callback_object); | 260 RequestContext::Register(sequence_number, callback_object); |
250 | 261 |
251 // Increment pending process count for sending browser's profiler data. | 262 // Increment pending process count for sending browser's profiler data. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 299 |
289 ++last_used_sequence_number_; | 300 ++last_used_sequence_number_; |
290 | 301 |
291 // Watch out for wrapping to a negative number. | 302 // Watch out for wrapping to a negative number. |
292 if (last_used_sequence_number_ < 0) | 303 if (last_used_sequence_number_ < 0) |
293 last_used_sequence_number_ = 1; | 304 last_used_sequence_number_ = 1; |
294 return last_used_sequence_number_; | 305 return last_used_sequence_number_; |
295 } | 306 } |
296 | 307 |
297 } // namespace chrome_browser_metrics | 308 } // namespace chrome_browser_metrics |
OLD | NEW |