OLD | NEW |
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 #ifndef CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H | 5 #ifndef CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H |
6 #define CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H | 6 #define CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/linked_ptr.h" | 12 #include "base/memory/linked_ptr.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "content/browser/vr/vr_device.h" | 15 #include "content/browser/vr/vr_device.h" |
16 #include "content/browser/vr/vr_device_provider.h" | 16 #include "content/browser/vr/vr_device_provider.h" |
17 #include "content/common/content_export.h" | 17 #include "content/common/content_export.h" |
18 #include "content/common/vr_service.mojom.h" | 18 #include "content/common/vr_service.mojom.h" |
19 #include "mojo/common/weak_binding_set.h" | 19 #include "mojo/common/weak_binding_set.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 | 22 |
23 class VRDeviceManager : public VRService, public mojo::ErrorHandler { | 23 class VRDeviceManager : public VRService { |
24 public: | 24 public: |
25 ~VRDeviceManager() override; | 25 ~VRDeviceManager() override; |
26 | 26 |
27 static void BindRequest(mojo::InterfaceRequest<VRService> request); | 27 static void BindRequest(mojo::InterfaceRequest<VRService> request); |
28 | 28 |
29 // Returns the VRDeviceManager singleton. | 29 // Returns the VRDeviceManager singleton. |
30 static VRDeviceManager* GetInstance(); | 30 static VRDeviceManager* GetInstance(); |
31 | 31 |
32 mojo::Array<VRDeviceInfoPtr> GetVRDevices(); | 32 mojo::Array<VRDeviceInfoPtr> GetVRDevices(); |
33 VRDevice* GetDevice(unsigned int index); | 33 VRDevice* GetDevice(unsigned int index); |
(...skipping 10 matching lines...) Expand all Loading... |
44 | 44 |
45 void InitializeProviders(); | 45 void InitializeProviders(); |
46 void RegisterProvider(scoped_ptr<VRDeviceProvider> provider); | 46 void RegisterProvider(scoped_ptr<VRDeviceProvider> provider); |
47 | 47 |
48 // VRService implementation | 48 // VRService implementation |
49 void GetDevices(const GetDevicesCallback& callback) override; | 49 void GetDevices(const GetDevicesCallback& callback) override; |
50 void GetSensorState(uint32_t index, | 50 void GetSensorState(uint32_t index, |
51 const GetSensorStateCallback& callback) override; | 51 const GetSensorStateCallback& callback) override; |
52 void ResetSensor(uint32_t index) override; | 52 void ResetSensor(uint32_t index) override; |
53 | 53 |
54 // mojo::ErrorHandler implementation | 54 // Mojo connection error handler. |
55 void OnConnectionError() override; | 55 void OnConnectionError(); |
56 | 56 |
57 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; | 57 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; |
58 ProviderList providers_; | 58 ProviderList providers_; |
59 | 59 |
60 // Devices are owned by their providers. | 60 // Devices are owned by their providers. |
61 using DeviceMap = std::map<unsigned int, VRDevice*>; | 61 using DeviceMap = std::map<unsigned int, VRDevice*>; |
62 DeviceMap devices_; | 62 DeviceMap devices_; |
63 | 63 |
64 bool vr_initialized_; | 64 bool vr_initialized_; |
65 | 65 |
66 mojo::WeakBindingSet<VRService> bindings_; | 66 mojo::WeakBindingSet<VRService> bindings_; |
67 | 67 |
68 // For testing. If true will not delete self when consumer count reaches 0. | 68 // For testing. If true will not delete self when consumer count reaches 0. |
69 bool keep_alive_; | 69 bool keep_alive_; |
70 | 70 |
71 base::ThreadChecker thread_checker_; | 71 base::ThreadChecker thread_checker_; |
72 | 72 |
73 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); | 73 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); |
74 }; | 74 }; |
75 | 75 |
76 } // namespace content | 76 } // namespace content |
77 | 77 |
78 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H | 78 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H |
OLD | NEW |