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

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

Issue 2317483002: Add support of vrdisplayconnect and vrdisplaydisconnect event (Closed)
Patch Set: Clean some style issue according to mthiesse@ Created 4 years, 3 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
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_manager.h" 5 #include "device/vr/vr_device_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 return iter->second; 120 return iter->second;
121 } 121 }
122 122
123 // These dispatchers must use Clone() instead of std::move to ensure that 123 // These dispatchers must use Clone() instead of std::move to ensure that
124 // if there are multiple registered services they all get a copy of the data. 124 // if there are multiple registered services they all get a copy of the data.
125 void VRDeviceManager::OnDeviceChanged(VRDisplayPtr device) { 125 void VRDeviceManager::OnDeviceChanged(VRDisplayPtr device) {
126 for (const auto& service : services_) 126 for (const auto& service : services_)
127 service->client()->OnDisplayChanged(device.Clone()); 127 service->client()->OnDisplayChanged(device.Clone());
128 } 128 }
129 129
130 void VRDeviceManager::OnDeviceConnectionStatusChanged(VRDevice* device,
131 bool is_connected) {
132 if (is_connected) {
133 VRDisplayPtr vr_device_info = device->GetVRDevice();
134 if (vr_device_info.is_null())
135 return;
136
137 vr_device_info->index = device->id();
138
139 for (const auto& service : services_)
140 service->client()->OnDisplayConnected(vr_device_info.Clone());
141 } else {
142 for (const auto& service : services_)
143 service->client()->OnDisplayDisconnected(device->id());
144 }
145 }
146
130 void VRDeviceManager::InitializeProviders() { 147 void VRDeviceManager::InitializeProviders() {
131 if (vr_initialized_) { 148 if (vr_initialized_) {
132 return; 149 return;
133 } 150 }
134 151
135 for (const auto& provider : providers_) 152 for (const auto& provider : providers_) {
153 provider->SetClient(this);
136 provider->Initialize(); 154 provider->Initialize();
155 }
137 156
138 vr_initialized_ = true; 157 vr_initialized_ = true;
139 } 158 }
140 159
141 void VRDeviceManager::RegisterProvider( 160 void VRDeviceManager::RegisterProvider(
142 std::unique_ptr<VRDeviceProvider> provider) { 161 std::unique_ptr<VRDeviceProvider> provider) {
143 providers_.push_back(make_linked_ptr(provider.release())); 162 providers_.push_back(make_linked_ptr(provider.release()));
144 } 163 }
145 164
146 void VRDeviceManager::SchedulePollEvents() { 165 void VRDeviceManager::SchedulePollEvents() {
(...skipping 10 matching lines...) Expand all
157 for (const auto& provider : providers_) 176 for (const auto& provider : providers_)
158 provider->PollEvents(); 177 provider->PollEvents();
159 } 178 }
160 179
161 void VRDeviceManager::StopSchedulingPollEvents() { 180 void VRDeviceManager::StopSchedulingPollEvents() {
162 if (has_scheduled_poll_) 181 if (has_scheduled_poll_)
163 timer_.Stop(); 182 timer_.Stop();
164 } 183 }
165 184
166 } // namespace device 185 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698