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

Side by Side Diff: content/browser/vr/vr_device_manager.cc

Issue 1274913004: Revert of Android WebVR implementation, Cardboard 0.5.5 SDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 | « content/browser/vr/vr_device_manager.h ('k') | content/browser/vr/vr_device_provider.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/vr/vr_device_manager.h" 5 #include "content/browser/vr/vr_device_manager.h"
6 6
7 #include "base/bind.h"
8 #include "base/memory/singleton.h" 7 #include "base/memory/singleton.h"
9 #include "third_party/WebKit/public/platform/modules/vr/WebVR.h" 8 #include "third_party/WebKit/public/platform/modules/vr/WebVR.h"
10 9
11 #if defined(OS_ANDROID)
12 #include "content/browser/vr/android/cardboard/cardboard_vr_device_provider.h"
13 #endif
14
15 namespace content { 10 namespace content {
16 11
17 namespace { 12 namespace {
18 VRDeviceManager* g_vr_device_manager = nullptr; 13 VRDeviceManager* g_vr_device_manager = nullptr;
19 } 14 }
20 15
21 VRDeviceManager::VRDeviceManager() 16 VRDeviceManager::VRDeviceManager()
22 : vr_initialized_(false), keep_alive_(false) { 17 : vr_initialized_(false), keep_alive_(false) {
23 bindings_.set_connection_error_handler( 18 bindings_.set_error_handler(this);
24 base::Bind(&VRDeviceManager::OnConnectionError, base::Unretained(this)));
25 // Register VRDeviceProviders for the current platform 19 // Register VRDeviceProviders for the current platform
26 #if defined(OS_ANDROID)
27 scoped_ptr<VRDeviceProvider> cardboard_provider(
28 new CardboardVRDeviceProvider());
29 RegisterProvider(cardboard_provider.Pass());
30 #endif
31 } 20 }
32 21
33 VRDeviceManager::VRDeviceManager(scoped_ptr<VRDeviceProvider> provider) 22 VRDeviceManager::VRDeviceManager(scoped_ptr<VRDeviceProvider> provider)
34 : vr_initialized_(false), keep_alive_(true) { 23 : vr_initialized_(false), keep_alive_(true) {
35 thread_checker_.DetachFromThread(); 24 thread_checker_.DetachFromThread();
36 RegisterProvider(provider.Pass()); 25 RegisterProvider(provider.Pass());
37 SetInstance(this); 26 SetInstance(this);
38 } 27 }
39 28
40 VRDeviceManager::~VRDeviceManager() { 29 VRDeviceManager::~VRDeviceManager() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return !!g_vr_device_manager; 63 return !!g_vr_device_manager;
75 } 64 }
76 65
77 mojo::Array<VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() { 66 mojo::Array<VRDeviceInfoPtr> VRDeviceManager::GetVRDevices() {
78 DCHECK(thread_checker_.CalledOnValidThread()); 67 DCHECK(thread_checker_.CalledOnValidThread());
79 68
80 InitializeProviders(); 69 InitializeProviders();
81 70
82 std::vector<VRDevice*> devices; 71 std::vector<VRDevice*> devices;
83 for (const auto& provider : providers_) 72 for (const auto& provider : providers_)
84 provider->GetDevices(&devices); 73 provider->GetDevices(devices);
85 74
86 mojo::Array<VRDeviceInfoPtr> out_devices(0); 75 mojo::Array<VRDeviceInfoPtr> out_devices(0);
87 for (const auto& device : devices) { 76 for (const auto& device : devices) {
88 if (device->id() == VR_DEVICE_LAST_ID) 77 if (device->id() == VR_DEVICE_LAST_ID)
89 continue; 78 continue;
90 79
91 if (devices_.find(device->id()) == devices_.end()) 80 if (devices_.find(device->id()) == devices_.end())
92 devices_[device->id()] = device; 81 devices_[device->id()] = device;
93 82
94 VRDeviceInfoPtr vr_device_info = device->GetVRDevice(); 83 VRDeviceInfoPtr vr_device_info = device->GetVRDevice();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 130 }
142 } 131 }
143 132
144 void VRDeviceManager::ResetSensor(uint32_t index) { 133 void VRDeviceManager::ResetSensor(uint32_t index) {
145 VRDevice* device = GetDevice(index); 134 VRDevice* device = GetDevice(index);
146 if (device) 135 if (device)
147 device->ResetSensor(); 136 device->ResetSensor();
148 } 137 }
149 138
150 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/vr/vr_device_manager.h ('k') | content/browser/vr/vr_device_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698