| 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 "core/frame/LocalFrame.h" | 7 #include "core/frame/LocalFrame.h" |
| 8 #include "modules/vr/VRGetDevicesCallback.h" | 8 #include "modules/vr/VRGetDevicesCallback.h" |
| 9 #include "platform/RuntimeEnabledFeatures.h" | 9 #include "platform/RuntimeEnabledFeatures.h" |
| 10 #include "platform/mojo/MojoHelper.h" | 10 #include "platform/mojo/MojoHelper.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 ASSERT(RuntimeEnabledFeatures::webVREnabled()); | 21 ASSERT(RuntimeEnabledFeatures::webVREnabled()); |
| 22 Supplement<LocalFrame>::provideTo(frame, supplementName(), registry ? new VR
Controller(frame, registry) : nullptr); | 22 Supplement<LocalFrame>::provideTo(frame, supplementName(), registry ? new VR
Controller(frame, registry) : nullptr); |
| 23 } | 23 } |
| 24 | 24 |
| 25 VRController* VRController::from(LocalFrame& frame) | 25 VRController* VRController::from(LocalFrame& frame) |
| 26 { | 26 { |
| 27 return static_cast<VRController*>(Supplement<LocalFrame>::from(frame, supple
mentName())); | 27 return static_cast<VRController*>(Supplement<LocalFrame>::from(frame, supple
mentName())); |
| 28 } | 28 } |
| 29 | 29 |
| 30 VRController::VRController(LocalFrame& frame, ServiceRegistry* registry) | 30 VRController::VRController(LocalFrame& frame, ServiceRegistry* registry) |
| 31 : LocalFrameLifecycleObserver(&frame) | |
| 32 { | 31 { |
| 33 ASSERT(!m_service.is_bound()); | 32 ASSERT(!m_service.is_bound()); |
| 34 registry->connectToRemoteService(mojo::GetProxy(&m_service)); | 33 registry->connectToRemoteService(mojo::GetProxy(&m_service)); |
| 35 } | 34 } |
| 36 | 35 |
| 37 const char* VRController::supplementName() | 36 const char* VRController::supplementName() |
| 38 { | 37 { |
| 39 return "VRController"; | 38 return "VRController"; |
| 40 } | 39 } |
| 41 | 40 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 60 return pose; | 59 return pose; |
| 61 } | 60 } |
| 62 | 61 |
| 63 void VRController::resetPose(unsigned index) | 62 void VRController::resetPose(unsigned index) |
| 64 { | 63 { |
| 65 if (!m_service) | 64 if (!m_service) |
| 66 return; | 65 return; |
| 67 m_service->ResetPose(index); | 66 m_service->ResetPose(index); |
| 68 } | 67 } |
| 69 | 68 |
| 70 void VRController::willDetachFrameHost() | |
| 71 { | |
| 72 // TODO(kphanee): Detach from the mojo service connection. | |
| 73 } | |
| 74 | |
| 75 void VRController::onGetDisplays(mojo::WTFArray<device::blink::VRDisplayPtr> dis
plays) | 69 void VRController::onGetDisplays(mojo::WTFArray<device::blink::VRDisplayPtr> dis
plays) |
| 76 { | 70 { |
| 77 std::unique_ptr<VRGetDevicesCallback> callback = m_pendingGetDevicesCallback
s.takeFirst(); | 71 std::unique_ptr<VRGetDevicesCallback> callback = m_pendingGetDevicesCallback
s.takeFirst(); |
| 78 if (!callback) | 72 if (!callback) |
| 79 return; | 73 return; |
| 80 | 74 |
| 81 callback->onSuccess(std::move(displays)); | 75 callback->onSuccess(std::move(displays)); |
| 82 } | 76 } |
| 83 | 77 |
| 84 DEFINE_TRACE(VRController) | 78 DEFINE_TRACE(VRController) |
| 85 { | 79 { |
| 86 Supplement<LocalFrame>::trace(visitor); | 80 Supplement<LocalFrame>::trace(visitor); |
| 87 LocalFrameLifecycleObserver::trace(visitor); | |
| 88 } | 81 } |
| 89 | 82 |
| 90 } // namespace blink | 83 } // namespace blink |
| OLD | NEW |