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

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

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated to use Mojo as requested by eng review Created 5 years, 6 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
OLDNEW
(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_DEVICE_MANAGER_H
6 #define CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_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/common/content_export.h"
19 #include "content/common/vr_service.mojom.h"
20
21 namespace content {
22
23 class CONTENT_EXPORT VRDeviceManager {
24 public:
25 virtual ~VRDeviceManager();
26
27 // Returns the VRDeviceManager singleton.
28 static VRDeviceManager* GetInstance();
29
30 mojo::Array<VRDeviceInfoPtr> GetVRDevices();
31 VRDevice* GetDevice(unsigned int index);
32
33 static void AddService(mojo::InterfaceImpl<VRService>* consumer);
34 static void RemoveService(mojo::InterfaceImpl<VRService>* consumer);
35
36 private:
37 friend class VRDeviceManagerTest;
38
39 VRDeviceManager();
40 // Constructor for testing.
41 explicit VRDeviceManager(scoped_ptr<VRDeviceProvider> provider);
42
43 static void SetInstance(VRDeviceManager* service);
44 static bool HasInstance();
45
46 void InitializeProviders();
47
48 void RegisterProvider(scoped_ptr<VRDeviceProvider> provider);
49
50 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>;
51 ProviderList providers_;
52
53 using DeviceMap = std::map<unsigned int, VRDevice*>;
54 DeviceMap devices_;
55
56 bool vr_initialized_;
57
58 using ServiceSet = std::set<mojo::InterfaceImpl<VRService>*>;
59 ServiceSet services_;
60 // For testing. If true will not delete self when consumer count reaches 0.
61 bool keep_alive_;
62
63 base::ThreadChecker thread_checker_;
64
65 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager);
66 };
67
68 } // namespace content
69
70 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698