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

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

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed tedchoc@'s feedback Created 5 years, 8 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_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 {
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
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;
mdempsky 2015/05/11 19:25:01 FYI: I believe Chromium style is to prefer "using
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698