OLD | NEW |
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 "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
8 #include "core/dom/DOMException.h" | 8 #include "core/dom/DOMException.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
11 #include "modules/vr/NavigatorVR.h" | 11 #include "modules/vr/NavigatorVR.h" |
12 #include "modules/vr/VRGetDevicesCallback.h" | 12 #include "modules/vr/VRGetDevicesCallback.h" |
13 #include "public/platform/InterfaceProvider.h" | 13 #include "public/platform/InterfaceProvider.h" |
14 | 14 |
15 #include "wtf/Assertions.h" | 15 #include "wtf/Assertions.h" |
16 | 16 |
17 namespace blink { | 17 namespace blink { |
18 | 18 |
19 VRController::VRController(NavigatorVR* navigatorVR) | 19 VRController::VRController(NavigatorVR* navigatorVR) |
20 : ContextLifecycleObserver(navigatorVR->document()), | 20 : ContextLifecycleObserver(navigatorVR->document()), |
21 m_navigatorVR(navigatorVR), | 21 m_navigatorVR(navigatorVR), |
22 m_displaySynced(false), | 22 m_displaySynced(false), |
23 m_binding(this) { | 23 m_binding(this) { |
24 navigatorVR->document()->frame()->interfaceProvider()->getInterface( | 24 navigatorVR->document()->frame()->interfaceProvider()->getInterface( |
25 mojo::GetProxy(&m_service)); | 25 mojo::GetProxy(&m_service)); |
26 m_service->SetClient( | 26 m_service->SetClient( |
27 m_binding.CreateInterfacePtrAndBind(), | 27 m_binding.CreateInterfacePtrAndBind(), |
28 convertToBaseCallback( | 28 convertToBaseCallback( |
29 WTF::bind(&VRController::onDisplaysSynced, wrapPersistent(this)))); | 29 WTF::bind(&VRController::onDisplaysSynced, wrapPersistent(this)))); |
30 ThreadState::current()->registerPreFinalizer(this); | |
31 } | 30 } |
32 | 31 |
33 VRController::~VRController() {} | 32 VRController::~VRController() {} |
34 | 33 |
35 void VRController::getDisplays(ScriptPromiseResolver* resolver) { | 34 void VRController::getDisplays(ScriptPromiseResolver* resolver) { |
36 if (!m_service) { | 35 if (!m_service) { |
37 DOMException* exception = DOMException::create( | 36 DOMException* exception = DOMException::create( |
38 InvalidStateError, "The service is no longer active."); | 37 InvalidStateError, "The service is no longer active."); |
39 resolver->reject(exception); | 38 resolver->reject(exception); |
40 return; | 39 return; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 } | 109 } |
111 | 110 |
112 DEFINE_TRACE(VRController) { | 111 DEFINE_TRACE(VRController) { |
113 visitor->trace(m_navigatorVR); | 112 visitor->trace(m_navigatorVR); |
114 visitor->trace(m_displays); | 113 visitor->trace(m_displays); |
115 | 114 |
116 ContextLifecycleObserver::trace(visitor); | 115 ContextLifecycleObserver::trace(visitor); |
117 } | 116 } |
118 | 117 |
119 } // namespace blink | 118 } // namespace blink |
OLD | NEW |