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

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

Issue 2742083002: Revert of Re-land WebVR compositor bypass via BrowserMain context + mailbox (Closed)
Patch Set: Created 3 years, 9 months 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 15 matching lines...) Expand all
26 GvrDeviceProvider::~GvrDeviceProvider() { 26 GvrDeviceProvider::~GvrDeviceProvider() {
27 device::GvrDelegateProvider* delegate_provider = 27 device::GvrDelegateProvider* delegate_provider =
28 device::GvrDelegateProvider::GetInstance(); 28 device::GvrDelegateProvider::GetInstance();
29 if (delegate_provider) { 29 if (delegate_provider) {
30 delegate_provider->ExitWebVRPresent(); 30 delegate_provider->ExitWebVRPresent();
31 delegate_provider->ClearDeviceProvider(); 31 delegate_provider->ClearDeviceProvider();
32 } 32 }
33 } 33 }
34 34
35 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) { 35 void GvrDeviceProvider::GetDevices(std::vector<VRDevice*>* devices) {
36 devices->push_back(vr_device_.get()); 36 Initialize();
37 } 37 if (initialized_)
38 38 devices->push_back(vr_device_.get());
39 device::GvrDelegateProvider* GvrDeviceProvider::GetDelegateProvider() {
40 device::GvrDelegateProvider* provider =
41 device::GvrDelegateProvider::GetInstance();
42 Initialize(provider);
43 return provider;
44 } 39 }
45 40
46 void GvrDeviceProvider::Initialize() { 41 void GvrDeviceProvider::Initialize() {
47 // TODO(mthiesse): Clean up how we connect the GvrDelegateProvider to the 42 // TODO(mthiesse): Clean up how we connect the GvrDelegateProvider to the
48 // GvrDeviceProvider so we don't have to call this function multiple times. 43 // GvrDeviceProvider so we don't have to call this function multiple times.
49 // Ideally the DelegateProvider would always be available, and GetInstance() 44 // Ideally the DelegateProvider would always be available, and GetInstance()
50 // would create it. 45 // would create it.
51 Initialize(device::GvrDelegateProvider::GetInstance()); 46 if (initialized_)
52 }
53
54 void GvrDeviceProvider::Initialize(device::GvrDelegateProvider* provider) {
55 if (!provider)
56 return; 47 return;
57 provider->SetDeviceProvider(this); 48 device::GvrDelegateProvider* delegate_provider =
49 device::GvrDelegateProvider::GetInstance();
50 if (!delegate_provider)
51 return;
52 delegate_provider->SetDeviceProvider(this);
53 initialized_ = true;
58 } 54 }
59 55
60 void GvrDeviceProvider::RequestPresent( 56 void GvrDeviceProvider::RequestPresent(
61 mojom::VRSubmitFrameClientPtr submit_client,
62 const base::Callback<void(bool)>& callback) { 57 const base::Callback<void(bool)>& callback) {
63 device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); 58 Initialize();
59 device::GvrDelegateProvider* delegate_provider =
60 device::GvrDelegateProvider::GetInstance();
64 if (!delegate_provider) 61 if (!delegate_provider)
65 return callback.Run(false); 62 return callback.Run(false);
66 63
67 // RequestWebVRPresent is async as we may trigger a DON flow that pauses 64 // RequestWebVRPresent is async as we may trigger a DON flow that pauses
68 // Chrome. 65 // Chrome.
69 delegate_provider->RequestWebVRPresent(std::move(submit_client), callback); 66 delegate_provider->RequestWebVRPresent(callback);
70 } 67 }
71 68
72 // VR presentation exit requested by the API. 69 // VR presentation exit requested by the API.
73 void GvrDeviceProvider::ExitPresent() { 70 void GvrDeviceProvider::ExitPresent() {
74 device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); 71 Initialize();
72 GvrDelegateProvider* delegate_provider = GvrDelegateProvider::GetInstance();
75 if (delegate_provider) 73 if (delegate_provider)
76 delegate_provider->ExitWebVRPresent(); 74 delegate_provider->ExitWebVRPresent();
77 } 75 }
78 76
79 void GvrDeviceProvider::SetListeningForActivate(bool listening) { 77 void GvrDeviceProvider::SetListeningForActivate(bool listening) {
80 device::GvrDelegateProvider* delegate_provider = GetDelegateProvider(); 78 Initialize();
79 device::GvrDelegateProvider* delegate_provider =
80 device::GvrDelegateProvider::GetInstance();
81 if (!delegate_provider) 81 if (!delegate_provider)
82 return; 82 return;
83 83
84 delegate_provider->SetListeningForActivate(listening); 84 delegate_provider->SetListeningForActivate(listening);
85 } 85 }
86 86
87 } // namespace device 87 } // 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