Chromium Code Reviews| Index: third_party/WebKit/Source/platform/vr/vr_dispatcher.h |
| diff --git a/third_party/WebKit/Source/platform/vr/vr_dispatcher.h b/third_party/WebKit/Source/platform/vr/vr_dispatcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6842f82eda43112c07c53d67ff4692b90a5d7829 |
| --- /dev/null |
| +++ b/third_party/WebKit/Source/platform/vr/vr_dispatcher.h |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLINK_PLATFORM_VR_VR_DISPATCHER_H_ |
| +#define BLINK_PLATFORM_VR_VR_DISPATCHER_H_ |
| + |
| +#include "base/id_map.h" |
| +#include "content/common/vr_service.mojom.h" |
| +#include "platform/PlatformExport.h" |
| +#include "public/platform/modules/vr/WebVRClient.h" |
| +#include "wtf/Noncopyable.h" |
| + |
| +namespace blink { |
| + |
| +class PLATFORM_EXPORT VRDispatcher : public WebVRClient { |
| + WTF_MAKE_NONCOPYABLE(VRDispatcher); |
| + public: |
| + static WebVRClient* create(); |
| + ~VRDispatcher() override; |
| + |
| + // WebVRClient implementation. |
| + void getDevices(WebVRGetDevicesCallback* callback) override; |
| + |
| + void getSensorState(unsigned int index, |
| + WebHMDSensorState& state) override; |
| + |
| + void resetSensor(unsigned int index) override; |
| + |
| + private: |
| + VRDispatcher(); |
| + |
| + // Helper method that returns an initialized PermissionServicePtr. |
| + content::VRServicePtr& GetVRServicePtr(); |
| + |
| + // Callback handlers |
| + void OnGetDevices(int* request_id, |
| + const mojo::Array<content::VRDeviceInfoPtr>& devices); |
| + void OnGetSensorState(WebHMDSensorState* state, |
| + const content::VRSensorStatePtr& mojo_state); |
| + |
| + // Tracks requests sent to browser to match replies with callbacks. |
| + // Owns callback objects. |
| + IDMap<WebVRGetDevicesCallback, IDMapOwnPointer> pending_requests_; |
|
haraken
2016/03/19 00:45:18
Hmm, IDMap looks nasty.
Can we introduce a new ob
RaviKasibhatla
2016/03/21 15:12:01
Done.
|
| + |
| + content::VRServicePtr vr_service_; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // BLINK_PLATFORM_VR_VR_DISPATCHER_H_ |