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 #include "wtf/PassOwnPtr.h" |
13 | 14 |
14 namespace blink { | 15 namespace blink { |
15 | 16 |
17 class ServiceRegistry; | |
18 class VRGetDevicesCallback; | |
19 | |
16 class MODULES_EXPORT VRController final | 20 class MODULES_EXPORT VRController final |
17 : public GarbageCollectedFinalized<VRController> | 21 : public GarbageCollectedFinalized<VRController> |
18 , public Supplement<LocalFrame> | 22 , public Supplement<LocalFrame> |
19 , public LocalFrameLifecycleObserver { | 23 , public LocalFrameLifecycleObserver { |
20 USING_GARBAGE_COLLECTED_MIXIN(VRController); | 24 USING_GARBAGE_COLLECTED_MIXIN(VRController); |
21 WTF_MAKE_NONCOPYABLE(VRController); | 25 WTF_MAKE_NONCOPYABLE(VRController); |
22 public: | 26 public: |
23 virtual ~VRController(); | 27 virtual ~VRController(); |
24 | 28 |
25 void getDevices(WebVRGetDevicesCallback*); | 29 void getDevices(PassOwnPtr<VRGetDevicesCallback>); |
dcheng
2016/04/28 19:59:44
Use std::unique_ptr in new code, here and elsewher
RaviKasibhatla
2016/04/29 14:49:05
IIRC, @yutak recently sent a broadcast that the tr
dcheng
2016/04/29 17:28:11
No, new code should just use std::unique_ptr. It w
RaviKasibhatla
2016/05/03 14:34:21
Done.
| |
26 | 30 |
27 void getSensorState(unsigned index, WebHMDSensorState& into); | 31 void getSensorState(unsigned index, WebHMDSensorState& into); |
28 | 32 |
29 void resetSensor(unsigned index); | 33 void resetSensor(unsigned index); |
30 | 34 |
31 static void provideTo(LocalFrame&, WebVRClient*); | 35 static void provideTo(LocalFrame&, ServiceRegistry*); |
32 static VRController* from(LocalFrame&); | 36 static VRController* from(LocalFrame&); |
33 static const char* supplementName(); | 37 static const char* supplementName(); |
34 | 38 |
35 DECLARE_VIRTUAL_TRACE(); | 39 DECLARE_VIRTUAL_TRACE(); |
36 | 40 |
37 private: | 41 private: |
38 VRController(LocalFrame&, WebVRClient*); | 42 VRController(LocalFrame&, ServiceRegistry*); |
39 | 43 |
40 // Inherited from LocalFrameLifecycleObserver. | 44 // Inherited from LocalFrameLifecycleObserver. |
41 void willDetachFrameHost() override; | 45 void willDetachFrameHost() override; |
42 | 46 |
43 WebVRClient* m_client; | 47 // Binding callbacks. |
48 void OnGetDevices(const mojo::Array<mojom::VRDeviceInfoPtr>&); | |
49 void OnGetSensorState(const mojom::VRSensorStatePtr&); | |
50 | |
51 WTF::Deque<OwnPtr<VRGetDevicesCallback>> m_pendingGetDevicesCallbacks; | |
52 // SensorState is returned synchronously. No need for storing multiple reque sts. | |
53 WebHMDSensorState* m_pendingSensorStateRequest; | |
haraken
2016/04/28 14:50:03
Why does this need to be a pointer?
RaviKasibhatla
2016/04/28 18:08:33
getSensorState() passes a reference to WebHMDSenso
haraken
2016/04/28 19:16:15
How can the caller of getSensorState() know the ti
| |
54 mojom::VRServicePtr m_service; | |
44 }; | 55 }; |
45 | 56 |
46 } // namespace blink | 57 } // namespace blink |
47 | 58 |
48 #endif // VRController_h | 59 #endif // VRController_h |
OLD | NEW |