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

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: Rebase and added further page isolation logic 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
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 static VRDevice* GetAllowedDevice(VRServiceImpl* service, unsigned int index);
37
35 // Adds a listener for device manager events. VRDeviceManager does not own 38 // Adds a listener for device manager events. VRDeviceManager does not own
36 // this object. 39 // this object.
37 void AddService(VRServiceImpl* service); 40 void AddService(VRServiceImpl* service);
38 void RemoveService(VRServiceImpl* service); 41 void RemoveService(VRServiceImpl* service);
39 42
40 DEVICE_VR_EXPORT mojo::Array<VRDisplayPtr> GetVRDevices(); 43 DEVICE_VR_EXPORT mojo::Array<VRDisplayPtr> GetVRDevices();
41 DEVICE_VR_EXPORT VRDevice* GetDevice(unsigned int index);
42 44
45 // Manage presentation to only allow a single service and device at a time.
46 bool RequestPresent(VRServiceImpl* service, unsigned int index);
47 void ExitPresent(VRServiceImpl* service, unsigned int index);
48 void SubmitFrame(VRServiceImpl* service, unsigned int index, VRPosePtr pose);
49
50 // VRClientDispatcher implementation
43 void OnDeviceChanged(VRDisplayPtr device) override; 51 void OnDeviceChanged(VRDisplayPtr device) override;
44 52
45 private: 53 private:
46 friend class VRDeviceManagerTest; 54 friend class VRDeviceManagerTest;
47 friend class VRServiceImplTest; 55 friend class VRServiceImplTest;
48 56
49 VRDeviceManager(); 57 VRDeviceManager();
50 // Constructor for testing. 58 // Constructor for testing.
51 DEVICE_VR_EXPORT explicit VRDeviceManager( 59 DEVICE_VR_EXPORT explicit VRDeviceManager(
52 std::unique_ptr<VRDeviceProvider> provider); 60 std::unique_ptr<VRDeviceProvider> provider);
53 61
62 VRDevice* GetDevice(unsigned int index);
63
54 static void SetInstance(VRDeviceManager* service); 64 static void SetInstance(VRDeviceManager* service);
55 static bool HasInstance(); 65 static bool HasInstance();
56 66
57 void InitializeProviders(); 67 void InitializeProviders();
58 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider); 68 void RegisterProvider(std::unique_ptr<VRDeviceProvider> provider);
59 69
60 void SchedulePollEvents(); 70 void SchedulePollEvents();
61 void PollEvents(); 71 void PollEvents();
62 void StopSchedulingPollEvents(); 72 void StopSchedulingPollEvents();
63 73
64 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>; 74 using ProviderList = std::vector<linked_ptr<VRDeviceProvider>>;
65 ProviderList providers_; 75 ProviderList providers_;
66 76
67 // Devices are owned by their providers. 77 // Devices are owned by their providers.
68 using DeviceMap = std::map<unsigned int, VRDevice*>; 78 using DeviceMap = std::map<unsigned int, VRDevice*>;
69 DeviceMap devices_; 79 DeviceMap devices_;
70 80
71 bool vr_initialized_; 81 bool vr_initialized_;
72 82
73 using ServiceList = std::vector<VRServiceImpl*>; 83 using ServiceList = std::vector<VRServiceImpl*>;
74 ServiceList services_; 84 ServiceList services_;
75 85
86 // Only one service and device is allowed to present at a time.
87 VRServiceImpl* presenting_service_;
88 VRDevice* presenting_device_;
89
76 // For testing. If true will not delete self when consumer count reaches 0. 90 // For testing. If true will not delete self when consumer count reaches 0.
77 bool keep_alive_; 91 bool keep_alive_;
78 92
79 bool has_scheduled_poll_; 93 bool has_scheduled_poll_;
80 94
81 base::ThreadChecker thread_checker_; 95 base::ThreadChecker thread_checker_;
82 96
83 base::RepeatingTimer timer_; 97 base::RepeatingTimer timer_;
84 98
85 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager); 99 DISALLOW_COPY_AND_ASSIGN(VRDeviceManager);
86 }; 100 };
87 101
88 } // namespace content 102 } // namespace content
89 103
90 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H 104 #endif // CONTENT_BROWSER_VR_VR_DEVICE_MANAGER_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698