OLD | NEW |
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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (!context) | 97 if (!context) |
98 return nullptr; | 98 return nullptr; |
99 | 99 |
100 non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context)); | 100 non_presenting_delegate_.reset(new GvrNonPresentingDelegate(context)); |
101 } | 101 } |
102 return static_cast<GvrNonPresentingDelegate*>(non_presenting_delegate_.get()) | 102 return static_cast<GvrNonPresentingDelegate*>(non_presenting_delegate_.get()) |
103 ->GetWeakPtr(); | 103 ->GetWeakPtr(); |
104 } | 104 } |
105 | 105 |
106 void VrShellDelegate::DestroyNonPresentingDelegate() { | 106 void VrShellDelegate::DestroyNonPresentingDelegate() { |
107 non_presenting_delegate_.reset(nullptr); | 107 if (non_presenting_delegate_) { |
108 JNIEnv* env = AttachCurrentThread(); | 108 non_presenting_delegate_.reset(nullptr); |
109 Java_VrShellDelegate_shutdownNonPresentingNativeContext( | 109 JNIEnv* env = AttachCurrentThread(); |
110 env, j_vr_shell_delegate_.obj()); | 110 Java_VrShellDelegate_shutdownNonPresentingNativeContext( |
| 111 env, j_vr_shell_delegate_.obj()); |
| 112 } |
111 } | 113 } |
112 | 114 |
113 // ---------------------------------------------------------------------------- | 115 // ---------------------------------------------------------------------------- |
114 // Native JNI methods | 116 // Native JNI methods |
115 // ---------------------------------------------------------------------------- | 117 // ---------------------------------------------------------------------------- |
116 | 118 |
117 bool RegisterVrShellDelegate(JNIEnv* env) { | 119 bool RegisterVrShellDelegate(JNIEnv* env) { |
118 return RegisterNativesImpl(env); | 120 return RegisterNativesImpl(env); |
119 } | 121 } |
120 | 122 |
121 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { | 123 jlong Init(JNIEnv* env, const JavaParamRef<jobject>& obj) { |
122 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); | 124 return reinterpret_cast<intptr_t>(new VrShellDelegate(env, obj)); |
123 } | 125 } |
124 | 126 |
125 } // namespace vr_shell | 127 } // namespace vr_shell |
OLD | NEW |