Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Unified Diff: chrome/browser/android/vr_shell/vr_metrics_util.cc

Issue 2865463003: Tracks GVR version crossed with headset type using UMA. (Closed)
Patch Set: Nit: moved fallthrough comment out of else-block Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_metrics_util.cc
diff --git a/chrome/browser/android/vr_shell/vr_metrics_util.cc b/chrome/browser/android/vr_shell/vr_metrics_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..29db19e449e99aa761a7b557de6c5c1df9afcfae
--- /dev/null
+++ b/chrome/browser/android/vr_shell/vr_metrics_util.cc
@@ -0,0 +1,90 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/android/vr_shell/vr_metrics_util.h"
+
+#include "base/metrics/histogram_macros.h"
+
+static constexpr int kVersionEncodingError = -4;
+static constexpr int kVrNotSupported = -3;
+static constexpr int kGvrNotInstalled = -2;
+static constexpr int kGvrTooOld = -1;
+
+namespace vr_shell {
+
+bool VrMetricsUtil::has_logged_vr_runtime_version_ = false;
+
+void VrMetricsUtil::LogGvrVersionForVrViewerType(
+ gvr_context* context,
+ const VrCoreInfo& vr_core_info) {
+ if (has_logged_vr_runtime_version_) {
+ return;
+ }
+
+ ViewerType vr_viewer_type =
+ context ? GetVrViewerType(context) : ViewerType::UNKNOWN_TYPE;
+ std::string histogram_name;
+ switch (vr_viewer_type) {
+ case ViewerType::CARDBOARD:
+ histogram_name = "VRRuntimeVersion.GVR.Cardboard";
+ break;
+ case ViewerType::DAYDREAM:
+ histogram_name = "VRRuntimeVersion.GVR.Daydream";
+ break;
+ default:
+ histogram_name = "VRRuntimeVersion.GVR.Unknown";
+ break;
+ }
+
+ uint32_t encoded_version = kVersionEncodingError;
+ switch (vr_core_info.compatibility) {
+ case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_NOT_SUPPORTED:
+ encoded_version = kVrNotSupported;
+ break;
+ case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_NOT_AVAILABLE:
+ encoded_version = kGvrNotInstalled;
+ break;
+ case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_OUT_OF_DATE:
+ if (vr_core_info.gvr_version.major == 0 &&
+ vr_core_info.gvr_version.minor == 0 &&
+ vr_core_info.gvr_version.patch == 0) {
+ encoded_version = kGvrTooOld;
+ break;
+ }
+ // 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.
+ // 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,
+ // a version in this case.
+ case VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_READY:
+ encoded_version =
+ std::min(vr_core_info.gvr_version.major, 999) * 1000 * 1000 +
+ std::min(vr_core_info.gvr_version.minor, 999) * 1000 +
+ std::min(vr_core_info.gvr_version.patch, 999);
+ break;
+ }
+
+ 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.
+
+ has_logged_vr_runtime_version_ = true;
+}
+
+void VrMetricsUtil::LogVrViewerType(gvr_context* context) {
+ 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
+ static_cast<int>(GetVrViewerType(context)),
+ static_cast<int>(ViewerType::VIEWER_TYPE_MAX));
+}
+
+ViewerType VrMetricsUtil::GetVrViewerType(gvr_context* context) {
+ auto gvr_api = gvr::GvrApi::WrapNonOwned(context);
+ switch (gvr_api->GetViewerType()) {
+ case gvr::ViewerType::GVR_VIEWER_TYPE_DAYDREAM:
+ return ViewerType::DAYDREAM;
+ case gvr::ViewerType::GVR_VIEWER_TYPE_CARDBOARD:
+ return ViewerType::CARDBOARD;
+ default:
+ NOTREACHED();
+ return ViewerType::UNKNOWN_TYPE;
+ }
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698