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

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

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