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

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

Issue 658903002: Starting a refactor to allow adding metrics on upload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fixes Created 6 years, 2 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
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/android_metrics_provider.h" 5 #include "chrome/browser/metrics/android_metrics_provider.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/prefs/pref_registry_simple.h" 8 #include "base/prefs/pref_registry_simple.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/android/feature_utilities.h"
12 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Increments a particular entry in the ListValue. 17 // Increments a particular entry in the ListValue.
17 void IncrementListValue(base::ListValue* counts, int index) { 18 void IncrementListValue(base::ListValue* counts, int index) {
18 int current_count = 0; 19 int current_count = 0;
19 counts->GetInteger(index, &current_count); 20 counts->GetInteger(index, &current_count);
20 counts->Set(index, new base::FundamentalValue(current_count + 1)); 21 counts->Set(index, new base::FundamentalValue(current_count + 1));
21 } 22 }
22 23
23 // Takes an int corresponding to a Type and returns the corresponding flag. 24 // Takes an int corresponding to a Type and returns the corresponding flag.
24 int GetActivityFlag(int type_id) { 25 int GetActivityFlag(int type_id) {
25 ActivityTypeIds::Type type = ActivityTypeIds::GetActivityType(type_id); 26 ActivityTypeIds::Type type = ActivityTypeIds::GetActivityType(type_id);
26 DCHECK_LT(type, ActivityTypeIds::ACTIVITY_MAX_VALUE); 27 DCHECK_LT(type, ActivityTypeIds::ACTIVITY_MAX_VALUE);
27 return (1 << type); 28 return (1 << type);
28 } 29 }
29 30
30 } // namespace 31 } // namespace
31 32
32 AndroidMetricsProvider::AndroidMetricsProvider(PrefService* local_state) 33 AndroidMetricsProvider::AndroidMetricsProvider(PrefService* local_state)
33 : local_state_(local_state) { 34 : local_state_(local_state) {
34 LogStabilityToPrefs(); 35 LogStabilityToPrefs();
35 } 36 }
36 37
37 AndroidMetricsProvider::~AndroidMetricsProvider() { 38 AndroidMetricsProvider::~AndroidMetricsProvider() {
38 } 39 }
39 40
41 void AndroidMetricsProvider::OnCollectFinalMetrics() {
42 UMA_HISTOGRAM_ENUMERATION(
43 "DocumentMode.Enabled",
Alexei Svitkine (slow) 2014/10/17 18:30:51 Please don't introduce a new top-level prefix. May
Maria 2014/10/17 21:44:50 I am reusing a top level prefix that we use in int
Alexei Svitkine (slow) 2014/10/20 15:47:00 Ah fair enough, OK,
44 chrome::android::GetDocumentModeValue(),
45 chrome::android::HISTOGRAM_MAX);
46 }
40 47
41 void AndroidMetricsProvider::ProvideStabilityMetrics( 48 void AndroidMetricsProvider::ProvideStabilityMetrics(
42 metrics::SystemProfileProto* system_profile_proto) { 49 metrics::SystemProfileProto* system_profile_proto) {
43 ConvertStabilityPrefsToHistograms(); 50 ConvertStabilityPrefsToHistograms();
44 } 51 }
45 52
46 void AndroidMetricsProvider::LogStabilityToPrefs() { 53 void AndroidMetricsProvider::LogStabilityToPrefs() {
47 // Track which Activities were launched by the user. 54 // Track which Activities were launched by the user.
48 // A 'launch' is defined as starting the Activity at least once during a 55 // A 'launch' is defined as starting the Activity at least once during a
49 // UMA session. Multiple launches are counted only once since it is possible 56 // UMA session. Multiple launches are counted only once since it is possible
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 145 }
139 146
140 // static 147 // static
141 void AndroidMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { 148 void AndroidMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) {
142 registry->RegisterIntegerPref(prefs::kStabilityForegroundActivityType, 149 registry->RegisterIntegerPref(prefs::kStabilityForegroundActivityType,
143 ActivityTypeIds::ACTIVITY_NONE); 150 ActivityTypeIds::ACTIVITY_NONE);
144 registry->RegisterIntegerPref(prefs::kStabilityLaunchedActivityFlags, 0); 151 registry->RegisterIntegerPref(prefs::kStabilityLaunchedActivityFlags, 0);
145 registry->RegisterListPref(prefs::kStabilityLaunchedActivityCounts); 152 registry->RegisterListPref(prefs::kStabilityLaunchedActivityCounts);
146 registry->RegisterListPref(prefs::kStabilityCrashedActivityCounts); 153 registry->RegisterListPref(prefs::kStabilityCrashedActivityCounts);
147 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698