Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: content/browser/renderer_host/vr_message_filter.cc

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved cardboard-java gyp and gn config into third_party Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 #include "content/browser/renderer_host/vr_message_filter.h"
6
7 #include "content/common/vr_messages.h"
8 #include "third_party/WebKit/public/platform/WebVR.h"
9
10 namespace content {
11
12 VRMessageFilter::VRMessageFilter()
13 : BrowserMessageFilter(VRMsgStart) {
14 }
15
16 VRMessageFilter::~VRMessageFilter() {
17 }
18
19 void VRMessageFilter::OnDestruct() const {
20 BrowserThread::DeleteOnIOThread::Destruct(this);
21 }
22
23 bool VRMessageFilter::OnMessageReceived(
24 const IPC::Message& message) {
25 bool handled = true;
26 IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message)
27 IPC_MESSAGE_HANDLER(VRHostMsg_GetVRDevices,
28 OnGetVRDevices)
29 IPC_MESSAGE_HANDLER(VRHostMsg_GetSensorState,
30 OnGetSensorState)
31 IPC_MESSAGE_HANDLER(VRHostMsg_ResetSensor,
32 OnResetSensor)
33 IPC_MESSAGE_UNHANDLED(handled = false)
34 IPC_END_MESSAGE_MAP()
35 return handled;
36 }
37
38 void VRMessageFilter::OnGetVRDevices(
39 int32_t render_frame_id,
40 int request_id) {
41 std::vector<blink::WebVRDevice> devices;
42 GetServiceInstance()->GetVRDevices(&devices);
43 Send(new VRMsg_GetDevicesSuccess(render_frame_id, request_id, devices));
44 }
45
46 void VRMessageFilter::OnGetSensorState(
47 int32_t render_frame_id,
48 unsigned int index,
49 blink::WebHMDSensorState* state) {
50 VRDevice* device = GetServiceInstance()->GetDevice(index);
51 if (device) {
Ted C 2015/04/24 01:06:06 typically you don't need braces unless it's confus
52 device->GetSensorState(state);
53 }
54 }
55
56 void VRMessageFilter::OnResetSensor(
57 int32_t render_frame_id,
58 unsigned int index) {
59 VRDevice* device = GetServiceInstance()->GetDevice(index);
60 if (device) {
61 device->ResetSensor();
62 }
63 }
64
65 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698