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

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

Issue 2317483002: Add support of vrdisplayconnect and vrdisplaydisconnect event (Closed)
Patch Set: Address most comments from bajones@ 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display) 143 void VRController::OnDisplayChanged(device::blink::VRDisplayPtr display)
144 { 144 {
145 VRDisplay* vrDisplay = getDisplayForIndex(display->index); 145 VRDisplay* vrDisplay = getDisplayForIndex(display->index);
146 if (!vrDisplay) 146 if (!vrDisplay)
147 return; 147 return;
148 148
149 vrDisplay->update(display); 149 vrDisplay->update(display);
150 } 150 }
151 151
152 void VRController::OnDisplayConnected(device::blink::VRDisplayPtr display)
153 {
154 VRDisplay* vrDisplay = createOrUpdateDisplay(display);
155 if (!vrDisplay)
156 return;
157
158 m_navigatorVR->fireVREvent(VRDisplayEvent::create(
159 EventTypeNames::vrdisplayconnect, true, false, vrDisplay, "connect"));
160 }
161
162 void VRController::OnDisplayDisconnected(unsigned index)
163 {
164 VRDisplay* vrDisplay = getDisplayForIndex(index);
165 if (!vrDisplay)
166 return;
167
168 vrDisplay->disconnected();
169
170 m_navigatorVR->fireVREvent(VRDisplayEvent::create(
171 EventTypeNames::vrdisplaydisconnect, true, false, vrDisplay, "disconnect "));
172 }
173
152 void VRController::contextDestroyed() 174 void VRController::contextDestroyed()
153 { 175 {
154 // If the document context was destroyed, shut down the client connection 176 // If the document context was destroyed, shut down the client connection
155 // and never call the mojo service again. 177 // and never call the mojo service again.
156 m_binding.Close(); 178 m_binding.Close();
157 m_service.reset(); 179 m_service.reset();
158 180
159 // The context is not automatically cleared, so do it manually. 181 // The context is not automatically cleared, so do it manually.
160 ContextLifecycleObserver::clearContext(); 182 ContextLifecycleObserver::clearContext();
161 } 183 }
162 184
163 DEFINE_TRACE(VRController) 185 DEFINE_TRACE(VRController)
164 { 186 {
165 visitor->trace(m_navigatorVR); 187 visitor->trace(m_navigatorVR);
166 visitor->trace(m_displays); 188 visitor->trace(m_displays);
167 189
168 ContextLifecycleObserver::trace(visitor); 190 ContextLifecycleObserver::trace(visitor);
169 } 191 }
170 192
171 } // namespace blink 193 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698