| 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 "platform/Supplementable.h" | 10 #include "platform/Supplementable.h" |
| 11 #include "public/platform/WebCallbacks.h" |
| 12 #include "public/platform/WebVector.h" |
| 11 #include "public/platform/modules/vr/WebVR.h" | 13 #include "public/platform/modules/vr/WebVR.h" |
| 12 #include "public/platform/modules/vr/WebVRClient.h" | 14 #include "public/platform/modules/vr/vr_service.mojom-wtf.h" |
| 15 #include "wtf/Vector.h" |
| 13 | 16 |
| 14 namespace blink { | 17 namespace blink { |
| 15 | 18 |
| 19 class ServiceRegistry; |
| 20 |
| 21 // Success and failure callbacks for getDevices. |
| 22 using WebVRGetDevicesCallback = WebCallbacks<const WebVector<WebVRDevice>&, void
>; |
| 23 |
| 16 class MODULES_EXPORT VRController final | 24 class MODULES_EXPORT VRController final |
| 17 : public GarbageCollectedFinalized<VRController> | 25 : public GarbageCollectedFinalized<VRController> |
| 18 , public Supplement<LocalFrame> | 26 , public Supplement<LocalFrame> |
| 19 , public LocalFrameLifecycleObserver { | 27 , public LocalFrameLifecycleObserver { |
| 20 USING_GARBAGE_COLLECTED_MIXIN(VRController); | 28 USING_GARBAGE_COLLECTED_MIXIN(VRController); |
| 21 WTF_MAKE_NONCOPYABLE(VRController); | 29 WTF_MAKE_NONCOPYABLE(VRController); |
| 22 public: | 30 public: |
| 23 virtual ~VRController(); | 31 virtual ~VRController(); |
| 24 | 32 |
| 25 void getDevices(WebVRGetDevicesCallback*); | 33 void getDevices(WebVRGetDevicesCallback*); |
| 26 | 34 |
| 27 void getSensorState(unsigned index, WebHMDSensorState& into); | 35 void getSensorState(unsigned index, WebHMDSensorState* into); |
| 28 | 36 |
| 29 void resetSensor(unsigned index); | 37 void resetSensor(unsigned index); |
| 30 | 38 |
| 31 static void provideTo(LocalFrame&, WebVRClient*); | 39 static void provideTo(LocalFrame&, ServiceRegistry*); |
| 32 static VRController* from(LocalFrame&); | 40 static VRController* from(LocalFrame&); |
| 33 static const char* supplementName(); | 41 static const char* supplementName(); |
| 34 | 42 |
| 35 DECLARE_VIRTUAL_TRACE(); | 43 DECLARE_VIRTUAL_TRACE(); |
| 36 | 44 |
| 37 private: | 45 private: |
| 38 VRController(LocalFrame&, WebVRClient*); | 46 VRController(LocalFrame&, ServiceRegistry*); |
| 47 |
| 48 mojom::wtf::VRServicePtr& service(); |
| 49 |
| 50 // Callback handlers |
| 51 void OnGetDevices(const mojo::WTFArray<mojom::wtf::VRDeviceInfoPtr>& devices
); |
| 52 void OnGetSensorState(const mojom::wtf::VRSensorStatePtr& mojoState); |
| 39 | 53 |
| 40 // Inherited from LocalFrameLifecycleObserver. | 54 // Inherited from LocalFrameLifecycleObserver. |
| 41 void willDetachFrameHost() override; | 55 void willDetachFrameHost() override; |
| 42 | 56 |
| 43 WebVRClient* m_client; | 57 ServiceRegistry* m_registry; |
| 58 mojom::wtf::VRServicePtr m_service; |
| 59 WebHMDSensorState* m_pendingState; |
| 60 Vector<OwnPtr<WebVRGetDevicesCallback>> m_pendingDeviceRequests; |
| 44 }; | 61 }; |
| 45 | 62 |
| 46 } // namespace blink | 63 } // namespace blink |
| 47 | 64 |
| 48 #endif // VRController_h | 65 #endif // VRController_h |
| OLD | NEW |