| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "media/capture/video/fake_video_capture_device.h" | 9 #include "media/capture/video/fake_video_capture_device.h" |
| 10 #include "services/video_capture/video_capture_device_factory_impl.h" | 10 #include "services/video_capture/video_capture_device_factory_impl.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return descriptor_.Equals(other); | 39 return descriptor_.Equals(other); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const { | 42 bool VideoCaptureDeviceFactoryImpl::DeviceEntry::is_bound() const { |
| 43 return binding_->is_bound(); | 43 return binding_->is_bound(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind( | 46 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Bind( |
| 47 mojom::VideoCaptureDeviceProxyRequest request) { | 47 mojom::VideoCaptureDeviceProxyRequest request) { |
| 48 binding_->Bind(std::move(request)); | 48 binding_->Bind(std::move(request)); |
| 49 binding_->set_connection_error_handler(base::Bind( |
| 50 &VideoCaptureDeviceFactoryImpl::DeviceEntry::OnConnectionErrorOrClose, |
| 51 base::Unretained(this))); |
| 49 } | 52 } |
| 50 | 53 |
| 51 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() { | 54 void VideoCaptureDeviceFactoryImpl::DeviceEntry::Unbind() { |
| 52 binding_->Unbind(); | 55 binding_->Unbind(); |
| 56 device_proxy_->Stop(); |
| 57 } |
| 58 |
| 59 void VideoCaptureDeviceFactoryImpl::DeviceEntry::OnConnectionErrorOrClose() { |
| 60 Unbind(); |
| 53 } | 61 } |
| 54 | 62 |
| 55 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default; | 63 VideoCaptureDeviceFactoryImpl::VideoCaptureDeviceFactoryImpl() = default; |
| 56 | 64 |
| 57 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default; | 65 VideoCaptureDeviceFactoryImpl::~VideoCaptureDeviceFactoryImpl() = default; |
| 58 | 66 |
| 59 void VideoCaptureDeviceFactoryImpl::AddDevice( | 67 void VideoCaptureDeviceFactoryImpl::AddDevice( |
| 60 mojom::VideoCaptureDeviceDescriptorPtr descriptor, | 68 mojom::VideoCaptureDeviceDescriptorPtr descriptor, |
| 61 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) { | 69 std::unique_ptr<VideoCaptureDeviceProxyImpl> device) { |
| 62 devices_.emplace_back(std::move(descriptor), std::move(device)); | 70 devices_.emplace_back(std::move(descriptor), std::move(device)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 86 entry.Unbind(); | 94 entry.Unbind(); |
| 87 entry.Bind(std::move(proxy_request)); | 95 entry.Bind(std::move(proxy_request)); |
| 88 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); | 96 callback.Run(mojom::DeviceAccessResultCode::SUCCESS); |
| 89 return; | 97 return; |
| 90 } | 98 } |
| 91 } | 99 } |
| 92 callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND); | 100 callback.Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND); |
| 93 } | 101 } |
| 94 | 102 |
| 95 } // namespace video_capture | 103 } // namespace video_capture |
| OLD | NEW |