| 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_functions.h" | 9 #include "base/metrics/histogram_functions.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 | 11 |
| 12 namespace arc { | 12 namespace arc { |
| 13 | 13 |
| 14 namespace { |
| 15 |
| 16 std::string GetHistogramName(const std::string& base_name, bool managed) { |
| 17 return base_name + (managed ? "Managed" : "Unmanaged"); |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 14 void UpdateOptInActionUMA(OptInActionType type) { | 22 void UpdateOptInActionUMA(OptInActionType type) { |
| 15 UMA_HISTOGRAM_ENUMERATION("Arc.OptInAction", static_cast<int>(type), | 23 UMA_HISTOGRAM_ENUMERATION("Arc.OptInAction", static_cast<int>(type), |
| 16 static_cast<int>(OptInActionType::SIZE)); | 24 static_cast<int>(OptInActionType::SIZE)); |
| 17 } | 25 } |
| 18 | 26 |
| 19 void UpdateOptInCancelUMA(OptInCancelReason reason) { | 27 void UpdateOptInCancelUMA(OptInCancelReason reason) { |
| 20 UMA_HISTOGRAM_ENUMERATION("Arc.OptInCancel", static_cast<int>(reason), | 28 UMA_HISTOGRAM_ENUMERATION("Arc.OptInCancel", static_cast<int>(reason), |
| 21 static_cast<int>(OptInCancelReason::SIZE)); | 29 static_cast<int>(OptInCancelReason::SIZE)); |
| 22 } | 30 } |
| 23 | 31 |
| 24 void UpdateEnabledStateUMA(bool enabled) { | 32 void UpdateEnabledStateUMA(bool enabled) { |
| 25 UMA_HISTOGRAM_BOOLEAN("Arc.State", enabled); | 33 UMA_HISTOGRAM_BOOLEAN("Arc.State", enabled); |
| 26 } | 34 } |
| 27 | 35 |
| 28 void UpdateOptInFlowResultUMA(OptInFlowResult result) { | 36 void UpdateOptInFlowResultUMA(OptInFlowResult result) { |
| 29 UMA_HISTOGRAM_ENUMERATION("Arc.OptInResult", static_cast<int>(result), | 37 UMA_HISTOGRAM_ENUMERATION("Arc.OptInResult", static_cast<int>(result), |
| 30 static_cast<int>(OptInFlowResult::SIZE)); | 38 static_cast<int>(OptInFlowResult::SIZE)); |
| 31 } | 39 } |
| 32 | 40 |
| 33 void UpdateProvisioningResultUMA(ProvisioningResult result, bool managed) { | 41 void UpdateProvisioningResultUMA(ProvisioningResult result, bool managed) { |
| 34 DCHECK_NE(result, ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); | 42 DCHECK_NE(result, ProvisioningResult::CHROME_SERVER_COMMUNICATION_ERROR); |
| 35 std::string histogram_name = "Arc.Provisioning.Result."; | |
| 36 histogram_name += managed ? "Managed" : "Unmanaged"; | |
| 37 base::LinearHistogram::FactoryGet( | 43 base::LinearHistogram::FactoryGet( |
| 38 histogram_name, 0, static_cast<int>(ProvisioningResult::SIZE), | 44 GetHistogramName("Arc.Provisioning.Result.", managed), 0, |
| 45 static_cast<int>(ProvisioningResult::SIZE), |
| 39 static_cast<int>(ProvisioningResult::SIZE) + 1, | 46 static_cast<int>(ProvisioningResult::SIZE) + 1, |
| 40 base::HistogramBase::kUmaTargetedHistogramFlag) | 47 base::HistogramBase::kUmaTargetedHistogramFlag) |
| 41 ->Add(static_cast<int>(result)); | 48 ->Add(static_cast<int>(result)); |
| 42 } | 49 } |
| 43 | 50 |
| 44 void UpdateProvisioningTiming(const base::TimeDelta& elapsed_time, | 51 void UpdateProvisioningTiming(const base::TimeDelta& elapsed_time, |
| 45 bool success, | 52 bool success, |
| 46 bool managed) { | 53 bool managed) { |
| 47 std::string histogram_name = "Arc.Provisioning.TimeDelta."; | 54 std::string histogram_name = "Arc.Provisioning.TimeDelta."; |
| 48 histogram_name += success ? "Success." : "Failure."; | 55 histogram_name += success ? "Success." : "Failure."; |
| 49 histogram_name += managed ? "Managed" : "Unmanaged"; | |
| 50 // The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since | 56 // The macro UMA_HISTOGRAM_CUSTOM_TIMES expects a constant string, but since |
| 51 // this measurement happens very infrequently, we do not need to use a macro | 57 // this measurement happens very infrequently, we do not need to use a macro |
| 52 // here. | 58 // here. |
| 53 base::Histogram::FactoryTimeGet( | 59 base::UmaHistogramCustomTimes(GetHistogramName(histogram_name, managed), |
| 54 histogram_name, base::TimeDelta::FromSeconds(1), | 60 elapsed_time, base::TimeDelta::FromSeconds(1), |
| 55 base::TimeDelta::FromMinutes(6), 50, | 61 base::TimeDelta::FromMinutes(6), 50); |
| 56 base::HistogramBase::kUmaTargetedHistogramFlag) | 62 } |
| 57 ->AddTime(elapsed_time); | 63 |
| 64 void UpdatePlayStoreShowTime(const base::TimeDelta& elapsed_time, |
| 65 bool managed) { |
| 66 base::UmaHistogramCustomTimes( |
| 67 GetHistogramName("Arc.PlayStoreShown.TimeDelta.", managed), elapsed_time, |
| 68 base::TimeDelta::FromSeconds(1), base::TimeDelta::FromMinutes(10), 50); |
| 58 } | 69 } |
| 59 | 70 |
| 60 void UpdateAuthTiming(const char* histogram_name, | 71 void UpdateAuthTiming(const char* histogram_name, |
| 61 base::TimeDelta elapsed_time) { | 72 base::TimeDelta elapsed_time) { |
| 62 base::UmaHistogramCustomTimes(histogram_name, elapsed_time, | 73 base::UmaHistogramCustomTimes(histogram_name, elapsed_time, |
| 63 base::TimeDelta::FromSeconds(1) /* minimum */, | 74 base::TimeDelta::FromSeconds(1) /* minimum */, |
| 64 base::TimeDelta::FromMinutes(3) /* maximum */, | 75 base::TimeDelta::FromMinutes(3) /* maximum */, |
| 65 50 /* bucket_count */); | 76 50 /* bucket_count */); |
| 66 } | 77 } |
| 67 | 78 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 124 |
| 114 #undef MAP_PROVISIONING_RESULT | 125 #undef MAP_PROVISIONING_RESULT |
| 115 | 126 |
| 116 // Some compilers report an error even if all values of an enum-class are | 127 // Some compilers report an error even if all values of an enum-class are |
| 117 // covered exhaustively in a switch statement. | 128 // covered exhaustively in a switch statement. |
| 118 NOTREACHED() << "Invalid value " << static_cast<int>(result); | 129 NOTREACHED() << "Invalid value " << static_cast<int>(result); |
| 119 return os; | 130 return os; |
| 120 } | 131 } |
| 121 | 132 |
| 122 } // namespace arc | 133 } // namespace arc |
| OLD | NEW |