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

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

Issue 2471433002: Implement WebVR presentation pausing for VR Shell Menu Mode (Closed)
Patch Set: Add comments to VRDisplay 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 #include "device/vr/vr_service_impl.h"
8 8
9 namespace device { 9 namespace device {
10 10
11 unsigned int VRDevice::next_id_ = 1; 11 unsigned int VRDevice::next_id_ = 1;
12 12
13 VRDevice::VRDevice(VRDeviceProvider* provider) 13 VRDevice::VRDevice(scoped_refptr<VRDeviceProvider> provider)
14 : presenting_service_(nullptr), provider_(provider), id_(next_id_) { 14 : presenting_service_(nullptr),
15 provider_(std::move(provider)),
16 id_(next_id_) {
15 // Prevent wraparound. Devices with this ID will be treated as invalid. 17 // Prevent wraparound. Devices with this ID will be treated as invalid.
16 if (next_id_ != VR_DEVICE_LAST_ID) 18 if (next_id_ != VR_DEVICE_LAST_ID)
17 next_id_++; 19 next_id_++;
18 } 20 }
19 21
20 VRDevice::~VRDevice() {} 22 VRDevice::~VRDevice() {}
21 23
24 scoped_refptr<VRDeviceProvider> VRDevice::provider() const {
25 return provider_;
26 }
27
22 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) { 28 bool VRDevice::RequestPresent(VRServiceImpl* service, bool secure_origin) {
23 return true; 29 return true;
24 }; 30 };
25 31
26 void VRDevice::AddService(VRServiceImpl* service) { 32 void VRDevice::AddService(VRServiceImpl* service) {
27 // Create a VRDisplayImpl for this service/device pair 33 // Create a VRDisplayImpl for this service/device pair
28 VRDisplayImpl* display_impl = service->GetVRDisplayImpl(this); 34 VRDisplayImpl* display_impl = service->GetVRDisplayImpl(this);
29 displays_.insert(std::make_pair(service, display_impl)); 35 displays_.insert(std::make_pair(service, display_impl));
30 } 36 }
31 37
(...skipping 24 matching lines...) Expand all
56 62
57 void VRDevice::OnExitPresent(VRServiceImpl* service) { 63 void VRDevice::OnExitPresent(VRServiceImpl* service) {
58 DisplayClientMap::iterator it = displays_.find(service); 64 DisplayClientMap::iterator it = displays_.find(service);
59 if (it != displays_.end()) { 65 if (it != displays_.end()) {
60 mojom::VRDisplayClient* client = it->second->client(); 66 mojom::VRDisplayClient* client = it->second->client();
61 if (client) 67 if (client)
62 client->OnExitPresent(); 68 client->OnExitPresent();
63 } 69 }
64 } 70 }
65 71
72 void VRDevice::OnDisplayBlur() {
73 for (const auto& display : displays_) {
74 mojom::VRDisplayClient* client = display.second->client();
75 if (client)
dcheng 2016/11/11 00:48:21 Does this need to null check? I believe that we bi
mthiesse 2016/11/11 20:19:21 Done.
76 client->OnDisplayBlur();
77 }
78 }
79
80 void VRDevice::OnDisplayFocus() {
81 for (const auto& display : displays_) {
82 mojom::VRDisplayClient* client = display.second->client();
83 if (client)
84 client->OnDisplayFocus();
85 }
86 }
87
66 } // namespace device 88 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698