| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 TrackingSynchronizer* TrackingSynchronizer::CurrentSynchronizer() { | 50 TrackingSynchronizer* TrackingSynchronizer::CurrentSynchronizer() { |
| 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 51 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 52 DCHECK(tracking_synchronizer_ != NULL); | 52 DCHECK(tracking_synchronizer_ != NULL); |
| 53 return tracking_synchronizer_; | 53 return tracking_synchronizer_; |
| 54 } | 54 } |
| 55 | 55 |
| 56 // static | 56 // static |
| 57 void TrackingSynchronizer::FetchTrackingDataAsynchronously( | 57 void TrackingSynchronizer::FetchTrackingDataAsynchronously( |
| 58 const base::WeakPtr<TrackingUI>& callback_object) { | 58 const base::WeakPtr<ProfilerUI>& callback_object) { |
| 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 59 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 60 | 60 |
| 61 TrackingSynchronizer* current_synchronizer = CurrentSynchronizer(); | 61 TrackingSynchronizer* current_synchronizer = CurrentSynchronizer(); |
| 62 if (current_synchronizer == NULL) { | 62 if (current_synchronizer == NULL) { |
| 63 // System teardown is happening. | 63 // System teardown is happening. |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 int sequence_number = current_synchronizer->RegisterAndNotifyAllProcesses( | 67 int sequence_number = current_synchronizer->RegisterAndNotifyAllProcesses( |
| 68 callback_object); | 68 callback_object); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 base::DictionaryValue* dictionary_value = | 152 base::DictionaryValue* dictionary_value = |
| 153 static_cast<DictionaryValue*>(value); | 153 static_cast<DictionaryValue*>(value); |
| 154 dictionary_value->SetString( | 154 dictionary_value->SetString( |
| 155 "process_type", ChildProcessInfo::GetTypeNameInEnglish(process_type)); | 155 "process_type", ChildProcessInfo::GetTypeNameInEnglish(process_type)); |
| 156 | 156 |
| 157 current_synchronizer->DecrementPendingProcessesAndSendData( | 157 current_synchronizer->DecrementPendingProcessesAndSendData( |
| 158 sequence_number, dictionary_value); | 158 sequence_number, dictionary_value); |
| 159 } | 159 } |
| 160 | 160 |
| 161 int TrackingSynchronizer::RegisterAndNotifyAllProcesses( | 161 int TrackingSynchronizer::RegisterAndNotifyAllProcesses( |
| 162 const base::WeakPtr<TrackingUI>& callback_object) { | 162 const base::WeakPtr<ProfilerUI>& callback_object) { |
| 163 // To iterate over all processes, or to send messages to the hosts, we need | 163 // To iterate over all processes, or to send messages to the hosts, we need |
| 164 // to be on the UI thread. | 164 // to be on the UI thread. |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 166 | 166 |
| 167 int sequence_number = GetNextAvailableSequenceNumber(); | 167 int sequence_number = GetNextAvailableSequenceNumber(); |
| 168 | 168 |
| 169 // Initialize processes_pending with one because we are going to send | 169 // Initialize processes_pending with one because we are going to send |
| 170 // browser's ThreadData. | 170 // browser's ThreadData. |
| 171 RequestContext* request = new RequestContext( | 171 RequestContext* request = new RequestContext( |
| 172 callback_object, sequence_number, 1, TimeTicks::Now()); | 172 callback_object, sequence_number, 1, TimeTicks::Now()); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // Watch out for wrapping to a negative number. | 262 // Watch out for wrapping to a negative number. |
| 263 if (last_used_sequence_number_ < 0) | 263 if (last_used_sequence_number_ < 0) |
| 264 last_used_sequence_number_ = 1; | 264 last_used_sequence_number_ = 1; |
| 265 return last_used_sequence_number_; | 265 return last_used_sequence_number_; |
| 266 } | 266 } |
| 267 | 267 |
| 268 // static | 268 // static |
| 269 TrackingSynchronizer* TrackingSynchronizer::tracking_synchronizer_ = NULL; | 269 TrackingSynchronizer* TrackingSynchronizer::tracking_synchronizer_ = NULL; |
| 270 | 270 |
| 271 } // namespace chrome_browser_metrics | 271 } // namespace chrome_browser_metrics |
| OLD | NEW |