| 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" |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 RequestContextMap::iterator it = | 125 RequestContextMap::iterator it = |
| 126 outstanding_requests_.Get().find(sequence_number); | 126 outstanding_requests_.Get().find(sequence_number); |
| 127 if (it == outstanding_requests_.Get().end()) | 127 if (it == outstanding_requests_.Get().end()) |
| 128 return; | 128 return; |
| 129 | 129 |
| 130 RequestContext* request = it->second; | 130 RequestContext* request = it->second; |
| 131 DCHECK_EQ(sequence_number, request->sequence_number_); | 131 DCHECK_EQ(sequence_number, request->sequence_number_); |
| 132 bool received_process_group_count = request->received_process_group_count_; | 132 bool received_process_group_count = request->received_process_group_count_; |
| 133 int unresponsive_processes = request->processes_pending_; | 133 int unresponsive_processes = request->processes_pending_; |
| 134 | 134 |
| 135 if (request->callback_object_) | 135 if (request->callback_object_.get()) |
| 136 request->callback_object_->FinishedReceivingProfilerData(); | 136 request->callback_object_->FinishedReceivingProfilerData(); |
| 137 | 137 |
| 138 delete request; | 138 delete request; |
| 139 outstanding_requests_.Get().erase(it); | 139 outstanding_requests_.Get().erase(it); |
| 140 | 140 |
| 141 UMA_HISTOGRAM_BOOLEAN("Profiling.ReceivedProcessGroupCount", | 141 UMA_HISTOGRAM_BOOLEAN("Profiling.ReceivedProcessGroupCount", |
| 142 received_process_group_count); | 142 received_process_group_count); |
| 143 UMA_HISTOGRAM_COUNTS("Profiling.PendingProcessNotResponding", | 143 UMA_HISTOGRAM_COUNTS("Profiling.PendingProcessNotResponding", |
| 144 unresponsive_processes); | 144 unresponsive_processes); |
| 145 } | 145 } |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 void TrackingSynchronizer::DecrementPendingProcessesAndSendData( | 267 void TrackingSynchronizer::DecrementPendingProcessesAndSendData( |
| 268 int sequence_number, | 268 int sequence_number, |
| 269 const tracked_objects::ProcessDataSnapshot& profiler_data, | 269 const tracked_objects::ProcessDataSnapshot& profiler_data, |
| 270 int process_type) { | 270 int process_type) { |
| 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 271 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 272 | 272 |
| 273 RequestContext* request = RequestContext::GetRequestContext(sequence_number); | 273 RequestContext* request = RequestContext::GetRequestContext(sequence_number); |
| 274 if (!request) | 274 if (!request) |
| 275 return; | 275 return; |
| 276 | 276 |
| 277 if (request->callback_object_) { | 277 if (request->callback_object_.get()) { |
| 278 request->callback_object_->ReceivedProfilerData(profiler_data, | 278 request->callback_object_ |
| 279 process_type); | 279 ->ReceivedProfilerData(profiler_data, process_type); |
| 280 } | 280 } |
| 281 | 281 |
| 282 // Delete request if we have heard back from all child processes. | 282 // Delete request if we have heard back from all child processes. |
| 283 request->DecrementProcessesPending(); | 283 request->DecrementProcessesPending(); |
| 284 request->DeleteIfAllDone(); | 284 request->DeleteIfAllDone(); |
| 285 } | 285 } |
| 286 | 286 |
| 287 int TrackingSynchronizer::GetNextAvailableSequenceNumber() { | 287 int TrackingSynchronizer::GetNextAvailableSequenceNumber() { |
| 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 288 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 289 | 289 |
| 290 ++last_used_sequence_number_; | 290 ++last_used_sequence_number_; |
| 291 | 291 |
| 292 // Watch out for wrapping to a negative number. | 292 // Watch out for wrapping to a negative number. |
| 293 if (last_used_sequence_number_ < 0) | 293 if (last_used_sequence_number_ < 0) |
| 294 last_used_sequence_number_ = 1; | 294 last_used_sequence_number_ = 1; |
| 295 return last_used_sequence_number_; | 295 return last_used_sequence_number_; |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace chrome_browser_metrics | 298 } // namespace chrome_browser_metrics |
| OLD | NEW |