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

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: Incorporated review feedback 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..2355a1c166c5b8463778d355a1b74491feb05d40
--- /dev/null
+++ b/chrome/browser/android/vr_shell/vr_metrics_util.cc
@@ -0,0 +1,91 @@
+// 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;
+ } else {
ddorwin 2017/05/25 05:14:12 I don't think you need to put it in an else block.
tiborg 2017/05/25 14:50:35 Done.
+ // We fall through to
+ // VrCoreCompatibility::VR_CORE_COMPATIBILITY_VR_READY since we can log
+ // 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);
+
+ has_logged_vr_runtime_version_ = true;
+}
+
+void VrMetricsUtil::LogVrViewerType(gvr_context* context) {
+ UMA_HISTOGRAM_ENUMERATION("VRViewerType",
+ 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