Chromium Code Reviews| Index: content/browser/renderer_host/vr_message_filter.cc |
| diff --git a/content/browser/renderer_host/vr_message_filter.cc b/content/browser/renderer_host/vr_message_filter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..949b11f0103eced4a0b7e5b403b81d913fbf12fe |
| --- /dev/null |
| +++ b/content/browser/renderer_host/vr_message_filter.cc |
| @@ -0,0 +1,69 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/renderer_host/vr_message_filter.h" |
| + |
| +#include "content/common/vr_messages.h" |
| +#include "third_party/WebKit/public/platform/WebVR.h" |
| + |
| +namespace content { |
| + |
| +VRMessageFilter::VRMessageFilter() |
| + : BrowserMessageFilter(VRMsgStart) { |
| +} |
| + |
| +VRMessageFilter::~VRMessageFilter() { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
|
no sievers
2015/03/19 01:24:51
I'm not sure this is guaranteed (although it might
|
| +} |
| + |
| +bool VRMessageFilter::OnMessageReceived( |
| + const IPC::Message& message) { |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message) |
| + IPC_MESSAGE_HANDLER(VRMsg_GetVRDevices, |
| + OnGetVRDevices) |
| + IPC_MESSAGE_HANDLER(VRMsg_GetHMDSensorState, |
| + OnGetHMDSensorState) |
| + IPC_MESSAGE_HANDLER(VRMsg_ResetSensor, |
| + OnResetSensor) |
| + IPC_MESSAGE_HANDLER(VRMsg_GetRenderTargetRects, |
| + OnGetRenderTargetRects) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| +} |
| + |
| +void VRMessageFilter::OnGetVRDevices( |
| + std::vector<blink::WebVRDevice>* devices) { |
| + VRService::GetInstance()->GetVRDevices(devices); |
| +} |
| + |
| +void VRMessageFilter::OnGetHMDSensorState( |
| + unsigned int index, blink::WebHMDSensorState* state) { |
| + VRDevice* device = VRService::GetInstance()->GetDevice(index); |
| + if (device) { |
| + device->GetHMDSensorState(state); |
| + } |
| +} |
| + |
| +void VRMessageFilter::OnResetSensor(unsigned int index) { |
| + VRDevice* device = VRService::GetInstance()->GetDevice(index); |
| + if (device) { |
| + device->ResetSensor(); |
| + } |
| +} |
| + |
| +void VRMessageFilter::OnGetRenderTargetRects( |
| + unsigned index, |
| + blink::WebVRFieldOfView leftFov, |
| + blink::WebVRFieldOfView rightFov, |
| + blink::WebVRVector4* leftRect, |
| + blink::WebVRVector4* rightRect) { |
| + VRDevice* device = VRService::GetInstance()->GetDevice(index); |
| + if (device) { |
| + device->GetRenderTargetRects(leftFov, rightFov, leftRect, rightRect); |
| + } |
| +} |
| + |
| +} // namespace content |