Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/arc/arc_optin_uma.h" | 5 #include "chrome/browser/chromeos/arc/arc_optin_uma.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 | 10 |
| 11 namespace arc { | 11 namespace arc { |
| 12 | 12 |
| 13 namespace { | |
| 14 | |
| 15 constexpr char kArcAuthHistogramPrefix[] = "Arc.Auth."; | |
| 16 | |
| 17 std::string GetAuthHistogramName(const std::string& key) { | |
| 18 return kArcAuthHistogramPrefix + key; | |
|
dcheng
2017/02/23 19:50:19
Just add the Arc.Auth. prefix to the UMAs, it'll b
khmel
2017/02/23 20:06:35
Done.
| |
| 19 } | |
| 20 | |
| 21 } // namespace | |
| 22 | |
| 13 void UpdateOptInActionUMA(OptInActionType type) { | 23 void UpdateOptInActionUMA(OptInActionType type) { |
| 14 UMA_HISTOGRAM_ENUMERATION("Arc.OptInAction", static_cast<int>(type), | 24 UMA_HISTOGRAM_ENUMERATION("Arc.OptInAction", static_cast<int>(type), |
| 15 static_cast<int>(OptInActionType::SIZE)); | 25 static_cast<int>(OptInActionType::SIZE)); |
| 16 } | 26 } |
| 17 | 27 |
| 18 void UpdateOptInCancelUMA(OptInCancelReason reason) { | 28 void UpdateOptInCancelUMA(OptInCancelReason reason) { |
| 19 UMA_HISTOGRAM_ENUMERATION("Arc.OptInCancel", static_cast<int>(reason), | 29 UMA_HISTOGRAM_ENUMERATION("Arc.OptInCancel", static_cast<int>(reason), |
| 20 static_cast<int>(OptInCancelReason::SIZE)); | 30 static_cast<int>(OptInCancelReason::SIZE)); |
| 21 } | 31 } |
| 22 | 32 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 44 // The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since | 54 // The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since |
| 45 // this measurement happens very infrequently, we do not need to use a macro | 55 // this measurement happens very infrequently, we do not need to use a macro |
| 46 // here. | 56 // here. |
| 47 base::Histogram::FactoryTimeGet( | 57 base::Histogram::FactoryTimeGet( |
| 48 histogram_name, base::TimeDelta::FromSeconds(1), | 58 histogram_name, base::TimeDelta::FromSeconds(1), |
| 49 base::TimeDelta::FromMinutes(6), 50, | 59 base::TimeDelta::FromMinutes(6), 50, |
| 50 base::HistogramBase::kUmaTargetedHistogramFlag) | 60 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 51 ->AddTime(elapsed_time); | 61 ->AddTime(elapsed_time); |
| 52 } | 62 } |
| 53 | 63 |
| 64 void UpdateAuthTiming(const std::string& key, | |
|
dcheng
2017/02/23 19:50:19
And then pass this as const char* to save some tem
khmel
2017/02/23 20:06:35
Done.
| |
| 65 const base::TimeDelta& elapsed_time) { | |
|
dcheng
2017/02/23 19:50:19
Nit: pass by value
khmel
2017/02/23 20:06:36
Done.
| |
| 66 base::Histogram::FactoryTimeGet( | |
| 67 GetAuthHistogramName(key), base::TimeDelta::FromSeconds(1) /* minimum */, | |
| 68 base::TimeDelta::FromMinutes(3) /* maximum */, 50 /* bucket_count */, | |
| 69 base::HistogramBase::kUmaTargetedHistogramFlag) | |
| 70 ->AddTime(elapsed_time); | |
| 71 } | |
| 72 | |
| 73 void UpdateAuthAttempts(const std::string& key, int32_t value) { | |
| 74 UMA_HISTOGRAM_CUSTOM_COUNTS(GetAuthHistogramName(key), value, 0 /* minimum */, | |
| 75 5 /* maximum */, 6 /* bucket_count */); | |
| 76 } | |
| 77 | |
| 54 void UpdateSilentAuthCodeUMA(OptInSilentAuthCode state) { | 78 void UpdateSilentAuthCodeUMA(OptInSilentAuthCode state) { |
| 55 UMA_HISTOGRAM_ENUMERATION("Arc.OptInSilentAuthCode", static_cast<int>(state), | 79 UMA_HISTOGRAM_ENUMERATION("Arc.OptInSilentAuthCode", static_cast<int>(state), |
| 56 static_cast<int>(OptInSilentAuthCode::SIZE)); | 80 static_cast<int>(OptInSilentAuthCode::SIZE)); |
| 57 } | 81 } |
| 58 | 82 |
| 59 std::ostream& operator<<(std::ostream& os, const ProvisioningResult& result) { | 83 std::ostream& operator<<(std::ostream& os, const ProvisioningResult& result) { |
| 60 #define MAP_PROVISIONING_RESULT(name) \ | 84 #define MAP_PROVISIONING_RESULT(name) \ |
| 61 case ProvisioningResult::name: \ | 85 case ProvisioningResult::name: \ |
| 62 return os << #name | 86 return os << #name |
| 63 | 87 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 86 | 110 |
| 87 #undef MAP_PROVISIONING_RESULT | 111 #undef MAP_PROVISIONING_RESULT |
| 88 | 112 |
| 89 // Some compilers report an error even if all values of an enum-class are | 113 // Some compilers report an error even if all values of an enum-class are |
| 90 // covered exhaustively in a switch statement. | 114 // covered exhaustively in a switch statement. |
| 91 NOTREACHED() << "Invalid value " << static_cast<int>(result); | 115 NOTREACHED() << "Invalid value " << static_cast<int>(result); |
| 92 return os; | 116 return os; |
| 93 } | 117 } |
| 94 | 118 |
| 95 } // namespace arc | 119 } // namespace arc |
| OLD | NEW |