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

Side by Side Diff: third_party/WebKit/Source/modules/vr/VRController.cpp

Issue 2317483002: Add support of vrdisplayconnect and vrdisplaydisconnect event (Closed)
Patch Set: fix missing brace 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 "modules/vr/VRController.h" 5 #include "modules/vr/VRController.h"
6 6
7 #include "core/dom/DOMException.h" 7 #include "core/dom/DOMException.h"
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/frame/LocalFrame.h" 9 #include "core/frame/LocalFrame.h"
10 #include "modules/vr/NavigatorVR.h" 10 #include "modules/vr/NavigatorVR.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 vrDisplay->update(display); 170 vrDisplay->update(display);
171 } 171 }
172 172
173 void VRController::OnExitPresent(unsigned index) 173 void VRController::OnExitPresent(unsigned index)
174 { 174 {
175 VRDisplay* vrDisplay = getDisplayForIndex(index); 175 VRDisplay* vrDisplay = getDisplayForIndex(index);
176 if (vrDisplay) 176 if (vrDisplay)
177 vrDisplay->forceExitPresent(); 177 vrDisplay->forceExitPresent();
178 } 178 }
179 179
180 void VRController::OnDisplayConnected(device::blink::VRDisplayPtr display)
181 {
182 VRDisplay* vrDisplay = createOrUpdateDisplay(display);
183 if (!vrDisplay)
184 return;
185
186 m_navigatorVR->fireVREvent(VRDisplayEvent::create(
187 EventTypeNames::vrdisplayconnect, true, false, vrDisplay, "connect"));
188 }
189
190 void VRController::OnDisplayDisconnected(unsigned index)
191 {
192 VRDisplay* vrDisplay = getDisplayForIndex(index);
193 if (!vrDisplay)
194 return;
195
196 vrDisplay->disconnected();
197
198 m_navigatorVR->fireVREvent(VRDisplayEvent::create(
199 EventTypeNames::vrdisplaydisconnect, true, false, vrDisplay, "disconnect "));
200 }
201
180 void VRController::contextDestroyed() 202 void VRController::contextDestroyed()
181 { 203 {
182 // If the document context was destroyed, shut down the client connection 204 // If the document context was destroyed, shut down the client connection
183 // and never call the mojo service again. 205 // and never call the mojo service again.
184 m_binding.Close(); 206 m_binding.Close();
185 m_service.reset(); 207 m_service.reset();
186 208
187 // The context is not automatically cleared, so do it manually. 209 // The context is not automatically cleared, so do it manually.
188 ContextLifecycleObserver::clearContext(); 210 ContextLifecycleObserver::clearContext();
189 } 211 }
190 212
191 DEFINE_TRACE(VRController) 213 DEFINE_TRACE(VRController)
192 { 214 {
193 visitor->trace(m_navigatorVR); 215 visitor->trace(m_navigatorVR);
194 visitor->trace(m_displays); 216 visitor->trace(m_displays);
195 217
196 ContextLifecycleObserver::trace(visitor); 218 ContextLifecycleObserver::trace(visitor);
197 } 219 }
198 220
199 } // namespace blink 221 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/vr/VRController.h ('k') | third_party/WebKit/Source/modules/vr/VRDisplay.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698