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

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

Issue 2570553004: Clean up some VrShell threading issues and remove unnecessary WeakPtr types. (Closed)
Patch Set: Created 4 years 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_
6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include "base/android/jni_weak_ref.h" 10 #include "base/android/jni_weak_ref.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "device/vr/android/gvr/gvr_delegate.h" 12 #include "device/vr/android/gvr/gvr_delegate.h"
13 13
14 namespace device { 14 namespace device {
15 class GvrDeviceProvider; 15 class GvrDeviceProvider;
16 } 16 }
17 17
18 namespace vr_shell { 18 namespace vr_shell {
19 19
20 class VrShellDelegate : public device::GvrDelegateProvider { 20 class VrShellDelegate : public device::GvrDelegateProvider {
21 public: 21 public:
22 VrShellDelegate(JNIEnv* env, jobject obj); 22 VrShellDelegate(JNIEnv* env, jobject obj);
23 virtual ~VrShellDelegate(); 23 virtual ~VrShellDelegate();
24 24
25 static VrShellDelegate* GetNativeDelegate(JNIEnv* env, jobject jdelegate); 25 static VrShellDelegate* GetNativeDelegate(JNIEnv* env, jobject jdelegate);
26 26
27 void SetDelegate(const base::WeakPtr<device::GvrDelegate>& delegate); 27 void SetDelegate(device::GvrDelegate* delegate);
28 void RemoveDelegate(); 28 void RemoveDelegate();
29 29
30 void SetPresentResult(JNIEnv* env, jobject obj, jboolean result); 30 void SetPresentResult(JNIEnv* env, jobject obj, jboolean result);
31 void DisplayActivate(JNIEnv* env, jobject obj); 31 void DisplayActivate(JNIEnv* env, jobject obj);
32 32
33 void ForceExitVr(); 33 void ForceExitVr();
34 device::GvrDeviceProvider* device_provider() { return device_provider_; }
34 35
35 // device::GvrDelegateProvider implementation 36 // device::GvrDelegateProvider implementation
36 void SetDeviceProvider( 37 void SetDeviceProvider(device::GvrDeviceProvider* device_provider) override;
37 base::WeakPtr<device::GvrDeviceProvider> device_provider) override;
38 void RequestWebVRPresent(const base::Callback<void(bool)>& callback) override; 38 void RequestWebVRPresent(const base::Callback<void(bool)>& callback) override;
39 void ExitWebVRPresent() override; 39 void ExitWebVRPresent() override;
40 base::WeakPtr<device::GvrDelegate> GetNonPresentingDelegate() override; 40 device::GvrDelegate* GetNonPresentingDelegate() override;
41 void DestroyNonPresentingDelegate() override; 41 void DestroyNonPresentingDelegate() override;
42 void SetListeningForActivate(bool listening) override; 42 void SetListeningForActivate(bool listening) override;
43 43
44 private: 44 private:
45 std::unique_ptr<device::GvrDelegate> non_presenting_delegate_; 45 std::unique_ptr<device::GvrDelegate> non_presenting_delegate_;
46 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_delegate_; 46 base::android::ScopedJavaGlobalRef<jobject> j_vr_shell_delegate_;
47 base::WeakPtr<device::GvrDeviceProvider> device_provider_; 47 device::GvrDeviceProvider* device_provider_ = nullptr;
48 base::WeakPtr<device::GvrDelegate> delegate_; 48 device::GvrDelegate* delegate_ = nullptr;
49 base::Callback<void(bool)> present_callback_; 49 base::Callback<void(bool)> present_callback_;
50 50
51 DISALLOW_COPY_AND_ASSIGN(VrShellDelegate); 51 DISALLOW_COPY_AND_ASSIGN(VrShellDelegate);
52 }; 52 };
53 53
54 bool RegisterVrShellDelegate(JNIEnv* env); 54 bool RegisterVrShellDelegate(JNIEnv* env);
55 55
56 } // namespace vr_shell 56 } // namespace vr_shell
57 57
58 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_ 58 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_SHELL_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698