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

Side by Side Diff: device/vr/android/gvr/gvr_device_provider.cc

Issue 2510873003: Clean up WebVR RequestPresent and make callback asynchronous. (Closed)
Patch Set: Fix FakeVRDevice 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
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/vr/android/gvr/gvr_device_provider.h" 5 #include "device/vr/android/gvr/gvr_device_provider.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/context_utils.h" 9 #include "base/android/context_utils.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 device::GvrDelegateProvider::GetInstance(); 49 device::GvrDelegateProvider::GetInstance();
50 if (!delegate_provider) 50 if (!delegate_provider)
51 return; 51 return;
52 52
53 if (!vr_device_) { 53 if (!vr_device_) {
54 vr_device_.reset( 54 vr_device_.reset(
55 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate())); 55 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate()));
56 } 56 }
57 } 57 }
58 58
59 bool GvrDeviceProvider::RequestPresent() { 59 void GvrDeviceProvider::RequestPresent(
60 const base::Callback<void(bool)>& callback) {
60 device::GvrDelegateProvider* delegate_provider = 61 device::GvrDelegateProvider* delegate_provider =
61 device::GvrDelegateProvider::GetInstance(); 62 device::GvrDelegateProvider::GetInstance();
62 if (!delegate_provider) 63 if (!delegate_provider)
63 return false; 64 return callback.Run(false);
64 65
65 // RequestWebVRPresent is async as a render thread may be created. 66 // RequestWebVRPresent is async as a render thread may be created.
66 return delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr()); 67 delegate_provider->RequestWebVRPresent(weak_ptr_factory_.GetWeakPtr(),
68 callback);
67 } 69 }
68 70
69 // VR presentation exit requested by the API. 71 // VR presentation exit requested by the API.
70 void GvrDeviceProvider::ExitPresent() { 72 void GvrDeviceProvider::ExitPresent() {
71 SwitchToNonPresentingDelegate(); 73 SwitchToNonPresentingDelegate();
72 // If we're presenting currently stop. 74 // If we're presenting currently stop.
73 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance(); 75 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance();
74 if (delegate_provider) 76 if (delegate_provider)
75 delegate_provider->ExitWebVRPresent(); 77 delegate_provider->ExitWebVRPresent();
76 } 78 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return; 113 return;
112 114
113 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate()); 115 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate());
114 116
115 // Remove GVR gamepad polling. 117 // Remove GVR gamepad polling.
116 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( 118 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
117 GAMEPAD_SOURCE_GVR); 119 GAMEPAD_SOURCE_GVR);
118 } 120 }
119 121
120 } // namespace device 122 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_device_provider.h ('k') | device/vr/test/fake_vr_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698