Chromium Code Reviews| Index: content/browser/vr/vr_service.h |
| diff --git a/content/browser/vr/vr_service.h b/content/browser/vr/vr_service.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f4201b0688be050f7ec2a8555c73059a05071253 |
| --- /dev/null |
| +++ b/content/browser/vr/vr_service.h |
| @@ -0,0 +1,74 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_VR_VR_SERVICE_H |
| +#define CONTENT_BROWSER_VR_VR_SERVICE_H |
| + |
| +#include <map> |
| +#include <set> |
| +#include <vector> |
| + |
| +#include "base/basictypes.h" |
| +#include "base/memory/linked_ptr.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "content/browser/vr/vr_device.h" |
| +#include "content/browser/vr/vr_device_provider.h" |
| +#include "content/browser/vr/vr_service_consumer.h" |
| +#include "content/common/content_export.h" |
| + |
| +namespace blink { |
| +class WebVRDevice; |
| +} |
| + |
| +namespace content { |
| + |
| +class CONTENT_EXPORT VRService { |
|
mdempsky
2015/05/11 19:25:01
Are base::LazyInstance or Singleton not appropriat
bajones
2015/05/12 00:13:39
This was a Singleton in a previous patchset. sieve
|
| + public: |
| + virtual ~VRService(); |
| + |
| + // Returns the VRService singleton. |
| + static VRService* GetInstance(); |
| + |
| + void GetVRDevices(std::vector<blink::WebVRDevice>* webvr_devices); |
| + VRDevice* GetDevice(unsigned int index); |
| + |
| + private: |
| + friend class VRServiceTest; |
| + friend class VRServiceConsumer; |
| + |
| + VRService(); |
| + // Constructor for testing. |
| + explicit VRService(scoped_ptr<VRDeviceProvider> provider); |
| + |
| + static void SetInstance(VRService* service); |
| + static bool HasInstance(); |
| + static void AddConsumer(VRServiceConsumer* consumer); |
| + static void RemoveConsumer(VRServiceConsumer* consumer); |
| + |
| + void InitializeProviders(); |
| + |
| + void RegisterProvider(scoped_ptr<VRDeviceProvider> provider); |
| + |
| + typedef std::vector<linked_ptr<VRDeviceProvider>> ProviderList; |
|
mdempsky
2015/05/11 19:25:01
FYI: I believe Chromium style is to prefer "using
|
| + ProviderList providers_; |
| + |
| + typedef std::map<unsigned int, VRDevice*> DeviceMap; |
| + DeviceMap devices_; |
| + |
| + bool vr_initialized_; |
| + |
| + typedef std::set<VRServiceConsumer*> ConsumerSet; |
| + ConsumerSet consumers_; |
| + // For testing. If true will not delete self when consumer count reaches 0. |
| + bool keep_alive_; |
| + |
| + base::ThreadChecker thread_checker_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(VRService); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_VR_VR_SERVICE_H |