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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 chromeos_metrics_provider_(nullptr), | 230 chromeos_metrics_provider_(nullptr), |
231 #endif | 231 #endif |
232 waiting_for_collect_final_metrics_step_(false), | 232 waiting_for_collect_final_metrics_step_(false), |
233 num_async_histogram_fetches_in_progress_(0), | 233 num_async_histogram_fetches_in_progress_(0), |
234 profiler_metrics_provider_(nullptr), | 234 profiler_metrics_provider_(nullptr), |
235 #if defined(ENABLE_PLUGINS) | 235 #if defined(ENABLE_PLUGINS) |
236 plugin_metrics_provider_(nullptr), | 236 plugin_metrics_provider_(nullptr), |
237 #endif | 237 #endif |
238 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
239 google_update_metrics_provider_(nullptr), | 239 google_update_metrics_provider_(nullptr), |
| 240 watcher_metrics_provider_(nullptr), |
| 241 antivirus_metrics_provider_(nullptr), |
240 #endif | 242 #endif |
241 drive_metrics_provider_(nullptr), | 243 drive_metrics_provider_(nullptr), |
242 start_time_(base::TimeTicks::Now()), | 244 start_time_(base::TimeTicks::Now()), |
243 has_uploaded_profiler_data_(false), | 245 has_uploaded_profiler_data_(false), |
244 weak_ptr_factory_(this) { | 246 weak_ptr_factory_(this) { |
245 DCHECK(thread_checker_.CalledOnValidThread()); | 247 DCHECK(thread_checker_.CalledOnValidThread()); |
246 RecordCommandLineMetrics(); | 248 RecordCommandLineMetrics(); |
247 RegisterForNotifications(); | 249 RegisterForNotifications(); |
248 } | 250 } |
249 | 251 |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 metrics_service_->RegisterMetricsProvider( | 483 metrics_service_->RegisterMetricsProvider( |
482 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider())); | 484 std::unique_ptr<metrics::MetricsProvider>(new PageLoadMetricsProvider())); |
483 #endif // BUILDFLAG(ANDROID_JAVA_UI) | 485 #endif // BUILDFLAG(ANDROID_JAVA_UI) |
484 | 486 |
485 #if defined(OS_WIN) | 487 #if defined(OS_WIN) |
486 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; | 488 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; |
487 metrics_service_->RegisterMetricsProvider( | 489 metrics_service_->RegisterMetricsProvider( |
488 std::unique_ptr<metrics::MetricsProvider>( | 490 std::unique_ptr<metrics::MetricsProvider>( |
489 google_update_metrics_provider_)); | 491 google_update_metrics_provider_)); |
490 | 492 |
| 493 base::FilePath user_data_dir; |
| 494 base::FilePath crash_dir; |
| 495 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir) || |
| 496 !base::PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dir)) { |
| 497 // If either call fails, then clear both. |
| 498 user_data_dir = base::FilePath(); |
| 499 crash_dir = base::FilePath(); |
| 500 } |
| 501 watcher_metrics_provider_ = new browser_watcher::WatcherMetricsProviderWin( |
| 502 chrome::GetBrowserExitCodesRegistryPath(), user_data_dir, crash_dir, |
| 503 content::BrowserThread::GetBlockingPool()); |
491 metrics_service_->RegisterMetricsProvider( | 504 metrics_service_->RegisterMetricsProvider( |
492 std::unique_ptr<metrics::MetricsProvider>( | 505 std::unique_ptr<metrics::MetricsProvider>(watcher_metrics_provider_)); |
493 new browser_watcher::WatcherMetricsProviderWin( | |
494 chrome::GetBrowserExitCodesRegistryPath(), | |
495 content::BrowserThread::GetBlockingPool()))); | |
496 | 506 |
497 antivirus_metrics_provider_ = new AntiVirusMetricsProvider( | 507 antivirus_metrics_provider_ = new AntiVirusMetricsProvider( |
498 content::BrowserThread::GetBlockingPool() | 508 content::BrowserThread::GetBlockingPool() |
499 ->GetTaskRunnerWithShutdownBehavior( | 509 ->GetTaskRunnerWithShutdownBehavior( |
500 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)); | 510 base::SequencedWorkerPool::CONTINUE_ON_SHUTDOWN)); |
501 | 511 |
502 metrics_service_->RegisterMetricsProvider( | 512 metrics_service_->RegisterMetricsProvider( |
503 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_)); | 513 std::unique_ptr<metrics::MetricsProvider>(antivirus_metrics_provider_)); |
504 #endif // defined(OS_WIN) | 514 #endif // defined(OS_WIN) |
505 | 515 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 #endif // defined(OS_WIN) | 605 #endif // defined(OS_WIN) |
596 } | 606 } |
597 | 607 |
598 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() { | 608 void ChromeMetricsServiceClient::OnInitTaskGotAntiVirusData() { |
599 drive_metrics_provider_->GetDriveMetrics( | 609 drive_metrics_provider_->GetDriveMetrics( |
600 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics, | 610 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics, |
601 weak_ptr_factory_.GetWeakPtr())); | 611 weak_ptr_factory_.GetWeakPtr())); |
602 } | 612 } |
603 | 613 |
604 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() { | 614 void ChromeMetricsServiceClient::OnInitTaskGotDriveMetrics() { |
| 615 #if defined(OS_WIN) |
| 616 watcher_metrics_provider_->CollectPostmortemReports(base::Bind( |
| 617 &ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports, |
| 618 weak_ptr_factory_.GetWeakPtr())); |
| 619 #else |
| 620 OnInitTaskCollectedPostmortemReports(); |
| 621 #endif // defined(OS_WIN) |
| 622 } |
| 623 |
| 624 void ChromeMetricsServiceClient::OnInitTaskCollectedPostmortemReports() { |
605 finished_init_task_callback_.Run(); | 625 finished_init_task_callback_.Run(); |
606 } | 626 } |
607 | 627 |
608 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() { | 628 bool ChromeMetricsServiceClient::ShouldIncludeProfilerDataInLog() { |
609 // Upload profiler data at most once per session. | 629 // Upload profiler data at most once per session. |
610 if (has_uploaded_profiler_data_) | 630 if (has_uploaded_profiler_data_) |
611 return false; | 631 return false; |
612 | 632 |
613 // For each log, flip a fair coin. Thus, profiler data is sent with the first | 633 // For each log, flip a fair coin. Thus, profiler data is sent with the first |
614 // log with probability 50%, with the second log with probability 25%, and so | 634 // log with probability 50%, with the second log with probability 25%, and so |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 } | 816 } |
797 } | 817 } |
798 | 818 |
799 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 819 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
800 metrics_service_->OnApplicationNotIdle(); | 820 metrics_service_->OnApplicationNotIdle(); |
801 } | 821 } |
802 | 822 |
803 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 823 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
804 return metrics::IsCellularLogicEnabled(); | 824 return metrics::IsCellularLogicEnabled(); |
805 } | 825 } |
OLD | NEW |