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

Side by Side Diff: chrome/browser/android/vr_shell/vr_shell_delegate.cc

Issue 2506853002: Fix double-deletion of VR Shell when exiting webVR in onPause. (Closed)
Patch Set: rebase Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/android/vr_shell/vr_shell_delegate.h" 5 #include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "chrome/browser/android/vr_shell/vr_shell.h" 8 #include "chrome/browser/android/vr_shell/vr_shell.h"
9 #include "device/vr/android/gvr/gvr_device_provider.h" 9 #include "device/vr/android/gvr/gvr_device_provider.h"
10 #include "jni/VrShellDelegate_jni.h" 10 #include "jni/VrShellDelegate_jni.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 VrShellDelegate* VrShellDelegate::GetNativeDelegate( 56 VrShellDelegate* VrShellDelegate::GetNativeDelegate(
57 JNIEnv* env, jobject jdelegate) { 57 JNIEnv* env, jobject jdelegate) {
58 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate); 58 long native_delegate = Java_VrShellDelegate_getNativePointer(env, jdelegate);
59 return reinterpret_cast<VrShellDelegate*>(native_delegate); 59 return reinterpret_cast<VrShellDelegate*>(native_delegate);
60 } 60 }
61 61
62 base::WeakPtr<device::GvrDeviceProvider> VrShellDelegate::GetDeviceProvider() { 62 base::WeakPtr<device::GvrDeviceProvider> VrShellDelegate::GetDeviceProvider() {
63 return device_provider_; 63 return device_provider_;
64 } 64 }
65 65
66 void VrShellDelegate::ExitWebVRIfNecessary(JNIEnv* env, jobject obj) {
67 if (!device_provider_)
68 return;
69
70 device_provider_->OnGvrDelegateRemoved();
71 }
72
73 bool VrShellDelegate::RequestWebVRPresent( 66 bool VrShellDelegate::RequestWebVRPresent(
74 base::WeakPtr<device::GvrDeviceProvider> device_provider) { 67 base::WeakPtr<device::GvrDeviceProvider> device_provider) {
75 // Only set one device provider at a time 68 // Only set one device provider at a time
76 DCHECK(!device_provider_); 69 DCHECK(!device_provider_);
77 device_provider_ = device_provider; 70 device_provider_ = device_provider;
78 71
79 // If/When VRShell is ready for use it will call OnVrShellReady. 72 // If/When VRShell is ready for use it will call OnVrShellReady.
80 JNIEnv* env = AttachCurrentThread(); 73 JNIEnv* env = AttachCurrentThread();
81 Java_VrShellDelegate_enterVRIfNecessary(env, j_vr_shell_delegate_.obj(), 74 Java_VrShellDelegate_enterVRIfNecessary(env, j_vr_shell_delegate_.obj(),
82 true); 75 true);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 114
122 bool RegisterVrShellDelegate(JNIEnv* env) { 115 bool RegisterVrShellDelegate(JNIEnv* env) {
123 return RegisterNativesImpl(env); 116 return RegisterNativesImpl(env);
124 } 117 }
125 118
126 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { 119 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) {
127 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); 120 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj));
128 } 121 }
129 122
130 } // namespace vr_shell 123 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698