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 <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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 94 bool IsCellularLogicEnabled() { | 94 bool IsCellularLogicEnabled() { |
| 95 if (variations::GetVariationParamValue("UMA_EnableCellularLogUpload", | 95 if (variations::GetVariationParamValue("UMA_EnableCellularLogUpload", |
| 96 "Enabled") != "true") { | 96 "Enabled") != "true") { |
| 97 return false; | 97 return false; |
| 98 } | 98 } |
| 99 | 99 |
| 100 return net::NetworkChangeNotifier::IsConnectionCellular( | 100 return net::NetworkChangeNotifier::IsConnectionCellular( |
| 101 net::NetworkChangeNotifier::GetConnectionType()); | 101 net::NetworkChangeNotifier::GetConnectionType()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 } // namespace | 104 // Checks whether it is the first time that cellular uploads logic should be |
| 105 // enabled based on whether the the preference for that logic is initialized. | |
| 106 // This should happen only once as the used preference will be initialized | |
| 107 // afterwards in |UmaSessionStats.java|. | |
| 108 bool ShouldClearSavedMetrics() { | |
| 109 #if !defined(OS_ANDROID) | |
| 110 return false; | |
| 111 #endif | |
| 112 PrefService* local_state = g_browser_process->local_state(); | |
| 113 return !local_state->HasPrefPath(prefs::kMetricsReportingEnabled) && | |
| 114 variations::GetVariationParamValue("UMA_EnableCellularLogUpload", | |
| 115 "Enabled") == "true"; | |
| 116 } | |
| 117 | |
| 118 } // anonymous namespace | |
|
Alexei Svitkine (slow)
2015/05/13 14:36:02
Nit: No need to say "anonymous", just " // namesp
gayane -on leave until 09-2017
2015/05/13 14:46:02
Done.
| |
| 119 | |
| 105 | 120 |
| 106 ChromeMetricsServiceClient::ChromeMetricsServiceClient( | 121 ChromeMetricsServiceClient::ChromeMetricsServiceClient( |
| 107 metrics::MetricsStateManager* state_manager) | 122 metrics::MetricsStateManager* state_manager) |
| 108 : metrics_state_manager_(state_manager), | 123 : metrics_state_manager_(state_manager), |
| 109 chromeos_metrics_provider_(nullptr), | 124 chromeos_metrics_provider_(nullptr), |
| 110 waiting_for_collect_final_metrics_step_(false), | 125 waiting_for_collect_final_metrics_step_(false), |
| 111 num_async_histogram_fetches_in_progress_(0), | 126 num_async_histogram_fetches_in_progress_(0), |
| 112 profiler_metrics_provider_(nullptr), | 127 profiler_metrics_provider_(nullptr), |
| 113 #if defined(ENABLE_PLUGINS) | 128 #if defined(ENABLE_PLUGINS) |
| 114 plugin_metrics_provider_(nullptr), | 129 plugin_metrics_provider_(nullptr), |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 void ChromeMetricsServiceClient::LogPluginLoadingError( | 287 void ChromeMetricsServiceClient::LogPluginLoadingError( |
| 273 const base::FilePath& plugin_path) { | 288 const base::FilePath& plugin_path) { |
| 274 #if defined(ENABLE_PLUGINS) | 289 #if defined(ENABLE_PLUGINS) |
| 275 plugin_metrics_provider_->LogPluginLoadingError(plugin_path); | 290 plugin_metrics_provider_->LogPluginLoadingError(plugin_path); |
| 276 #else | 291 #else |
| 277 NOTREACHED(); | 292 NOTREACHED(); |
| 278 #endif // defined(ENABLE_PLUGINS) | 293 #endif // defined(ENABLE_PLUGINS) |
| 279 } | 294 } |
| 280 | 295 |
| 281 void ChromeMetricsServiceClient::Initialize() { | 296 void ChromeMetricsServiceClient::Initialize() { |
| 297 // Clear metrics reports if it is the first time cellular upload logic should | |
| 298 // apply to avoid sudden bulk uploads. It needs to be done before initializing | |
| 299 // metrics service so that metrics log manager is initialized correctly. | |
| 300 if (ShouldClearSavedMetrics()) { | |
| 301 local_state->ClearPref(metrics::prefs::kMetricsInitialLogs); | |
| 302 local_state->ClearPref(metrics::prefs::kMetricsOngoingLogs); | |
| 303 } | |
| 304 | |
| 282 metrics_service_.reset(new metrics::MetricsService( | 305 metrics_service_.reset(new metrics::MetricsService( |
| 283 metrics_state_manager_, this, g_browser_process->local_state())); | 306 metrics_state_manager_, this, g_browser_process->local_state())); |
| 284 | 307 |
| 285 // Register metrics providers. | 308 // Register metrics providers. |
| 286 #if defined(ENABLE_EXTENSIONS) | 309 #if defined(ENABLE_EXTENSIONS) |
| 287 metrics_service_->RegisterMetricsProvider( | 310 metrics_service_->RegisterMetricsProvider( |
| 288 scoped_ptr<metrics::MetricsProvider>( | 311 scoped_ptr<metrics::MetricsProvider>( |
| 289 new ExtensionsMetricsProvider(metrics_state_manager_))); | 312 new ExtensionsMetricsProvider(metrics_state_manager_))); |
| 290 #endif | 313 #endif |
| 291 metrics_service_->RegisterMetricsProvider( | 314 metrics_service_->RegisterMetricsProvider( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 356 new SigninStatusMetricsProviderChromeOS; | 379 new SigninStatusMetricsProviderChromeOS; |
| 357 metrics_service_->RegisterMetricsProvider( | 380 metrics_service_->RegisterMetricsProvider( |
| 358 scoped_ptr<metrics::MetricsProvider>(signin_metrics_provider_cros)); | 381 scoped_ptr<metrics::MetricsProvider>(signin_metrics_provider_cros)); |
| 359 #endif // defined(OS_CHROMEOS) | 382 #endif // defined(OS_CHROMEOS) |
| 360 | 383 |
| 361 #if !defined(OS_CHROMEOS) && !defined(OS_IOS) | 384 #if !defined(OS_CHROMEOS) && !defined(OS_IOS) |
| 362 metrics_service_->RegisterMetricsProvider( | 385 metrics_service_->RegisterMetricsProvider( |
| 363 scoped_ptr<metrics::MetricsProvider>( | 386 scoped_ptr<metrics::MetricsProvider>( |
| 364 SigninStatusMetricsProvider::CreateInstance())); | 387 SigninStatusMetricsProvider::CreateInstance())); |
| 365 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) | 388 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) |
| 389 | |
| 390 // Clear stability metrics if it is the first time cellular upload logic | |
| 391 // should apply to avoid sudden bulk uploads. It needs to be done after all | |
| 392 // providers are registered. | |
| 393 if (ShouldClearSavedMetrics()) | |
| 394 metrics_service_->ClearSavedStabilityMetrics(); | |
| 366 } | 395 } |
| 367 | 396 |
| 368 void ChromeMetricsServiceClient::OnInitTaskGotHardwareClass() { | 397 void ChromeMetricsServiceClient::OnInitTaskGotHardwareClass() { |
| 369 const base::Closure got_plugin_info_callback = | 398 const base::Closure got_plugin_info_callback = |
| 370 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotPluginInfo, | 399 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotPluginInfo, |
| 371 weak_ptr_factory_.GetWeakPtr()); | 400 weak_ptr_factory_.GetWeakPtr()); |
| 372 | 401 |
| 373 #if defined(ENABLE_PLUGINS) | 402 #if defined(ENABLE_PLUGINS) |
| 374 plugin_metrics_provider_->GetPluginInformation(got_plugin_info_callback); | 403 plugin_metrics_provider_->GetPluginInformation(got_plugin_info_callback); |
| 375 #else | 404 #else |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 case content::NOTIFICATION_LOAD_START: | 554 case content::NOTIFICATION_LOAD_START: |
| 526 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: | 555 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: |
| 527 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: | 556 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: |
| 528 metrics_service_->OnApplicationNotIdle(); | 557 metrics_service_->OnApplicationNotIdle(); |
| 529 break; | 558 break; |
| 530 | 559 |
| 531 default: | 560 default: |
| 532 NOTREACHED(); | 561 NOTREACHED(); |
| 533 } | 562 } |
| 534 } | 563 } |
| OLD | NEW |