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

Side by Side Diff: device/vr/vr_device.cc

Issue 2420743003: mojo VR interface simplified (Closed)
Patch Set: address leon@ comments about name Created 4 years, 1 month 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/vr/vr_device.h" 5 #include "device/vr/vr_device.h"
6 #include "device/vr/vr_device_provider.h" 6 #include "device/vr/vr_device_provider.h"
7 #include "device/vr/vr_service_impl.h"
7 8
8 namespace device { 9 namespace device {
9 10
10 unsigned int VRDevice::next_id_ = 1; 11 unsigned int VRDevice::next_id_ = 1;
11 12
12 VRDevice::VRDevice(VRDeviceProvider* provider) 13 VRDevice::VRDevice(VRDeviceProvider* provider)
13 : provider_(provider), id_(next_id_) { 14 : presenting_service_(nullptr), provider_(provider), id_(next_id_) {
14 // Prevent wraparound. Devices with this ID will be treated as invalid. 15 // Prevent wraparound. Devices with this ID will be treated as invalid.
15 if (next_id_ != VR_DEVICE_LAST_ID) 16 if (next_id_ != VR_DEVICE_LAST_ID)
16 next_id_++; 17 next_id_++;
17 } 18 }
18 19
19 VRDevice::~VRDevice() {} 20 VRDevice::~VRDevice() {}
20 21
21 bool VRDevice::RequestPresent(bool secure_origin) { 22 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) {
22 return true; 23 return true;
23 }; 24 };
24 25
26 void VRDevice::SetClient(std::vector<VRServiceImpl*>* clients) {
bajones 2016/10/25 22:21:38 Weird mismatch in terminology here and elsewhere w
shaobo.yan 2016/10/26 01:19:22 Sorry about this but a little explain : since the
27 for (auto& service : *clients) {
28 display_clients_.insert(
29 std::pair<VRServiceImpl*, mojom::VRDisplayClientPtr>(
30 service, service->GetDisplayClient()));
31 }
32 }
33
34 void VRDevice::RemoveService(VRServiceImpl* service) {
35 ExitPresent(service);
36 display_clients_.erase(service);
37 }
38
39 bool VRDevice::CheckAccessAllowed(VRServiceImpl* service) {
40 return (!presenting_service_ || presenting_service_ == service);
41 }
42
43 bool VRDevice::IsPresentingService(VRServiceImpl* service) {
44 return (presenting_service_ && presenting_service_ == service);
45 }
46
47 void VRDevice::RegisterDeviceClient(VRServiceImpl* service) {
48 mojom::VRDevicePtr device_client = service->GetDevicePtr(this);
49 if (device_client) {
50 DisplayClientMap::iterator it = display_clients_.find(service);
51 if (it != display_clients_.end())
52 it->second->RegisterDevice(std::move(device_client));
53 }
54 }
55
56 void VRDevice::UpdateDisplayInfo(VRServiceImpl* service) {
57 DisplayClientMap::iterator it = display_clients_.find(service);
58 if (it != display_clients_.end())
59 it->second->UpdateDisplayInfo(GetVRDevice());
60 }
61
25 } // namespace device 62 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698