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

Side by Side Diff: content/browser/vr/vr_service_impl.cc

Issue 829803003: Adding Chrome-side WebVR interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated to use Mojo as requested by eng review Created 5 years, 6 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/vr/vr_service_impl.h"
6
7 #include "base/location.h"
8 #include "content/browser/vr/vr_device_manager.h"
9
10 namespace content {
11
12 void VRServiceImpl::Create(mojo::InterfaceRequest<VRService> request) {
13 VRServiceImpl* service = new VRServiceImpl();
14 mojo::BindToRequest(service, &request);
15 }
16
17 VRServiceImpl::VRServiceImpl() : registered_with_device_manager_(false) {
18 }
19
20 VRServiceImpl::~VRServiceImpl() {
21 if (registered_with_device_manager_) {
22 VRDeviceManager::RemoveService(this);
23 }
24 }
25
26 VRDeviceManager* VRServiceImpl::GetDeviceManager() {
27 if (!registered_with_device_manager_) {
28 VRDeviceManager::AddService(this);
29 registered_with_device_manager_ = true;
30 }
31 return VRDeviceManager::GetInstance();
32 }
33
34 void VRServiceImpl::GetDevices(const GetDevicesCallback& callback) {
35 callback.Run(GetDeviceManager()->GetVRDevices());
36 }
37
38 void VRServiceImpl::GetSensorState(uint32_t index,
39 const GetSensorStateCallback& callback) {
40 VRDevice* device = GetDeviceManager()->GetDevice(index);
41 if (device) {
42 callback.Run(device->GetSensorState());
43 } else {
44 callback.Run(nullptr);
45 }
46 }
47
48 void VRServiceImpl::ResetSensor(uint32_t index) {
49 VRDevice* device = GetDeviceManager()->GetDevice(index);
50 if (device)
51 device->ResetSensor();
52 }
53
54 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698