Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: chrome/browser/metrics/chrome_metrics_service_client.cc

Issue 1130993005: Reset metrics if cellular uploads logic should be applied. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #if defined(OS_ANDROID)
105 // Checks whether it is the first time that cellular uploads logic should be
106 // enabled based on whether the the preference for that logic is initialized.
107 // This should happen only once as the used preference will be initialized
108 // afterwards in |UmaSessionStats.java|.
109 bool needReset() {
Alexei Svitkine (slow) 2015/05/12 16:40:00 Please use a better name. Capitalize first letter
gayane -on leave until 09-2017 2015/05/13 13:56:12 Done.
110 PrefService* local_state = g_browser_process->local_state();
111 return !local_state->HasPrefPath(prefs::kMetricsReportingEnabled) &&
112 variations::GetVariationParamValue("UMA_EnableCellularLogUpload",
113 "Enabled") == "true";
114 }
115 #endif
104 } // namespace 116 } // namespace
Alexei Svitkine (slow) 2015/05/12 16:40:00 Nit: add a blank line after this.
gayane -on leave until 09-2017 2015/05/13 13:56:12 Done.
105 117
106 ChromeMetricsServiceClient::ChromeMetricsServiceClient( 118 ChromeMetricsServiceClient::ChromeMetricsServiceClient(
107 metrics::MetricsStateManager* state_manager) 119 metrics::MetricsStateManager* state_manager)
108 : metrics_state_manager_(state_manager), 120 : metrics_state_manager_(state_manager),
109 chromeos_metrics_provider_(nullptr), 121 chromeos_metrics_provider_(nullptr),
110 waiting_for_collect_final_metrics_step_(false), 122 waiting_for_collect_final_metrics_step_(false),
111 num_async_histogram_fetches_in_progress_(0), 123 num_async_histogram_fetches_in_progress_(0),
112 profiler_metrics_provider_(nullptr), 124 profiler_metrics_provider_(nullptr),
113 #if defined(ENABLE_PLUGINS) 125 #if defined(ENABLE_PLUGINS)
114 plugin_metrics_provider_(nullptr), 126 plugin_metrics_provider_(nullptr),
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 void ChromeMetricsServiceClient::LogPluginLoadingError( 284 void ChromeMetricsServiceClient::LogPluginLoadingError(
273 const base::FilePath& plugin_path) { 285 const base::FilePath& plugin_path) {
274 #if defined(ENABLE_PLUGINS) 286 #if defined(ENABLE_PLUGINS)
275 plugin_metrics_provider_->LogPluginLoadingError(plugin_path); 287 plugin_metrics_provider_->LogPluginLoadingError(plugin_path);
276 #else 288 #else
277 NOTREACHED(); 289 NOTREACHED();
278 #endif // defined(ENABLE_PLUGINS) 290 #endif // defined(ENABLE_PLUGINS)
279 } 291 }
280 292
281 void ChromeMetricsServiceClient::Initialize() { 293 void ChromeMetricsServiceClient::Initialize() {
294 // Reset metrics reports if it is the first time cellular upload logic should
295 // apply to avoid sudden bulk uploads. It needs to be done before initializing
296 // metrics service so that metrics log manager is initialized correctly.
297 #if defined(OS_ANDROID)
Alexei Svitkine (slow) 2015/05/12 16:40:00 Instead of having the ifdefs in 3 places, how abou
gayane -on leave until 09-2017 2015/05/13 13:56:12 Done.
298 if (needReset()) {
299 local_state->ClearPref(metrics::prefs::kMetricsInitialLogs);
300 local_state->ClearPref(metrics::prefs::kMetricsOngoingLogs);
301 }
302 #endif
303
282 metrics_service_.reset(new metrics::MetricsService( 304 metrics_service_.reset(new metrics::MetricsService(
283 metrics_state_manager_, this, g_browser_process->local_state())); 305 metrics_state_manager_, this, g_browser_process->local_state()));
284 306
285 // Register metrics providers. 307 // Register metrics providers.
286 #if defined(ENABLE_EXTENSIONS) 308 #if defined(ENABLE_EXTENSIONS)
287 metrics_service_->RegisterMetricsProvider( 309 metrics_service_->RegisterMetricsProvider(
288 scoped_ptr<metrics::MetricsProvider>( 310 scoped_ptr<metrics::MetricsProvider>(
289 new ExtensionsMetricsProvider(metrics_state_manager_))); 311 new ExtensionsMetricsProvider(metrics_state_manager_)));
290 #endif 312 #endif
291 metrics_service_->RegisterMetricsProvider( 313 metrics_service_->RegisterMetricsProvider(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 new SigninStatusMetricsProviderChromeOS; 378 new SigninStatusMetricsProviderChromeOS;
357 metrics_service_->RegisterMetricsProvider( 379 metrics_service_->RegisterMetricsProvider(
358 scoped_ptr<metrics::MetricsProvider>(signin_metrics_provider_cros)); 380 scoped_ptr<metrics::MetricsProvider>(signin_metrics_provider_cros));
359 #endif // defined(OS_CHROMEOS) 381 #endif // defined(OS_CHROMEOS)
360 382
361 #if !defined(OS_CHROMEOS) && !defined(OS_IOS) 383 #if !defined(OS_CHROMEOS) && !defined(OS_IOS)
362 metrics_service_->RegisterMetricsProvider( 384 metrics_service_->RegisterMetricsProvider(
363 scoped_ptr<metrics::MetricsProvider>( 385 scoped_ptr<metrics::MetricsProvider>(
364 SigninStatusMetricsProvider::CreateInstance())); 386 SigninStatusMetricsProvider::CreateInstance()));
365 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS) 387 #endif // !defined(OS_CHROMEOS) && !defined(OS_IOS)
388
389 // Reset stability metrics if it is the first time cellular upload logic should
390 // apply to avoid sudden bulk uploads. It needs to be done after all providers
391 // are registered.
392 #if defined(OS_ANDROID)
393 if (needReset()) {
Alexei Svitkine (slow) 2015/05/12 16:40:00 Nit: No {}'s
gayane -on leave until 09-2017 2015/05/13 13:56:12 Done.
394 metrics_service_->ClearSavedStabilityMetrics();
395 }
396 #endif
366 } 397 }
367 398
368 void ChromeMetricsServiceClient::OnInitTaskGotHardwareClass() { 399 void ChromeMetricsServiceClient::OnInitTaskGotHardwareClass() {
369 const base::Closure got_plugin_info_callback = 400 const base::Closure got_plugin_info_callback =
370 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotPluginInfo, 401 base::Bind(&ChromeMetricsServiceClient::OnInitTaskGotPluginInfo,
371 weak_ptr_factory_.GetWeakPtr()); 402 weak_ptr_factory_.GetWeakPtr());
372 403
373 #if defined(ENABLE_PLUGINS) 404 #if defined(ENABLE_PLUGINS)
374 plugin_metrics_provider_->GetPluginInformation(got_plugin_info_callback); 405 plugin_metrics_provider_->GetPluginInformation(got_plugin_info_callback);
375 #else 406 #else
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 case content::NOTIFICATION_LOAD_START: 556 case content::NOTIFICATION_LOAD_START:
526 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: 557 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED:
527 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: 558 case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG:
528 metrics_service_->OnApplicationNotIdle(); 559 metrics_service_->OnApplicationNotIdle();
529 break; 560 break;
530 561
531 default: 562 default:
532 NOTREACHED(); 563 NOTREACHED();
533 } 564 }
534 } 565 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698