Index: chrome/browser/android/vr_shell/vr_shell_delegate.cc |
diff --git a/chrome/browser/android/vr_shell/vr_shell_delegate.cc b/chrome/browser/android/vr_shell/vr_shell_delegate.cc |
index 6440fd0179783da1ff76b152e8fa2d3cbc34081c..bf71fc8c2c38cf522ae6f5335cc84ab3ca8ba0cb 100644 |
--- a/chrome/browser/android/vr_shell/vr_shell_delegate.cc |
+++ b/chrome/browser/android/vr_shell/vr_shell_delegate.cc |
@@ -9,6 +9,7 @@ |
#include "base/android/jni_android.h" |
#include "base/callback_helpers.h" |
#include "chrome/browser/android/vr_shell/non_presenting_gvr_delegate.h" |
+#include "chrome/browser/android/vr_shell/vr_metrics_util.h" |
#include "device/vr/android/gvr/gvr_delegate.h" |
#include "device/vr/android/gvr/gvr_device.h" |
#include "device/vr/android/gvr/gvr_device_provider.h" |
@@ -16,6 +17,7 @@ |
using base::android::JavaParamRef; |
using base::android::AttachCurrentThread; |
+using base::android::ScopedJavaLocalRef; |
namespace vr_shell { |
@@ -38,8 +40,7 @@ VrShellDelegate::~VrShellDelegate() { |
device::GvrDelegateProvider* VrShellDelegate::CreateVrShellDelegate() { |
JNIEnv* env = AttachCurrentThread(); |
- base::android::ScopedJavaLocalRef<jobject> jdelegate = |
- Java_VrShellDelegate_getInstance(env); |
+ ScopedJavaLocalRef<jobject> jdelegate = Java_VrShellDelegate_getInstance(env); |
if (!jdelegate.is_null()) |
return GetNativeVrShellDelegate(env, jdelegate.obj()); |
return nullptr; |
@@ -56,9 +57,9 @@ void VrShellDelegate::SetPresentingDelegate( |
gvr_context* context) { |
presenting_delegate_ = delegate; |
// Clean up the non-presenting delegate. |
+ JNIEnv* env = AttachCurrentThread(); |
if (presenting_delegate_ && non_presenting_delegate_) { |
non_presenting_delegate_ = nullptr; |
- JNIEnv* env = AttachCurrentThread(); |
Java_VrShellDelegate_shutdownNonPresentingNativeContext( |
env, j_vr_shell_delegate_.obj()); |
} |
@@ -74,6 +75,9 @@ void VrShellDelegate::SetPresentingDelegate( |
base::ResetAndReturn(&present_callback_).Run(true); |
pending_successful_present_request_ = false; |
} |
+ |
+ auto vr_core_info = MakeVrCoreInfo(env); |
mthiesse
2017/05/24 05:47:26
nit: Only use auto when the type is apparent. I do
tiborg
2017/05/25 00:06:03
Done.
|
+ VrMetricsUtil::LogGvrVersionForVrViewerType(context, *vr_core_info); |
} |
void VrShellDelegate::RemoveDelegate() { |
@@ -197,6 +201,24 @@ void VrShellDelegate::ExitWebVRPresent() { |
} |
} |
+jlong VrShellDelegate::MakeNativeVrCoreInfo(JNIEnv* env, |
mthiesse
2017/05/24 05:47:26
I think you should move this function into (a new)
tiborg
2017/05/25 00:06:03
Done.
|
+ const JavaParamRef<jobject>& obj, |
+ jint major_version, |
+ jint minor_version, |
+ jint patch_version, |
+ jint compatibility) { |
+ return reinterpret_cast<intptr_t>( |
+ new VrCoreInfo(major_version, minor_version, patch_version, |
+ static_cast<VrCoreCompatibility>(compatibility))); |
+} |
+ |
+std::unique_ptr<VrCoreInfo> VrShellDelegate::MakeVrCoreInfo(JNIEnv* env) { |
+ std::unique_ptr<VrCoreInfo> vr_core_info = |
+ std::unique_ptr<VrCoreInfo>(reinterpret_cast<VrCoreInfo*>( |
mthiesse
2017/05/24 05:47:26
This is pretty confusing. I think you probably wan
tiborg
2017/05/25 00:06:03
Done.
|
+ Java_VrShellDelegate_getVrCoreInfo(env, j_vr_shell_delegate_.obj()))); |
+ return vr_core_info; |
+} |
+ |
void VrShellDelegate::CreateNonPresentingDelegate() { |
JNIEnv* env = AttachCurrentThread(); |
gvr_context* context = reinterpret_cast<gvr_context*>( |
@@ -206,6 +228,8 @@ void VrShellDelegate::CreateNonPresentingDelegate() { |
base::MakeUnique<NonPresentingGvrDelegate>(context); |
non_presenting_delegate_->UpdateVSyncInterval(timebase_nanos_, |
interval_seconds_); |
+ auto vr_core_info = MakeVrCoreInfo(env); |
+ VrMetricsUtil::LogGvrVersionForVrViewerType(context, *vr_core_info); |
} |
void VrShellDelegate::OnActivateDisplayHandled(bool present_requested) { |