Roll src/third_party/skia 2440fcd:4de8c3a
[chromium-blink-merge.git] / content / renderer / vr / vr_dispatcher.h
blob7e5d56bd55c0ea20cd9258a74a7b8d65ff4bd7b6
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.
5 #ifndef CONTENT_RENDERER_VR_DISPATCHER_H_
6 #define CONTENT_RENDERER_VR_DISPATCHER_H_
8 #include <vector>
10 #include "base/id_map.h"
11 #include "content/common/vr_service.mojom.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
13 #include "third_party/WebKit/public/platform/modules/vr/WebVR.h"
14 #include "third_party/WebKit/public/platform/modules/vr/WebVRClient.h"
16 namespace content {
18 class ServiceRegistry;
20 class VRDispatcher : NON_EXPORTED_BASE(public blink::WebVRClient) {
21 public:
22 explicit VRDispatcher(ServiceRegistry* service_registry);
23 ~VRDispatcher();
25 // blink::WebVRClient implementation.
26 void getDevices(blink::WebVRGetDevicesCallback* callback) override;
28 void getSensorState(unsigned int index,
29 blink::WebHMDSensorState& state) override;
31 void resetSensor(unsigned int index) override;
33 private:
34 // Helper method that returns an initialized PermissionServicePtr.
35 VRServicePtr& GetVRServicePtr();
37 // Callback handlers
38 void OnGetDevices(int request_id,
39 const mojo::Array<VRDeviceInfoPtr>& devices);
40 static void OnGetSensorState(blink::WebHMDSensorState* state,
41 const VRSensorStatePtr& mojo_state);
43 // Tracks requests sent to browser to match replies with callbacks.
44 // Owns callback objects.
45 IDMap<blink::WebVRGetDevicesCallback, IDMapOwnPointer> pending_requests_;
47 ServiceRegistry* service_registry_;
48 VRServicePtr vr_service_;
50 DISALLOW_COPY_AND_ASSIGN(VRDispatcher);
53 } // namespace content
55 #endif // CONTENT_RENDERER_VR_DISPATCHER_H_