Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/android/vr_shell/vr_metrics_util.h" | |
| 6 | |
| 7 #include "base/metrics/histogram_macros.h" | |
| 8 | |
| 9 static constexpr int kVersionEncodingError = -4; | |
| 10 static constexpr int kVrNotSupported = -3; | |
| 11 static constexpr int kGvrNotInstalled = -2; | |
| 12 static constexpr int kGvrTooOld = -1; | |
| 13 | |
| 14 namespace vr_shell { | |
| 15 | |
| 16 bool VrMetricsUtil::has_logged_vr_runtime_version_ = false; | |
| 17 | |
| 18 void VrMetricsUtil::LogGvrVersionForVrViewerType( | |
| 19 gvr_context* context, | |
| 20 const VrCoreInfo& vr_core_info) { | |
| 21 if (has_logged_vr_runtime_version_) { | |
| 22 return; | |
| 23 } | |
| 24 | |
| 25 ViewerType vr_viewer_type = | |
| 26 context ? GetVrViewerType(context) : ViewerType::UNKNOWN_TYPE; | |
| 27 std::string histogram_name; | |
| 28 switch (vr_viewer_type) { | |
| 29 case ViewerType::CARDBOARD: | |
| 30 histogram_name = "VRRuntimeVersion.GVR.Cardboard"; | |
| 31 break; | |
| 32 case ViewerType::DAYDREAM: | |
| 33 histogram_name = "VRRuntimeVersion.GVR.Daydream"; | |
| 34 break; | |
| 35 default: | |
| 36 histogram_name = "VRRuntimeVersion.GVR.Unknown"; | |
| 37 break; | |
| 38 } | |
| 39 | |
| 40 uint32_t encoded_version = kVersionEncodingError; | |
| 41 switch (vr_core_info.compatibility) { | |
| 42 case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_NOT_SUPPORTED: | |
| 43 encoded_version = kVrNotSupported; | |
| 44 break; | |
| 45 case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_NOT_AVAILABLE: | |
| 46 encoded_version = kGvrNotInstalled; | |
| 47 break; | |
| 48 case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_OUT_OF_DATE: | |
| 49 if (vr_core_info.gvr_version.major == 0 && | |
| 50 vr_core_info.gvr_version.minor == 0 && | |
| 51 vr_core_info.gvr_version.patch == 0) { | |
| 52 encoded_version = kGvrTooOld; | |
| 53 break; | |
| 54 } | |
| 55 // We fall through to | |
|
ddorwin
2017/05/25 16:42:26
We generally avoid "we" in comments, especially in
tiborg
2017/05/25 21:41:42
Done.
| |
| 56 // VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_READY since we can log | |
|
ddorwin
2017/05/25 16:42:26
This should be indented with the above text. (I ho
tiborg
2017/05/25 21:41:42
Clang-format moved it into the next line. However,
| |
| 57 // a version in this case. | |
| 58 case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_READY: | |
| 59 encoded_version = | |
| 60 std::min(vr_core_info.gvr_version.major, 999) * 1000 * 1000 + | |
| 61 std::min(vr_core_info.gvr_version.minor, 999) * 1000 + | |
| 62 std::min(vr_core_info.gvr_version.patch, 999); | |
| 63 break; | |
| 64 } | |
| 65 | |
| 66 UMA_HISTOGRAM_SPARSE_SLOWLY(histogram_name.c_str(), encoded_version); | |
|
rkaplow
2017/05/25 20:57:27
since this is using macros this should actually be
tiborg
2017/05/25 21:41:42
Done.
| |
| 67 | |
| 68 has_logged_vr_runtime_version_ = true; | |
| 69 } | |
| 70 | |
| 71 void VrMetricsUtil::LogVrViewerType(gvr_context* context) { | |
| 72 UMA_HISTOGRAM_ENUMERATION("VRViewerType", | |
|
rkaplow
2017/05/25 20:57:27
add xml for this?
tiborg
2017/05/25 21:41:42
There already is an entry for this: https://cs.chr
| |
| 73 static_cast<int>(GetVrViewerType(context)), | |
| 74 static_cast<int>(ViewerType::VIEWER_TYPE_MAX)); | |
| 75 } | |
| 76 | |
| 77 ViewerType VrMetricsUtil::GetVrViewerType(gvr_context* context) { | |
| 78 auto gvr_api = gvr::GvrApi::WrapNonOwned(context); | |
| 79 switch (gvr_api->GetViewerType()) { | |
| 80 case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM: | |
| 81 return ViewerType::DAYDREAM; | |
| 82 case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD: | |
| 83 return ViewerType::CARDBOARD; | |
| 84 default: | |
| 85 NOTREACHED(); | |
| 86 return ViewerType::UNKNOWN_TYPE; | |
| 87 } | |
| 88 } | |
| 89 | |
| 90 } // namespace vr_shell | |
| OLD | NEW |