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

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

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Address comments 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 return; 55 return;
56 56
57 if (!vr_device_) { 57 if (!vr_device_) {
58 vr_device_.reset( 58 vr_device_.reset(
59 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate())); 59 new GvrDevice(this, delegate_provider->GetNonPresentingDelegate()));
60 client_->OnDeviceConnectionStatusChanged(vr_device_.get(), true); 60 client_->OnDeviceConnectionStatusChanged(vr_device_.get(), true);
61 } 61 }
62 } 62 }
63 63
64 bool GvrDeviceProvider::RequestPresent() { 64 bool GvrDeviceProvider::RequestPresent() {
65 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
65 device::GvrDelegateProvider* delegate_provider = 66 device::GvrDelegateProvider* delegate_provider =
66 device::GvrDelegateProvider::GetInstance(); 67 device::GvrDelegateProvider::GetInstance();
67 if (!delegate_provider) 68 if (!delegate_provider)
68 return false; 69 return false;
69 70
70 // RequestWebVRPresent is async as a render thread may be created. 71 // RequestWebVRPresent is async as a render thread may be created.
71 return delegate_provider->RequestWebVRPresent(this); 72 return delegate_provider->RequestWebVRPresent(this);
72 } 73 }
73 74
74 void GvrDeviceProvider::ExitPresent() { 75 void GvrDeviceProvider::ExitPresent() {
(...skipping 13 matching lines...) Expand all
88 GAMEPAD_SOURCE_GVR); 89 GAMEPAD_SOURCE_GVR);
89 90
90 delegate_provider->ExitWebVRPresent(); 91 delegate_provider->ExitWebVRPresent();
91 92
92 if (client_) 93 if (client_)
93 client_->OnPresentEnded(vr_device_.get()); 94 client_->OnPresentEnded(vr_device_.get());
94 } 95 }
95 96
96 void GvrDeviceProvider::OnGvrDelegateReady(GvrDelegate* delegate) { 97 void GvrDeviceProvider::OnGvrDelegateReady(GvrDelegate* delegate) {
97 main_thread_task_runner_->PostTask( 98 main_thread_task_runner_->PostTask(
98 FROM_HERE, 99 FROM_HERE, base::Bind(&GvrDeviceProvider::GvrDelegateReady, this,
99 base::Bind(&GvrDeviceProvider::GvrDelegateReady, base::Unretained(this), 100 base::Unretained(delegate)));
100 base::Unretained(delegate)));
101 } 101 }
102 102
103 void GvrDeviceProvider::OnGvrDelegateRemoved() { 103 void GvrDeviceProvider::OnGvrDelegateRemoved() {
104 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 104 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
105 if (!vr_device_) 105 if (!vr_device_)
106 return; 106 return;
107 ExitPresent(); 107 ExitPresent();
108 } 108 }
109 109
110 void GvrDeviceProvider::OnDisplayBlur() {
111 if (!main_thread_task_runner_->BelongsToCurrentThread()) {
112 main_thread_task_runner_->PostTask(
113 FROM_HERE, base::Bind(&GvrDeviceProvider::OnDisplayBlur, this));
114 return;
115 }
116 if (client_)
117 client_->OnDisplayBlur(vr_device_.get());
118 }
119
120 void GvrDeviceProvider::OnDisplayFocus() {
121 if (!main_thread_task_runner_->BelongsToCurrentThread()) {
122 main_thread_task_runner_->PostTask(
123 FROM_HERE, base::Bind(&GvrDeviceProvider::OnDisplayFocus, this));
124 return;
125 }
126 if (client_)
127 client_->OnDisplayFocus(vr_device_.get());
128 }
129
110 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) { 130 void GvrDeviceProvider::GvrDelegateReady(GvrDelegate* delegate) {
111 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); 131 DCHECK(main_thread_task_runner_->BelongsToCurrentThread());
112 132
113 vr_device_->SetDelegate(delegate); 133 vr_device_->SetDelegate(delegate);
114 GamepadDataFetcherManager::GetInstance()->AddFactory( 134 GamepadDataFetcherManager::GetInstance()->AddFactory(
115 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id())); 135 new GvrGamepadDataFetcher::Factory(delegate, vr_device_->id()));
116 } 136 }
117 137
118 } // namespace device 138 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698