| 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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/chrome_notification_types.h" | 20 #include "chrome/browser/chrome_notification_types.h" |
| 21 #include "chrome/browser/google/google_brand.h" | 21 #include "chrome/browser/google/google_brand.h" |
| 22 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 22 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| 23 #include "chrome/browser/metrics/omnibox_metrics_provider.h" | 23 #include "chrome/browser/metrics/omnibox_metrics_provider.h" |
| 24 #include "chrome/browser/metrics/time_ticks_experiment_win.h" | 24 #include "chrome/browser/metrics/time_ticks_experiment_win.h" |
| 25 #include "chrome/browser/process_resource_usage.h" | 25 #include "chrome/browser/process_resource_usage.h" |
| 26 #include "chrome/browser/ui/browser_otr_state.h" | 26 #include "chrome/browser/ui/browser_otr_state.h" |
| 27 #include "chrome/common/channel_info.h" |
| 27 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
| 28 #include "chrome/common/chrome_paths.h" | 29 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 30 #include "chrome/common/crash_keys.h" | 31 #include "chrome/common/crash_keys.h" |
| 31 #include "chrome/common/metrics/version_utils.h" | 32 #include "chrome/common/metrics/version_utils.h" |
| 32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
| 33 #include "components/metrics/call_stack_profile_metrics_provider.h" | 34 #include "components/metrics/call_stack_profile_metrics_provider.h" |
| 34 #include "components/metrics/drive_metrics_provider.h" | 35 #include "components/metrics/drive_metrics_provider.h" |
| 35 #include "components/metrics/gpu/gpu_metrics_provider.h" | 36 #include "components/metrics/gpu/gpu_metrics_provider.h" |
| 36 #include "components/metrics/metrics_service.h" | 37 #include "components/metrics/metrics_service.h" |
| 37 #include "components/metrics/net/net_metrics_log_uploader.h" | 38 #include "components/metrics/net/net_metrics_log_uploader.h" |
| 38 #include "components/metrics/net/network_metrics_provider.h" | 39 #include "components/metrics/net/network_metrics_provider.h" |
| 39 #include "components/metrics/profiler/profiler_metrics_provider.h" | 40 #include "components/metrics/profiler/profiler_metrics_provider.h" |
| 40 #include "components/metrics/profiler/tracking_synchronizer.h" | 41 #include "components/metrics/profiler/tracking_synchronizer.h" |
| 41 #include "components/metrics/url_constants.h" | 42 #include "components/metrics/url_constants.h" |
| 42 #include "components/variations/variations_associated_data.h" | 43 #include "components/variations/variations_associated_data.h" |
| 44 #include "components/version_info/version_info.h" |
| 43 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| 44 #include "content/public/browser/histogram_fetcher.h" | 46 #include "content/public/browser/histogram_fetcher.h" |
| 45 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
| 46 #include "content/public/browser/render_process_host.h" | 48 #include "content/public/browser/render_process_host.h" |
| 47 #include "content/public/common/service_registry.h" | 49 #include "content/public/common/service_registry.h" |
| 48 | 50 |
| 49 #if defined(OS_ANDROID) | 51 #if defined(OS_ANDROID) |
| 50 #include "chrome/browser/metrics/android_metrics_provider.h" | 52 #include "chrome/browser/metrics/android_metrics_provider.h" |
| 51 #endif | 53 #endif |
| 52 | 54 |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 199 |
| 198 std::string ChromeMetricsServiceClient::GetApplicationLocale() { | 200 std::string ChromeMetricsServiceClient::GetApplicationLocale() { |
| 199 return g_browser_process->GetApplicationLocale(); | 201 return g_browser_process->GetApplicationLocale(); |
| 200 } | 202 } |
| 201 | 203 |
| 202 bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { | 204 bool ChromeMetricsServiceClient::GetBrand(std::string* brand_code) { |
| 203 return google_brand::GetBrand(brand_code); | 205 return google_brand::GetBrand(brand_code); |
| 204 } | 206 } |
| 205 | 207 |
| 206 metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { | 208 metrics::SystemProfileProto::Channel ChromeMetricsServiceClient::GetChannel() { |
| 207 return metrics::AsProtobufChannel(chrome::VersionInfo::GetChannel()); | 209 return metrics::AsProtobufChannel(chrome::GetChannel()); |
| 208 } | 210 } |
| 209 | 211 |
| 210 std::string ChromeMetricsServiceClient::GetVersionString() { | 212 std::string ChromeMetricsServiceClient::GetVersionString() { |
| 211 return metrics::GetVersionString(); | 213 return metrics::GetVersionString(); |
| 212 } | 214 } |
| 213 | 215 |
| 214 void ChromeMetricsServiceClient::OnLogUploadComplete() { | 216 void ChromeMetricsServiceClient::OnLogUploadComplete() { |
| 215 // Collect time ticks stats after each UMA upload. | 217 // Collect time ticks stats after each UMA upload. |
| 216 #if defined(OS_WIN) | 218 #if defined(OS_WIN) |
| 217 chrome::CollectTimeTicksStats(); | 219 chrome::CollectTimeTicksStats(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 new AndroidMetricsProvider(g_browser_process->local_state()))); | 375 new AndroidMetricsProvider(g_browser_process->local_state()))); |
| 374 #endif // defined(OS_ANDROID) | 376 #endif // defined(OS_ANDROID) |
| 375 | 377 |
| 376 #if defined(OS_WIN) | 378 #if defined(OS_WIN) |
| 377 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; | 379 google_update_metrics_provider_ = new GoogleUpdateMetricsProviderWin; |
| 378 metrics_service_->RegisterMetricsProvider( | 380 metrics_service_->RegisterMetricsProvider( |
| 379 scoped_ptr<metrics::MetricsProvider>(google_update_metrics_provider_)); | 381 scoped_ptr<metrics::MetricsProvider>(google_update_metrics_provider_)); |
| 380 | 382 |
| 381 // Report exit funnels for canary and dev only. | 383 // Report exit funnels for canary and dev only. |
| 382 bool report_exit_funnels = false; | 384 bool report_exit_funnels = false; |
| 383 switch (chrome::VersionInfo::GetChannel()) { | 385 switch (chrome::GetChannel()) { |
| 384 case version_info::Channel::CANARY: | 386 case version_info::Channel::CANARY: |
| 385 case version_info::Channel::DEV: | 387 case version_info::Channel::DEV: |
| 386 report_exit_funnels = true; | 388 report_exit_funnels = true; |
| 387 break; | 389 break; |
| 388 } | 390 } |
| 389 | 391 |
| 390 metrics_service_->RegisterMetricsProvider( | 392 metrics_service_->RegisterMetricsProvider( |
| 391 scoped_ptr<metrics::MetricsProvider>( | 393 scoped_ptr<metrics::MetricsProvider>( |
| 392 new browser_watcher::WatcherMetricsProviderWin( | 394 new browser_watcher::WatcherMetricsProviderWin( |
| 393 chrome::kBrowserExitCodesRegistryPath, report_exit_funnels))); | 395 chrome::kBrowserExitCodesRegistryPath, report_exit_funnels))); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 case content::NOTIFICATION_LOAD_START: | 608 case content::NOTIFICATION_LOAD_START: |
| 607 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: | 609 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: |
| 608 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: | 610 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: |
| 609 metrics_service_->OnApplicationNotIdle(); | 611 metrics_service_->OnApplicationNotIdle(); |
| 610 break; | 612 break; |
| 611 | 613 |
| 612 default: | 614 default: |
| 613 NOTREACHED(); | 615 NOTREACHED(); |
| 614 } | 616 } |
| 615 } | 617 } |
| OLD | NEW |