| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/media/router/media_router_metrics.h" | 5 #include "chrome/browser/media/router/media_router_metrics.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #if !defined(OS_ANDROID) | |
| 10 #include "base/version.h" | |
| 11 #include "components/version_info/version_info.h" | |
| 12 #include "extensions/common/extension.h" | |
| 13 #endif // !defined(OS_ANDROID) | |
| 14 | 9 |
| 15 namespace media_router { | 10 namespace media_router { |
| 16 | 11 |
| 17 // static | 12 // static |
| 18 void MediaRouterMetrics::RecordMediaRouterDialogOrigin( | 13 void MediaRouterMetrics::RecordMediaRouterDialogOrigin( |
| 19 MediaRouterDialogOpenOrigin origin) { | 14 MediaRouterDialogOpenOrigin origin) { |
| 20 DCHECK_LT(static_cast<int>(origin), | 15 DCHECK_LT(static_cast<int>(origin), |
| 21 static_cast<int>(MediaRouterDialogOpenOrigin::TOTAL_COUNT)); | 16 static_cast<int>(MediaRouterDialogOpenOrigin::TOTAL_COUNT)); |
| 22 UMA_HISTOGRAM_ENUMERATION( | 17 UMA_HISTOGRAM_ENUMERATION( |
| 23 "MediaRouter.Icon.Click.Location", static_cast<int>(origin), | 18 "MediaRouter.Icon.Click.Location", static_cast<int>(origin), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 51 // static | 46 // static |
| 52 void MediaRouterMetrics::RecordRouteCreationOutcome( | 47 void MediaRouterMetrics::RecordRouteCreationOutcome( |
| 53 MediaRouterRouteCreationOutcome outcome) { | 48 MediaRouterRouteCreationOutcome outcome) { |
| 54 DCHECK_LT(static_cast<int>(outcome), | 49 DCHECK_LT(static_cast<int>(outcome), |
| 55 static_cast<int>(MediaRouterRouteCreationOutcome::TOTAL_COUNT)); | 50 static_cast<int>(MediaRouterRouteCreationOutcome::TOTAL_COUNT)); |
| 56 UMA_HISTOGRAM_ENUMERATION( | 51 UMA_HISTOGRAM_ENUMERATION( |
| 57 "MediaRouter.Route.CreationOutcome", static_cast<int>(outcome), | 52 "MediaRouter.Route.CreationOutcome", static_cast<int>(outcome), |
| 58 static_cast<int>(MediaRouterRouteCreationOutcome::TOTAL_COUNT)); | 53 static_cast<int>(MediaRouterRouteCreationOutcome::TOTAL_COUNT)); |
| 59 } | 54 } |
| 60 | 55 |
| 61 #if !defined(OS_ANDROID) | |
| 62 // static | |
| 63 void MediaRouterMetrics::RecordMediaRouteProviderWakeReason( | |
| 64 MediaRouteProviderWakeReason reason) { | |
| 65 DCHECK_LT(static_cast<int>(reason), | |
| 66 static_cast<int>(MediaRouteProviderWakeReason::TOTAL_COUNT)); | |
| 67 UMA_HISTOGRAM_ENUMERATION( | |
| 68 "MediaRouter.Provider.WakeReason", static_cast<int>(reason), | |
| 69 static_cast<int>(MediaRouteProviderWakeReason::TOTAL_COUNT)); | |
| 70 } | |
| 71 | |
| 72 // static | |
| 73 void MediaRouterMetrics::RecordMediaRouteProviderVersion( | |
| 74 const extensions::Extension& extension) { | |
| 75 MediaRouteProviderVersion version = MediaRouteProviderVersion::UNKNOWN; | |
| 76 const base::Version* extension_version = extension.version(); | |
| 77 if (extension_version) { | |
| 78 version = GetMediaRouteProviderVersion( | |
| 79 *extension_version, base::Version(version_info::GetVersionNumber())); | |
| 80 } | |
| 81 | |
| 82 DCHECK_LT(static_cast<int>(version), | |
| 83 static_cast<int>(MediaRouteProviderVersion::TOTAL_COUNT)); | |
| 84 UMA_HISTOGRAM_ENUMERATION( | |
| 85 "MediaRouter.Provider.Version", static_cast<int>(version), | |
| 86 static_cast<int>(MediaRouteProviderVersion::TOTAL_COUNT)); | |
| 87 } | |
| 88 | |
| 89 // static | |
| 90 void MediaRouterMetrics::RecordMediaRouteProviderWakeup( | |
| 91 MediaRouteProviderWakeup wakeup) { | |
| 92 DCHECK_LT(static_cast<int>(wakeup), | |
| 93 static_cast<int>(MediaRouteProviderWakeup::TOTAL_COUNT)); | |
| 94 UMA_HISTOGRAM_ENUMERATION( | |
| 95 "MediaRouter.Provider.Wakeup", static_cast<int>(wakeup), | |
| 96 static_cast<int>(MediaRouteProviderWakeup::TOTAL_COUNT)); | |
| 97 } | |
| 98 | |
| 99 // static | |
| 100 MediaRouteProviderVersion MediaRouterMetrics::GetMediaRouteProviderVersion( | |
| 101 const base::Version& extension_version, | |
| 102 const base::Version& browser_version) { | |
| 103 if (!extension_version.IsValid() || extension_version.components().empty() || | |
| 104 !browser_version.IsValid() || browser_version.components().empty()) { | |
| 105 return MediaRouteProviderVersion::UNKNOWN; | |
| 106 } | |
| 107 | |
| 108 uint32_t extension_major = extension_version.components()[0]; | |
| 109 uint32_t browser_major = browser_version.components()[0]; | |
| 110 // Sanity check. | |
| 111 if (extension_major == 0 || browser_major == 0) { | |
| 112 return MediaRouteProviderVersion::UNKNOWN; | |
| 113 } else if (extension_major >= browser_major) { | |
| 114 return MediaRouteProviderVersion::SAME_VERSION_AS_CHROME; | |
| 115 } else if (browser_major - extension_major == 1) { | |
| 116 return MediaRouteProviderVersion::ONE_VERSION_BEHIND_CHROME; | |
| 117 } else { | |
| 118 return MediaRouteProviderVersion::MULTIPLE_VERSIONS_BEHIND_CHROME; | |
| 119 } | |
| 120 } | |
| 121 #endif // !defined(OS_ANDROID) | |
| 122 | |
| 123 } // namespace media_router | 56 } // namespace media_router |
| OLD | NEW |