Chromium Code Reviews| 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 <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 #include "chrome/browser/sync/chrome_sync_client.h" | 38 #include "chrome/browser/sync/chrome_sync_client.h" |
| 39 #include "chrome/browser/ui/browser_otr_state.h" | 39 #include "chrome/browser/ui/browser_otr_state.h" |
| 40 #include "chrome/common/channel_info.h" | 40 #include "chrome/common/channel_info.h" |
| 41 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
| 42 #include "chrome/common/chrome_paths_internal.h" | 42 #include "chrome/common/chrome_paths_internal.h" |
| 43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/crash_keys.h" | 44 #include "chrome/common/crash_keys.h" |
| 45 #include "chrome/common/features.h" | 45 #include "chrome/common/features.h" |
| 46 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/installer/util/util_constants.h" | 47 #include "chrome/installer/util/util_constants.h" |
| 48 #include "components/browser_watcher/features.h" | |
| 48 #include "components/metrics/call_stack_profile_metrics_provider.h" | 49 #include "components/metrics/call_stack_profile_metrics_provider.h" |
| 49 #include "components/metrics/drive_metrics_provider.h" | 50 #include "components/metrics/drive_metrics_provider.h" |
| 50 #include "components/metrics/file_metrics_provider.h" | 51 #include "components/metrics/file_metrics_provider.h" |
| 51 #include "components/metrics/gpu/gpu_metrics_provider.h" | 52 #include "components/metrics/gpu/gpu_metrics_provider.h" |
| 52 #include "components/metrics/metrics_pref_names.h" | 53 #include "components/metrics/metrics_pref_names.h" |
| 53 #include "components/metrics/metrics_reporting_default_state.h" | 54 #include "components/metrics/metrics_reporting_default_state.h" |
| 54 #include "components/metrics/metrics_service.h" | 55 #include "components/metrics/metrics_service.h" |
| 55 #include "components/metrics/metrics_service_client.h" | 56 #include "components/metrics/metrics_service_client.h" |
| 56 #include "components/metrics/metrics_state_manager.h" | 57 #include "components/metrics/metrics_state_manager.h" |
| 57 #include "components/metrics/net/cellular_logic_helper.h" | 58 #include "components/metrics/net/cellular_logic_helper.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 98 #endif | 99 #endif |
| 99 | 100 |
| 100 #if defined(OS_WIN) | 101 #if defined(OS_WIN) |
| 101 #include <windows.h> | 102 #include <windows.h> |
| 102 | 103 |
| 103 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h" | 104 #include "chrome/browser/metrics/antivirus_metrics_provider_win.h" |
| 104 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" | 105 #include "chrome/browser/metrics/google_update_metrics_provider_win.h" |
| 105 #include "chrome/common/metrics_constants_util_win.h" | 106 #include "chrome/common/metrics_constants_util_win.h" |
| 106 #include "chrome/install_static/install_util.h" | 107 #include "chrome/install_static/install_util.h" |
| 107 #include "chrome/installer/util/browser_distribution.h" | 108 #include "chrome/installer/util/browser_distribution.h" |
| 109 #include "components/browser_watcher/stability_debugging_win.h" | |
| 108 #include "components/browser_watcher/watcher_metrics_provider_win.h" | 110 #include "components/browser_watcher/watcher_metrics_provider_win.h" |
| 109 #endif | 111 #endif |
| 110 | 112 |
| 111 #if defined(OS_WIN) || defined(OS_MACOSX) | 113 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 112 #include "third_party/crashpad/crashpad/client/crashpad_info.h" | 114 #include "third_party/crashpad/crashpad/client/crashpad_info.h" |
| 113 #endif | 115 #endif |
| 114 | 116 |
| 115 #if !defined(OS_CHROMEOS) | 117 #if !defined(OS_CHROMEOS) |
| 116 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " | 118 #include "chrome/browser/signin/chrome_signin_status_metrics_provider_delegate.h " |
| 117 #include "components/signin/core/browser/signin_status_metrics_provider.h" | 119 #include "components/signin/core/browser/signin_status_metrics_provider.h" |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 DCHECK_NE(nullptr, channel_name); | 252 DCHECK_NE(nullptr, channel_name); |
| 251 | 253 |
| 252 wchar_t exe_file[MAX_PATH] = {}; | 254 wchar_t exe_file[MAX_PATH] = {}; |
| 253 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); | 255 CHECK(::GetModuleFileName(nullptr, exe_file, arraysize(exe_file))); |
| 254 | 256 |
| 255 base::string16 unused_special_build; | 257 base::string16 unused_special_build; |
| 256 install_static::GetExecutableVersionDetails( | 258 install_static::GetExecutableVersionDetails( |
| 257 exe_file, product_name, version_number, &unused_special_build, | 259 exe_file, product_name, version_number, &unused_special_build, |
| 258 channel_name); | 260 channel_name); |
| 259 } | 261 } |
| 262 | |
| 263 bool GetStabilityFilePath(base::FilePath* path) { | |
| 264 DCHECK_NE(nullptr, path); | |
| 265 | |
| 266 base::FilePath user_data_dir; | |
| 267 if (!base::PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) | |
| 268 return false; | |
| 269 | |
| 270 return browser_watcher::GetStabilityFileForProcess(base::Process::Current(), | |
| 271 user_data_dir, path); | |
| 272 } | |
| 260 #endif // OS_WIN | 273 #endif // OS_WIN |
| 261 | 274 |
| 262 } // namespace | 275 } // namespace |
| 263 | 276 |
| 264 const char ChromeMetricsServiceClient::kBrowserMetricsName[] = "BrowserMetrics"; | 277 const char ChromeMetricsServiceClient::kBrowserMetricsName[] = "BrowserMetrics"; |
| 265 | 278 |
| 266 ChromeMetricsServiceClient::ChromeMetricsServiceClient( | 279 ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| 267 metrics::MetricsStateManager* state_manager) | 280 metrics::MetricsStateManager* state_manager) |
| 268 : metrics_state_manager_(state_manager), | 281 : metrics_state_manager_(state_manager), |
| 269 #if defined(OS_CHROMEOS) | 282 #if defined(OS_CHROMEOS) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 #endif // OS_WIN || OS_MACOSX | 400 #endif // OS_WIN || OS_MACOSX |
| 388 } | 401 } |
| 389 | 402 |
| 390 void ChromeMetricsServiceClient::OnLogUploadComplete() { | 403 void ChromeMetricsServiceClient::OnLogUploadComplete() { |
| 391 // Collect time ticks stats after each UMA upload. | 404 // Collect time ticks stats after each UMA upload. |
| 392 #if defined(OS_WIN) | 405 #if defined(OS_WIN) |
| 393 chrome::CollectTimeTicksStats(); | 406 chrome::CollectTimeTicksStats(); |
| 394 #endif | 407 #endif |
| 395 } | 408 } |
| 396 | 409 |
| 410 void ChromeMetricsServiceClient::OnLogCleanShutdown() { | |
| 411 #if defined(OS_WIN) | |
| 412 if (!base::FeatureList::IsEnabled( | |
| 413 browser_watcher::kStabilityDebuggingFeature)) { | |
| 414 return; | |
| 415 } | |
| 416 | |
| 417 base::FilePath stability_file; | |
| 418 if (!GetStabilityFilePath(&stability_file)) { | |
| 419 // TODO(manzagop): add a metric for this. | |
| 420 return; | |
| 421 } | |
| 422 | |
| 423 // Open (with delete) and then immediately close the file by going out of | |
| 424 // scope. This should cause the stability debugging file to be deleted prior | |
| 425 // to the next execution. | |
| 426 base::File file(stability_file, base::File::FLAG_OPEN | | |
| 427 base::File::FLAG_READ | | |
| 428 base::File::FLAG_DELETE_ON_CLOSE); | |
| 429 #endif // OS_WIN | |
|
Alexei Svitkine (slow)
2016/11/22 21:29:37
Why not have all this logic live in browser_watche
manzagop (departed)
2016/11/22 22:16:09
Done.
| |
| 430 } | |
| 431 | |
| 397 void ChromeMetricsServiceClient::InitializeSystemProfileMetrics( | 432 void ChromeMetricsServiceClient::InitializeSystemProfileMetrics( |
| 398 const base::Closure& done_callback) { | 433 const base::Closure& done_callback) { |
| 399 DCHECK(initialize_task_queue_.empty()); | 434 DCHECK(initialize_task_queue_.empty()); |
| 400 | 435 |
| 401 // Each provider's initializer takes its own "done_callback" to enable | 436 // Each provider's initializer takes its own "done_callback" to enable |
| 402 // asynchronously chaining. We bind |next_task| to this callback, so | 437 // asynchronously chaining. We bind |next_task| to this callback, so |
| 403 // OnInitNextTask() gets called after each initializer, and we can go through | 438 // OnInitNextTask() gets called after each initializer, and we can go through |
| 404 // successive tasks in |initialize_task_queue_|. Note that |next_task| is | 439 // successive tasks in |initialize_task_queue_|. Note that |next_task| is |
| 405 // copied by value when passed into base::Bind(). | 440 // copied by value when passed into base::Bind(). |
| 406 base::Closure next_task = | 441 base::Closure next_task = |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 879 } | 914 } |
| 880 } | 915 } |
| 881 | 916 |
| 882 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { | 917 void ChromeMetricsServiceClient::OnURLOpenedFromOmnibox(OmniboxLog* log) { |
| 883 metrics_service_->OnApplicationNotIdle(); | 918 metrics_service_->OnApplicationNotIdle(); |
| 884 } | 919 } |
| 885 | 920 |
| 886 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { | 921 bool ChromeMetricsServiceClient::IsUMACellularUploadLogicEnabled() { |
| 887 return metrics::IsCellularLogicEnabled(); | 922 return metrics::IsCellularLogicEnabled(); |
| 888 } | 923 } |
| OLD | NEW |