OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_RENDERER_VR_DISPATCHER_H_ |
| 6 #define CONTENT_RENDERER_VR_DISPATCHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/id_map.h" |
| 11 #include "content/public/renderer/render_frame_observer.h" |
| 12 #include "third_party/WebKit/public/platform/WebVR.h" |
| 13 #include "third_party/WebKit/public/platform/WebVRClient.h" |
| 14 #include "third_party/WebKit/public/platform/WebVector.h" |
| 15 |
| 16 namespace content { |
| 17 |
| 18 class VRDispatcher : public RenderFrameObserver, |
| 19 NON_EXPORTED_BASE(public blink::WebVRClient) { |
| 20 public: |
| 21 explicit VRDispatcher(RenderFrame* render_frame); |
| 22 ~VRDispatcher(); |
| 23 |
| 24 // RenderFrameObserver implementation. |
| 25 bool OnMessageReceived(const IPC::Message& message) override; |
| 26 |
| 27 // blink::WebVRClient implementation. |
| 28 void getDevices(blink::WebVRGetDevicesCallback* callback) override; |
| 29 |
| 30 void getSensorState(unsigned int index, |
| 31 blink::WebHMDSensorState& state) override; |
| 32 |
| 33 void resetSensor(unsigned int index) override; |
| 34 |
| 35 private: |
| 36 // IPC Handlers |
| 37 void OnGetDevicesSuccess(int request_id, |
| 38 const std::vector<blink::WebVRDevice>& devices); |
| 39 void OnGetDevicesError(int request_id); |
| 40 |
| 41 // Tracks requests sent to browser to match replies with callbacks. |
| 42 // Owns callback objects. |
| 43 IDMap<blink::WebVRGetDevicesCallback, IDMapOwnPointer> pending_requests_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(VRDispatcher); |
| 46 }; |
| 47 |
| 48 } // namespace content |
| 49 |
| 50 #endif // CONTENT_RENDERER_VR_DISPATCHER_H_ |
OLD | NEW |