| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome_metrics_service_client.h" | 5 #include "chrome/browser/metrics/chrome_metrics_service_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 waiting_for_collect_final_metrics_step_(false), | 126 waiting_for_collect_final_metrics_step_(false), |
| 127 num_async_histogram_fetches_in_progress_(0), | 127 num_async_histogram_fetches_in_progress_(0), |
| 128 profiler_metrics_provider_(nullptr), | 128 profiler_metrics_provider_(nullptr), |
| 129 #if defined(ENABLE_PLUGINS) | 129 #if defined(ENABLE_PLUGINS) |
| 130 plugin_metrics_provider_(nullptr), | 130 plugin_metrics_provider_(nullptr), |
| 131 #endif | 131 #endif |
| 132 #if defined(OS_WIN) | 132 #if defined(OS_WIN) |
| 133 google_update_metrics_provider_(nullptr), | 133 google_update_metrics_provider_(nullptr), |
| 134 #endif | 134 #endif |
| 135 drive_metrics_provider_(nullptr), | 135 drive_metrics_provider_(nullptr), |
| 136 start_time_(base::TimeTicks::Now()), |
| 136 weak_ptr_factory_(this) { | 137 weak_ptr_factory_(this) { |
| 137 DCHECK(thread_checker_.CalledOnValidThread()); | 138 DCHECK(thread_checker_.CalledOnValidThread()); |
| 138 RecordCommandLineMetrics(); | 139 RecordCommandLineMetrics(); |
| 139 RegisterForNotifications(); | 140 RegisterForNotifications(); |
| 140 } | 141 } |
| 141 | 142 |
| 142 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { | 143 ChromeMetricsServiceClient::~ChromeMetricsServiceClient() { |
| 143 DCHECK(thread_checker_.CalledOnValidThread()); | 144 DCHECK(thread_checker_.CalledOnValidThread()); |
| 144 } | 145 } |
| 145 | 146 |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) | 417 #endif // defined(OS_WIN) && defined(GOOGLE_CHROME_BUILD) |
| 417 } | 418 } |
| 418 | 419 |
| 419 void ChromeMetricsServiceClient::OnInitTaskGotGoogleUpdateData() { | 420 void ChromeMetricsServiceClient::OnInitTaskGotGoogleUpdateData() { |
| 420 // Start the next part of the init task: fetching performance data. This will | 421 // Start the next part of the init task: fetching performance data. This will |
| 421 // call into |FinishedReceivingProfilerData()| when the task completes. | 422 // call into |FinishedReceivingProfilerData()| when the task completes. |
| 422 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously( | 423 metrics::TrackingSynchronizer::FetchProfilerDataAsynchronously( |
| 423 weak_ptr_factory_.GetWeakPtr()); | 424 weak_ptr_factory_.GetWeakPtr()); |
| 424 } | 425 } |
| 425 | 426 |
| 426 // TODO(vadimt): Consider wrapping params in a struct after the list of params | |
| 427 // to ReceivedProfilerData settles. crbug/456354. | |
| 428 void ChromeMetricsServiceClient::ReceivedProfilerData( | 427 void ChromeMetricsServiceClient::ReceivedProfilerData( |
| 429 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, | 428 const tracked_objects::ProcessDataPhaseSnapshot& process_data_phase, |
| 430 base::ProcessId process_id, | 429 base::ProcessId process_id, |
| 431 content::ProcessType process_type, | 430 content::ProcessType process_type, |
| 432 int profiling_phase, | 431 int profiling_phase, |
| 433 base::TimeDelta phase_start, | 432 base::TimeTicks phase_start, |
| 434 base::TimeDelta phase_finish, | 433 base::TimeTicks phase_finish, |
| 435 const metrics::ProfilerEvents& past_events) { | 434 const metrics::ProfilerEvents& past_events) { |
| 436 profiler_metrics_provider_->RecordProfilerData( | 435 profiler_metrics_provider_->RecordProfilerData( |
| 437 process_data_phase, process_id, process_type, profiling_phase, | 436 process_data_phase, process_id, process_type, profiling_phase, |
| 438 phase_start, phase_finish, past_events); | 437 phase_start - start_time_, phase_finish - start_time_, past_events); |
| 439 } | 438 } |
| 440 | 439 |
| 441 void ChromeMetricsServiceClient::FinishedReceivingProfilerData() { | 440 void ChromeMetricsServiceClient::FinishedReceivingProfilerData() { |
| 442 drive_metrics_provider_->GetDriveMetrics( | 441 drive_metrics_provider_->GetDriveMetrics( |
| 443 finished_gathering_initial_metrics_callback_); | 442 finished_gathering_initial_metrics_callback_); |
| 444 } | 443 } |
| 445 | 444 |
| 446 void ChromeMetricsServiceClient::OnMemoryDetailCollectionDone() { | 445 void ChromeMetricsServiceClient::OnMemoryDetailCollectionDone() { |
| 447 DCHECK(thread_checker_.CalledOnValidThread()); | 446 DCHECK(thread_checker_.CalledOnValidThread()); |
| 448 | 447 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 557 case content::NOTIFICATION_LOAD_START: | 556 case content::NOTIFICATION_LOAD_START: |
| 558 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: | 557 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: |
| 559 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: | 558 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: |
| 560 metrics_service_->OnApplicationNotIdle(); | 559 metrics_service_->OnApplicationNotIdle(); |
| 561 break; | 560 break; |
| 562 | 561 |
| 563 default: | 562 default: |
| 564 NOTREACHED(); | 563 NOTREACHED(); |
| 565 } | 564 } |
| 566 } | 565 } |
| OLD | NEW |