| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 class VRDeviceManager : public blink::mojom::VRService { | 25 class VRDeviceManager : public blink::mojom::VRService { |
| 26 public: | 26 public: |
| 27 ~VRDeviceManager() override; | 27 ~VRDeviceManager() override; |
| 28 | 28 |
| 29 static void BindRequest( | 29 static void BindRequest( |
| 30 mojo::InterfaceRequest<blink::mojom::VRService> request); | 30 mojo::InterfaceRequest<blink::mojom::VRService> request); |
| 31 | 31 |
| 32 // Returns the VRDeviceManager singleton. | 32 // Returns the VRDeviceManager singleton. |
| 33 static VRDeviceManager* GetInstance(); | 33 static VRDeviceManager* GetInstance(); |
| 34 | 34 |
| 35 mojo::Array<blink::mojom::VRDeviceInfoPtr> GetVRDevices(); | 35 mojo::Array<blink::mojom::VRDisplayPtr> GetVRDevices(); |
| 36 VRDevice* GetDevice(unsigned int index); | 36 VRDevice* GetDevice(unsigned int index); |
| 37 | 37 |
| 38 private: | 38 private: |
| 39 friend class VRDeviceManagerTest; | 39 friend class VRDeviceManagerTest; |
| 40 | 40 |
| 41 VRDeviceManager(); | 41 VRDeviceManager(); |
| 42 // Constructor for testing. | 42 // Constructor for testing. |
| 43 explicit VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider); | 43 explicit VRDeviceManager(std::unique_ptr<VRDeviceProvider> provider); |
| 44 | 44 |
| 45 static void SetInstance(VRDeviceManager* service); | 45 static void SetInstance(VRDeviceManager* service); |
| 46 static bool HasInstance(); | 46 static bool HasInstance(); |
| 47 | 47 |
| 48 void InitializeProviders(); | 48 void InitializeProviders(); |
| 49 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider); | 49 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider); |
| 50 | 50 |
| 51 // mojom::VRService implementation | 51 // mojom::VRService implementation |
| 52 void GetDevices(const GetDevicesCallback& callback) override; | 52 void GetDisplays(const GetDisplaysCallback& callback) override; |
| 53 void GetSensorState(uint32_t index, | 53 void GetPose(uint32_t index, |
| 54 const GetSensorStateCallback& callback) override; | 54 const GetPoseCallback& callback) override; |
| 55 void ResetSensor(uint32_t index) override; | 55 void ResetPose(uint32_t index) override; |
| 56 | 56 |
| 57 // Mojo connection error handler. | 57 // Mojo connection error handler. |
| 58 void OnConnectionError(); | 58 void OnConnectionError(); |
| 59 | 59 |
| 60 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; | 60 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; |
| 61 ProviderList providers_; | 61 ProviderList providers_; |
| 62 | 62 |
| 63 // Devices are owned by their providers. | 63 // Devices are owned by their providers. |
| 64 using DeviceMap = std::map<unsigned int, VRDevice*>; | 64 using DeviceMap = std::map<unsigned int, VRDevice*>; |
| 65 DeviceMap devices_; | 65 DeviceMap devices_; |
| 66 | 66 |
| 67 bool vr_initialized_; | 67 bool vr_initialized_; |
| 68 | 68 |
| 69 mojo::BindingSet<blink::mojom::VRService> bindings_; | 69 mojo::BindingSet<blink::mojom::VRService> bindings_; |
| 70 | 70 |
| 71 // For testing. If true will not delete self when consumer count reaches 0. | 71 // For testing. If true will not delete self when consumer count reaches 0. |
| 72 bool keep_alive_; | 72 bool keep_alive_; |
| 73 | 73 |
| 74 base::ThreadChecker thread_checker_; | 74 base::ThreadChecker thread_checker_; |
| 75 | 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); | 76 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // namespace content | 79 } // namespace content |
| 80 | 80 |
| 81 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H | 81 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H |
| OLD | NEW |