OLD | NEW |
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 VRController_h | 5 #ifndef VRController_h |
6 #define VRController_h | 6 #define VRController_h |
7 | 7 |
8 #include "core/frame/LocalFrameLifecycleObserver.h" | 8 #include "core/frame/LocalFrameLifecycleObserver.h" |
9 #include "modules/ModulesExport.h" | 9 #include "modules/ModulesExport.h" |
| 10 #include "modules/vr/VRTypeConverters.h" |
10 #include "platform/Supplementable.h" | 11 #include "platform/Supplementable.h" |
11 #include "public/platform/modules/vr/WebVR.h" | 12 #include "wtf/Deque.h" |
12 #include "public/platform/modules/vr/WebVRClient.h" | |
13 | 13 |
14 namespace blink { | 14 namespace blink { |
15 | 15 |
| 16 class ServiceRegistry; |
| 17 class VRGetDevicesCallback; |
| 18 |
16 class MODULES_EXPORT VRController final | 19 class MODULES_EXPORT VRController final |
17 : public GarbageCollectedFinalized<VRController> | 20 : public GarbageCollectedFinalized<VRController> |
18 , public Supplement<LocalFrame> | 21 , public Supplement<LocalFrame> |
19 , public LocalFrameLifecycleObserver { | 22 , public LocalFrameLifecycleObserver { |
20 USING_GARBAGE_COLLECTED_MIXIN(VRController); | 23 USING_GARBAGE_COLLECTED_MIXIN(VRController); |
21 WTF_MAKE_NONCOPYABLE(VRController); | 24 WTF_MAKE_NONCOPYABLE(VRController); |
22 public: | 25 public: |
23 virtual ~VRController(); | 26 virtual ~VRController(); |
24 | 27 |
25 void getDevices(WebVRGetDevicesCallback*); | 28 void getDevices(VRGetDevicesCallback*); |
26 | 29 |
27 void getSensorState(unsigned index, WebHMDSensorState& into); | 30 void getSensorState(unsigned index, WebHMDSensorState& into); |
28 | 31 |
29 void resetSensor(unsigned index); | 32 void resetSensor(unsigned index); |
30 | 33 |
31 static void provideTo(LocalFrame&, WebVRClient*); | 34 static void provideTo(LocalFrame&, ServiceRegistry*); |
32 static VRController* from(LocalFrame&); | 35 static VRController* from(LocalFrame&); |
33 static const char* supplementName(); | 36 static const char* supplementName(); |
34 | 37 |
35 DECLARE_VIRTUAL_TRACE(); | 38 DECLARE_VIRTUAL_TRACE(); |
36 | 39 |
37 private: | 40 private: |
38 VRController(LocalFrame&, WebVRClient*); | 41 VRController(LocalFrame&, ServiceRegistry*); |
39 | 42 |
40 // Inherited from LocalFrameLifecycleObserver. | 43 // Inherited from LocalFrameLifecycleObserver. |
41 void willDetachFrameHost() override; | 44 void willDetachFrameHost() override; |
42 | 45 |
43 WebVRClient* m_client; | 46 // Binding callbacks. |
| 47 void OnGetDevices(const mojo::Array<mojom::VRDeviceInfoPtr>&); |
| 48 void OnGetSensorState(const mojom::VRSensorStatePtr&); |
| 49 |
| 50 WTF::Deque<VRGetDevicesCallback*> m_pendingGetDevicesCallbacks; |
| 51 // SensorState is returned synchronously. No need for storing multiple reque
sts. |
| 52 WebHMDSensorState* m_pendingSensorStateRequest; |
| 53 mojom::VRServicePtr m_service; |
44 }; | 54 }; |
45 | 55 |
46 } // namespace blink | 56 } // namespace blink |
47 | 57 |
48 #endif // VRController_h | 58 #endif // VRController_h |
OLD | NEW |