OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_VR_VR_SERVICE_H |
| 6 #define CONTENT_BROWSER_VR_VR_SERVICE_H |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <vector> |
| 11 |
| 12 #include "base/basictypes.h" |
| 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/threading/thread_checker.h" |
| 16 #include "content/browser/vr/vr_device.h" |
| 17 #include "content/browser/vr/vr_device_provider.h" |
| 18 #include "content/browser/vr/vr_service_consumer.h" |
| 19 #include "content/common/content_export.h" |
| 20 |
| 21 namespace blink { |
| 22 class WebVRDevice; |
| 23 } |
| 24 |
| 25 namespace content { |
| 26 |
| 27 class CONTENT_EXPORT VRService { |
| 28 public: |
| 29 virtual ~VRService(); |
| 30 |
| 31 // Returns the VRService singleton. |
| 32 static VRService* GetInstance(); |
| 33 |
| 34 void GetVRDevices(std::vector<blink::WebVRDevice>* webvr_devices); |
| 35 VRDevice* GetDevice(unsigned int index); |
| 36 |
| 37 private: |
| 38 friend class VRServiceTest; |
| 39 friend class VRServiceConsumer; |
| 40 |
| 41 VRService(); |
| 42 // Constructor for testing. |
| 43 explicit VRService(scoped_ptr<VRDeviceProvider> provider); |
| 44 |
| 45 static void SetInstance(VRService* service); |
| 46 static bool HasInstance(); |
| 47 static void AddConsumer(VRServiceConsumer* consumer); |
| 48 static void RemoveConsumer(VRServiceConsumer* consumer); |
| 49 |
| 50 void InitializeProviders(); |
| 51 |
| 52 void RegisterProvider(scoped_ptr<VRDeviceProvider> provider); |
| 53 |
| 54 typedef std::vector<linked_ptr<VRDeviceProvider>> ProviderList; |
| 55 ProviderList providers_; |
| 56 |
| 57 typedef std::map<unsigned int, VRDevice*> DeviceMap; |
| 58 DeviceMap devices_; |
| 59 |
| 60 bool vr_initialized_; |
| 61 |
| 62 typedef std::set<VRServiceConsumer*> ConsumerSet; |
| 63 ConsumerSet consumers_; |
| 64 // For testing. If true will not delete self when consumer count reaches 0. |
| 65 bool keep_alive_; |
| 66 |
| 67 base::ThreadChecker thread_checker_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(VRService); |
| 70 }; |
| 71 |
| 72 } // namespace content |
| 73 |
| 74 #endif // CONTENT_BROWSER_VR_VR_SERVICE_H |
OLD | NEW |