Chromium Code Reviews| 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 #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 DCHECK_CURRENTLY_ON(BrowserThread::IO); | |
|
no sievers
2015/03/19 01:24:51
I'm not sure this is guaranteed (although it might
| |
| 18 } | |
| 19 | |
| 20 bool VRMessageFilter::OnMessageReceived( | |
| 21 const IPC::Message& message) { | |
| 22 bool handled = true; | |
| 23 IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message) | |
| 24 IPC_MESSAGE_HANDLER(VRMsg_GetVRDevices, | |
| 25 OnGetVRDevices) | |
| 26 IPC_MESSAGE_HANDLER(VRMsg_GetHMDSensorState, | |
| 27 OnGetHMDSensorState) | |
| 28 IPC_MESSAGE_HANDLER(VRMsg_ResetSensor, | |
| 29 OnResetSensor) | |
| 30 IPC_MESSAGE_HANDLER(VRMsg_GetRenderTargetRects, | |
| 31 OnGetRenderTargetRects) | |
| 32 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 33 IPC_END_MESSAGE_MAP() | |
| 34 return handled; | |
| 35 } | |
| 36 | |
| 37 void VRMessageFilter::OnGetVRDevices( | |
| 38 std::vector<blink::WebVRDevice>* devices) { | |
| 39 VRService::GetInstance()->GetVRDevices(devices); | |
| 40 } | |
| 41 | |
| 42 void VRMessageFilter::OnGetHMDSensorState( | |
| 43 unsigned int index, blink::WebHMDSensorState* state) { | |
| 44 VRDevice* device = VRService::GetInstance()->GetDevice(index); | |
| 45 if (device) { | |
| 46 device->GetHMDSensorState(state); | |
| 47 } | |
| 48 } | |
| 49 | |
| 50 void VRMessageFilter::OnResetSensor(unsigned int index) { | |
| 51 VRDevice* device = VRService::GetInstance()->GetDevice(index); | |
| 52 if (device) { | |
| 53 device->ResetSensor(); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 void VRMessageFilter::OnGetRenderTargetRects( | |
| 58 unsigned index, | |
| 59 blink::WebVRFieldOfView leftFov, | |
| 60 blink::WebVRFieldOfView rightFov, | |
| 61 blink::WebVRVector4* leftRect, | |
| 62 blink::WebVRVector4* rightRect) { | |
| 63 VRDevice* device = VRService::GetInstance()->GetDevice(index); | |
| 64 if (device) { | |
| 65 device->GetRenderTargetRects(leftFov, rightFov, leftRect, rightRect); | |
| 66 } | |
| 67 } | |
| 68 | |
| 69 } // namespace content | |
| OLD | NEW |