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 "base/macros.h" | |
12 #include "content/common/vr_service.mojom.h" | |
13 #include "third_party/WebKit/public/platform/WebVector.h" | |
14 #include "third_party/WebKit/public/platform/modules/vr/WebVR.h" | |
15 #include "third_party/WebKit/public/platform/modules/vr/WebVRClient.h" | |
16 | |
17 namespace content { | |
18 | |
19 class ServiceRegistry; | |
20 | |
21 class VRDispatcher : NON_EXPORTED_BASE(public blink::WebVRClient) { | |
22 public: | |
23 explicit VRDispatcher(ServiceRegistry* service_registry); | |
24 ~VRDispatcher() override; | |
25 | |
26 // blink::WebVRClient implementation. | |
27 void getDevices(blink::WebVRGetDevicesCallback* callback) override; | |
28 | |
29 void getSensorState(unsigned int index, | |
30 blink::WebHMDSensorState& state) override; | |
31 | |
32 void resetSensor(unsigned int index) override; | |
33 | |
34 private: | |
35 // Helper method that returns an initialized PermissionServicePtr. | |
36 mojom::VRServicePtr& GetVRServicePtr(); | |
37 | |
38 // Callback handlers | |
39 void OnGetDevices(int request_id, | |
40 const mojo::Array<mojom::VRDeviceInfoPtr>& devices); | |
41 static void OnGetSensorState(blink::WebHMDSensorState* state, | |
42 const mojom::VRSensorStatePtr& mojo_state); | |
43 | |
44 // Tracks requests sent to browser to match replies with callbacks. | |
45 // Owns callback objects. | |
46 IDMap<blink::WebVRGetDevicesCallback, IDMapOwnPointer> pending_requests_; | |
47 | |
48 ServiceRegistry* service_registry_; | |
49 mojom::VRServicePtr vr_service_; | |
50 | |
51 DISALLOW_COPY_AND_ASSIGN(VRDispatcher); | |
52 }; | |
53 | |
54 } // namespace content | |
55 | |
56 #endif // CONTENT_RENDERER_VR_DISPATCHER_H_ | |
OLD | NEW |