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

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

Issue 2494733002: Reland of mojo VR interface simpified. (Closed)
Patch Set: Fix Werror 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 25 matching lines...) Expand all
36 ExitPresent(); 36 ExitPresent();
37 } 37 }
38 38
39 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { 39 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
40 Initialize(); 40 Initialize();
41 41
42 if (vr_device_) 42 if (vr_device_)
43 devices->push_back(vr_device_.get()); 43 devices->push_back(vr_device_.get());
44 } 44 }
45 45
46 void GvrDeviceProvider::SetClient(VRClientDispatcher* client) {
47 if (!client_)
48 client_.reset(client);
49 }
50
51 void GvrDeviceProvider::Initialize() { 46 void GvrDeviceProvider::Initialize() {
52 device::GvrDelegateProvider* delegate_provider = 47 device::GvrDelegateProvider* delegate_provider =
53 device::GvrDelegateProvider::GetInstance(); 48 device::GvrDelegateProvider::GetInstance();
54 if (!delegate_provider) 49 if (!delegate_provider)
55 return; 50 return;
56 51
57 if (!vr_device_) { 52 if (!vr_device_) {
58 vr_device_.reset( 53 vr_device_.reset(
59 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate())); 54 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate()));
60 client_->OnDeviceConnectionStatusChanged(vr_device_.get(), true);
61 } 55 }
62 } 56 }
63 57
64 bool GvrDeviceProvider::RequestPresent() { 58 bool GvrDeviceProvider::RequestPresent() {
65 device::GvrDelegateProvider* delegate_provider = 59 device::GvrDelegateProvider* delegate_provider =
66 device::GvrDelegateProvider::GetInstance(); 60 device::GvrDelegateProvider::GetInstance();
67 if (!delegate_provider) 61 if (!delegate_provider)
68 return false; 62 return false;
69 63
70 // RequestWebVRPresent is async as a render thread may be created. 64 // RequestWebVRPresent is async as a render thread may be created.
(...skipping 10 matching lines...) Expand all
81 device::GvrDelegateProvider::GetInstance(); 75 device::GvrDelegateProvider::GetInstance();
82 if (!delegate_provider) 76 if (!delegate_provider)
83 return; 77 return;
84 78
85 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate()); 79 vr_device_->SetDelegate(delegate_provider->GetNonPresentingDelegate());
86 80
87 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory( 81 GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
88 GAMEPAD_SOURCE_GVR); 82 GAMEPAD_SOURCE_GVR);
89 83
90 delegate_provider->ExitWebVRPresent(); 84 delegate_provider->ExitWebVRPresent();
91
92 if (client_)
93 client_->OnPresentEnded(vr_device_.get());
94 } 85 }
95 86
96 void GvrDeviceProvider::OnGvrDelegateReady(GvrDelegate* delegate) { 87 void GvrDeviceProvider::OnGvrDelegateReady(GvrDelegate* delegate) {
97 main_thread_task_runner_->PostTask( 88 main_thread_task_runner_->PostTask(
98 FROM_HERE, 89 FROM_HERE,
99 base::Bind(&GvrDeviceProvider::GvrDelegateReady, base::Unretained(this), 90 base::Bind(&GvrDeviceProvider::GvrDelegateReady, base::Unretained(this),
100 base::Unretained(delegate))); 91 base::Unretained(delegate)));
101 } 92 }
102 93
103 void GvrDeviceProvider::OnGvrDelegateRemoved() { 94 void GvrDeviceProvider::OnGvrDelegateRemoved() {
104 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 95 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
105 if (!vr_device_) 96 if (!vr_device_)
106 return; 97 return;
107 ExitPresent(); 98 ExitPresent();
108 } 99 }
109 100
110 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) { 101 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) {
111 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 102 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
112 103
113 vr_device_->SetDelegate(delegate); 104 vr_device_->SetDelegate(delegate);
114 GamepadDataFetcherManager::GetInstance()->AddFactory( 105 GamepadDataFetcherManager::GetInstance()->AddFactory(
115 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id())); 106 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id()));
116 } 107 }
117 108
118 } // namespace device 109 } // 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