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

Side by Side Diff: device/vr/vr_device_manager.h

Issue 2329893002: Isolate a presenting VR device from pages other than the one presenting. (Closed)
Patch Set: Unit tests Created 4 years, 3 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
« no previous file with comments | « device/vr/vr_device.cc ('k') | device/vr/vr_device_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 DEVICE_VR_VR_DEVICE_MANAGER_H 5 #ifndef DEVICE_VR_VR_DEVICE_MANAGER_H
6 #define DEVICE_VR_VR_DEVICE_MANAGER_H 6 #define DEVICE_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
25 25
26 namespace device { 26 namespace device {
27 27
28 class VRDeviceManager : public VRClientDispatcher { 28 class VRDeviceManager : public VRClientDispatcher {
29 public: 29 public:
30 DEVICE_VR_EXPORT virtual ~VRDeviceManager(); 30 DEVICE_VR_EXPORT virtual ~VRDeviceManager();
31 31
32 // Returns the VRDeviceManager singleton. 32 // Returns the VRDeviceManager singleton.
33 static VRDeviceManager* GetInstance(); 33 static VRDeviceManager* GetInstance();
34 34
35 // Gets a VRDevice instance if the specified service is allowed to access it.
36 DEVICE_VR_EXPORT static VRDevice* GetAllowedDevice(VRServiceImpl* service,
37 unsigned int index);
38
35 // Adds a listener for device manager events. VRDeviceManager does not own 39 // Adds a listener for device manager events. VRDeviceManager does not own
36 // this object. 40 // this object.
37 void AddService(VRServiceImpl* service); 41 void AddService(VRServiceImpl* service);
38 void RemoveService(VRServiceImpl* service); 42 void RemoveService(VRServiceImpl* service);
39 43
40 DEVICE_VR_EXPORT mojo::Array<VRDisplayPtr> GetVRDevices(); 44 DEVICE_VR_EXPORT mojo::Array<VRDisplayPtr> GetVRDevices();
41 DEVICE_VR_EXPORT VRDevice* GetDevice(unsigned int index);
42 45
46 // Manage presentation to only allow a single service and device at a time.
47 DEVICE_VR_EXPORT bool RequestPresent(VRServiceImpl* service,
48 unsigned int index);
49 DEVICE_VR_EXPORT void ExitPresent(VRServiceImpl* service, unsigned int index);
50 void SubmitFrame(VRServiceImpl* service, unsigned int index, VRPosePtr pose);
51
52 // VRClientDispatcher implementation
43 void OnDeviceChanged(VRDisplayPtr device) override; 53 void OnDeviceChanged(VRDisplayPtr device) override;
44 54
45 private: 55 private:
46 friend class VRDeviceManagerTest; 56 friend class VRDeviceManagerTest;
47 friend class VRServiceImplTest; 57 friend class VRServiceImplTest;
48 58
49 VRDeviceManager(); 59 VRDeviceManager();
50 // Constructor for testing. 60 // Constructor for testing.
51 DEVICE_VR_EXPORT explicit VRDeviceManager( 61 DEVICE_VR_EXPORT explicit VRDeviceManager(
52 std::unique_ptr<VRDeviceProvider> provider); 62 std::unique_ptr<VRDeviceProvider> provider);
53 63
64 DEVICE_VR_EXPORT VRDevice* GetDevice(unsigned int index);
65
54 static void SetInstance(VRDeviceManager* service); 66 static void SetInstance(VRDeviceManager* service);
55 static bool HasInstance(); 67 static bool HasInstance();
56 68
57 void InitializeProviders(); 69 void InitializeProviders();
58 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider); 70 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider);
59 71
60 void SchedulePollEvents(); 72 void SchedulePollEvents();
61 void PollEvents(); 73 void PollEvents();
62 void StopSchedulingPollEvents(); 74 void StopSchedulingPollEvents();
63 75
64 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; 76 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>;
65 ProviderList providers_; 77 ProviderList providers_;
66 78
67 // Devices are owned by their providers. 79 // Devices are owned by their providers.
68 using DeviceMap = std::map<unsigned int, VRDevice*>; 80 using DeviceMap = std::map<unsigned int, VRDevice*>;
69 DeviceMap devices_; 81 DeviceMap devices_;
70 82
71 bool vr_initialized_; 83 bool vr_initialized_;
72 84
73 using ServiceList = std::vector<VRServiceImpl*>; 85 using ServiceList = std::vector<VRServiceImpl*>;
74 ServiceList services_; 86 ServiceList services_;
75 87
88 // Only one service and device is allowed to present at a time.
89 VRServiceImpl* presenting_service_;
90 VRDevice* presenting_device_;
91
76 // For testing. If true will not delete self when consumer count reaches 0. 92 // For testing. If true will not delete self when consumer count reaches 0.
77 bool keep_alive_; 93 bool keep_alive_;
78 94
79 bool has_scheduled_poll_; 95 bool has_scheduled_poll_;
80 96
81 base::ThreadChecker thread_checker_; 97 base::ThreadChecker thread_checker_;
82 98
83 base::RepeatingTimer timer_; 99 base::RepeatingTimer timer_;
84 100
85 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); 101 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager);
86 }; 102 };
87 103
88 } // namespace content 104 } // namespace content
89 105
90 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H 106 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
OLDNEW
« no previous file with comments | « device/vr/vr_device.cc ('k') | device/vr/vr_device_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698