| 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/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, ¤t_count); | 20 counts->GetInteger(index, ¤t_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::ProvideGeneralMetrics( |
| 42 metrics::ChromeUserMetricsExtension* uma_proto) { |
| 43 UMA_HISTOGRAM_ENUMERATION( |
| 44 "DocumentActivity.Enabled", |
| 45 chrome::android::GetDocumentModeValue(), |
| 46 chrome::android::RUNNING_MODE_MAX); |
| 47 } |
| 40 | 48 |
| 41 void AndroidMetricsProvider::ProvideStabilityMetrics( | 49 void AndroidMetricsProvider::ProvideStabilityMetrics( |
| 42 metrics::SystemProfileProto* system_profile_proto) { | 50 metrics::SystemProfileProto* system_profile_proto) { |
| 43 ConvertStabilityPrefsToHistograms(); | 51 ConvertStabilityPrefsToHistograms(); |
| 44 } | 52 } |
| 45 | 53 |
| 46 void AndroidMetricsProvider::LogStabilityToPrefs() { | 54 void AndroidMetricsProvider::LogStabilityToPrefs() { |
| 47 // Track which Activities were launched by the user. | 55 // Track which Activities were launched by the user. |
| 48 // A 'launch' is defined as starting the Activity at least once during a | 56 // 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 | 57 // UMA session. Multiple launches are counted only once since it is possible |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 } | 146 } |
| 139 | 147 |
| 140 // static | 148 // static |
| 141 void AndroidMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { | 149 void AndroidMetricsProvider::RegisterPrefs(PrefRegistrySimple* registry) { |
| 142 registry->RegisterIntegerPref(prefs::kStabilityForegroundActivityType, | 150 registry->RegisterIntegerPref(prefs::kStabilityForegroundActivityType, |
| 143 ActivityTypeIds::ACTIVITY_NONE); | 151 ActivityTypeIds::ACTIVITY_NONE); |
| 144 registry->RegisterIntegerPref(prefs::kStabilityLaunchedActivityFlags, 0); | 152 registry->RegisterIntegerPref(prefs::kStabilityLaunchedActivityFlags, 0); |
| 145 registry->RegisterListPref(prefs::kStabilityLaunchedActivityCounts); | 153 registry->RegisterListPref(prefs::kStabilityLaunchedActivityCounts); |
| 146 registry->RegisterListPref(prefs::kStabilityCrashedActivityCounts); | 154 registry->RegisterListPref(prefs::kStabilityCrashedActivityCounts); |
| 147 } | 155 } |
| OLD | NEW |