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

Unified 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 side-by-side diff with in-line comments
Download patch
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..fb1b9e2fc8a31f4dab0c9a164a423e4762d46652
--- /dev/null
+++ b/content/browser/renderer_host/vr_message_filter.cc
@@ -0,0 +1,65 @@
+// 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() {
+}
+
+void VRMessageFilter::OnDestruct() const {
+ BrowserThread::DeleteOnIOThread::Destruct(this);
+}
+
+bool VRMessageFilter::OnMessageReceived(
+ const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(VRMessageFilter, message)
+ IPC_MESSAGE_HANDLER(VRHostMsg_GetVRDevices,
+ OnGetVRDevices)
+ IPC_MESSAGE_HANDLER(VRHostMsg_GetSensorState,
+ OnGetSensorState)
+ IPC_MESSAGE_HANDLER(VRHostMsg_ResetSensor,
+ OnResetSensor)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void VRMessageFilter::OnGetVRDevices(
+ int32_t render_frame_id,
+ int request_id) {
+ std::vector<blink::WebVRDevice> devices;
+ GetServiceInstance()->GetVRDevices(&devices);
+ Send(new VRMsg_GetDevicesSuccess(render_frame_id, request_id, devices));
+}
+
+void VRMessageFilter::OnGetSensorState(
+ int32_t render_frame_id,
+ unsigned int index,
+ blink::WebHMDSensorState* state) {
+ VRDevice* device = GetServiceInstance()->GetDevice(index);
+ if (device) {
Ted C 2015/04/24 01:06:06 typically you don't need braces unless it's confus
+ device->GetSensorState(state);
+ }
+}
+
+void VRMessageFilter::OnResetSensor(
+ int32_t render_frame_id,
+ unsigned int index) {
+ VRDevice* device = GetServiceInstance()->GetDevice(index);
+ if (device) {
+ device->ResetSensor();
+ }
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698