Chromium Code Reviews| Index: content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc |
| diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc |
| index f34de98ff20cb09a577c667e02273e03c2356080..449ed097eacc153117f0d453ffc23c565d777575 100644 |
| --- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc |
| +++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc |
| @@ -57,9 +57,9 @@ namespace content { |
| InProcessVideoCaptureDeviceLauncher::InProcessVideoCaptureDeviceLauncher( |
| scoped_refptr<base::SingleThreadTaskRunner> device_task_runner, |
| - media::VideoCaptureSystem* video_capture_system) |
| + media::VideoCaptureSystem* optional_video_capture_system) |
| : device_task_runner_(std::move(device_task_runner)), |
| - video_capture_system_(video_capture_system), |
| + optional_video_capture_system_(optional_video_capture_system), |
| state_(State::READY_TO_LAUNCH) {} |
| InProcessVideoCaptureDeviceLauncher::~InProcessVideoCaptureDeviceLauncher() { |
| @@ -92,6 +92,11 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync( |
| switch (stream_type) { |
| case MEDIA_DEVICE_VIDEO_CAPTURE: { |
| + if (!optional_video_capture_system_) { |
| + callbacks->OnDeviceLaunchFailed(); |
| + base::ResetAndReturn(&done_cb).Run(); |
| + return; |
| + } |
| start_capture_closure = |
| base::Bind(&InProcessVideoCaptureDeviceLauncher:: |
| DoStartDeviceCaptureOnDeviceThread, |
| @@ -165,9 +170,11 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted( |
| switch (state_copy) { |
| case State::DEVICE_START_IN_PROGRESS: |
| callbacks->OnDeviceLaunchFailed(); |
| + base::ResetAndReturn(&done_cb).Run(); |
| return; |
| case State::DEVICE_START_ABORTING: |
| callbacks->OnDeviceLaunchAborted(); |
| + base::ResetAndReturn(&done_cb).Run(); |
| return; |
| case State::READY_TO_LAUNCH: |
| NOTREACHED(); |
| @@ -181,16 +188,17 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted( |
| switch (state_copy) { |
| case State::DEVICE_START_IN_PROGRESS: |
| callbacks->OnDeviceLaunched(std::move(launched_device)); |
| + base::ResetAndReturn(&done_cb).Run(); |
| return; |
| case State::DEVICE_START_ABORTING: |
| launched_device.reset(); |
| callbacks->OnDeviceLaunchAborted(); |
| + base::ResetAndReturn(&done_cb).Run(); |
| return; |
| case State::READY_TO_LAUNCH: |
| NOTREACHED(); |
| return; |
| } |
|
mcasas
2017/05/16 22:22:22
If we want to run |done_cb| in every possible retu
chfremer
2017/05/16 22:45:02
Agreed that this would be better and cleaner. Unfo
|
| - base::ResetAndReturn(&done_cb).Run(); |
| } |
| void InProcessVideoCaptureDeviceLauncher::DoStartDeviceCaptureOnDeviceThread( |
| @@ -202,7 +210,7 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDeviceCaptureOnDeviceThread( |
| DCHECK(device_task_runner_->BelongsToCurrentThread()); |
| std::unique_ptr<media::VideoCaptureDevice> video_capture_device = |
| - video_capture_system_->CreateDevice(device_id); |
| + optional_video_capture_system_->CreateDevice(device_id); |
|
mcasas
2017/05/16 22:22:22
If it's optional, we should check if (optional_vid
chfremer
2017/05/16 22:45:01
True. There is already a check in LaunchDeviceAsyn
|
| if (!video_capture_device) { |
| result_callback.Run(nullptr); |