| Index: device/vr/vr_service_impl.cc
|
| diff --git a/device/vr/vr_service_impl.cc b/device/vr/vr_service_impl.cc
|
| index 6ea486de284d4d5e0e37bb7a7a36adb172b41a6b..ad12ace4c8affb86b0ddca747b7a4eeb83811ea6 100644
|
| --- a/device/vr/vr_service_impl.cc
|
| +++ b/device/vr/vr_service_impl.cc
|
| @@ -18,74 +18,53 @@ VRServiceImpl::~VRServiceImpl() {
|
| RemoveFromDeviceManager();
|
| }
|
|
|
| -void VRServiceImpl::BindRequest(mojo::InterfaceRequest<VRService> request) {
|
| +void VRServiceImpl::BindRequest(
|
| + mojo::InterfaceRequest<mojom::VRService> request) {
|
| VRServiceImpl* service = new VRServiceImpl();
|
| service->Bind(std::move(request));
|
| }
|
|
|
| -void VRServiceImpl::Bind(mojo::InterfaceRequest<VRService> request) {
|
| - binding_.reset(new mojo::Binding<VRService>(this, std::move(request)));
|
| +// Gets a VRDisplayPtr unique to this service so that the associated page can
|
| +// communicate with the VRDevice.
|
| +VRDisplayImpl* VRServiceImpl::GetVRDisplayImpl(VRDevice* device) {
|
| + DisplayImplMap::iterator it = displays_.find(device);
|
| + if (it != displays_.end())
|
| + return it->second.get();
|
| +
|
| + VRDisplayImpl* display_impl = new VRDisplayImpl(device, this);
|
| + displays_[device] = base::WrapUnique(display_impl);
|
| + return display_impl;
|
| +}
|
| +
|
| +void VRServiceImpl::Bind(mojo::InterfaceRequest<mojom::VRService> request) {
|
| + // TODO(shaobo.yan@intel.com) : Keep one binding_ and use close and rebind.
|
| + binding_.reset(new mojo::Binding<mojom::VRService>(this, std::move(request)));
|
| binding_->set_connection_error_handler(base::Bind(
|
| &VRServiceImpl::RemoveFromDeviceManager, base::Unretained(this)));
|
| }
|
|
|
| void VRServiceImpl::RemoveFromDeviceManager() {
|
| + displays_.clear();
|
| VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| device_manager->RemoveService(this);
|
| }
|
|
|
| -void VRServiceImpl::SetClient(VRServiceClientPtr client) {
|
| - DCHECK(!client_.get());
|
| -
|
| - client_ = std::move(client);
|
| - VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| - device_manager->AddService(this);
|
| -}
|
| -
|
| -void VRServiceImpl::GetDisplays(const GetDisplaysCallback& callback) {
|
| - VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| - callback.Run(device_manager->GetVRDevices());
|
| -}
|
| -
|
| -void VRServiceImpl::GetPose(uint32_t index, const GetPoseCallback& callback) {
|
| - VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
|
| -
|
| - if (device) {
|
| - callback.Run(device->GetPose());
|
| - } else {
|
| - callback.Run(nullptr);
|
| - }
|
| -}
|
| -
|
| -void VRServiceImpl::ResetPose(uint32_t index) {
|
| - VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
|
| - if (device)
|
| - device->ResetPose();
|
| -}
|
| -
|
| -void VRServiceImpl::RequestPresent(uint32_t index,
|
| - bool secureOrigin,
|
| - const RequestPresentCallback& callback) {
|
| - VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| - callback.Run(device_manager->RequestPresent(this, index, secureOrigin));
|
| +void VRServiceImpl::RemoveDevice(VRDevice* device) {
|
| + displays_.erase(device);
|
| }
|
|
|
| -void VRServiceImpl::ExitPresent(uint32_t index) {
|
| - VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| - device_manager->ExitPresent(this, index);
|
| -}
|
| +void VRServiceImpl::SetClient(mojom::VRServiceClientPtr service_client,
|
| + const SetClientCallback& callback) {
|
| + DCHECK(!client_.get());
|
|
|
| -void VRServiceImpl::SubmitFrame(uint32_t index, VRPosePtr pose) {
|
| + client_ = std::move(service_client);
|
| VRDeviceManager* device_manager = VRDeviceManager::GetInstance();
|
| - device_manager->SubmitFrame(this, index, std::move(pose));
|
| -}
|
| -
|
| -void VRServiceImpl::UpdateLayerBounds(uint32_t index,
|
| - VRLayerBoundsPtr leftBounds,
|
| - VRLayerBoundsPtr rightBounds) {
|
| - VRDevice* device = VRDeviceManager::GetAllowedDevice(this, index);
|
| - if (device)
|
| - device->UpdateLayerBounds(std::move(leftBounds), std::move(rightBounds));
|
| + // Once a client has been connected AddService will force any VRDisplays to
|
| + // send OnConnected to it so that it's populated with the currently active
|
| + // displays. Thereafer it will stay up to date by virtue of listening for new
|
| + // connected events.
|
| + device_manager->AddService(this);
|
| + callback.Run(device_manager->GetNumberOfConnectedDevices());
|
| }
|
|
|
| } // namespace device
|
|
|