OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/browser/renderer_host/media/service_video_capture_device_launc
her.h" | 5 #include "content/browser/renderer_host/media/service_video_capture_device_launc
her.h" |
6 | 6 |
7 #include "content/browser/renderer_host/media/service_launched_video_capture_dev
ice.h" | 7 #include "content/browser/renderer_host/media/service_launched_video_capture_dev
ice.h" |
8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
9 #include "media/capture/video/video_frame_receiver_on_task_runner.h" | 9 #include "media/capture/video/video_frame_receiver_on_task_runner.h" |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 if (!device_factory_->is_bound()) { | 83 if (!device_factory_->is_bound()) { |
84 // This can happen when the ServiceVideoCaptureProvider owning | 84 // This can happen when the ServiceVideoCaptureProvider owning |
85 // |device_factory_| loses connection to the service process and resets | 85 // |device_factory_| loses connection to the service process and resets |
86 // |device_factory_|. | 86 // |device_factory_|. |
87 ConcludeLaunchDeviceWithFailure(false, callbacks, std::move(done_cb)); | 87 ConcludeLaunchDeviceWithFailure(false, callbacks, std::move(done_cb)); |
88 return; | 88 return; |
89 } | 89 } |
90 video_capture::mojom::DevicePtr device; | 90 video_capture::mojom::DevicePtr device; |
91 // We need the temporary variable |device_request| in order to guarantee that | |
92 // mojo::MakeRequest(&device) happens before base::Passed(&device). | |
93 auto device_request = mojo::MakeRequest(&device); | |
94 (*device_factory_) | 91 (*device_factory_) |
95 ->CreateDevice( | 92 ->CreateDevice( |
96 device_id, std::move(device_request), | 93 device_id, mojo::MakeRequest(&device), |
97 base::Bind( | 94 base::Bind( |
98 // Use of Unretained |this| is safe, because |done_cb| guarantees | 95 // Use of Unretained |this| is safe, because |done_cb| guarantees |
99 // that |this| stays alive. | 96 // that |this| stays alive. |
100 &ServiceVideoCaptureDeviceLauncher::OnCreateDeviceCallback, | 97 &ServiceVideoCaptureDeviceLauncher::OnCreateDeviceCallback, |
101 base::Unretained(this), params, base::Passed(&device), | 98 base::Unretained(this), params, base::Passed(&device), |
102 std::move(receiver), callbacks, base::Passed(&done_cb))); | 99 std::move(receiver), callbacks, base::Passed(&done_cb))); |
103 state_ = State::DEVICE_START_IN_PROGRESS; | 100 state_ = State::DEVICE_START_IN_PROGRESS; |
104 } | 101 } |
105 | 102 |
106 void ServiceVideoCaptureDeviceLauncher::AbortLaunch() { | 103 void ServiceVideoCaptureDeviceLauncher::AbortLaunch() { |
(...skipping 20 matching lines...) Expand all Loading... |
127 return; | 124 return; |
128 case video_capture::mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND: | 125 case video_capture::mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND: |
129 case video_capture::mojom::DeviceAccessResultCode::NOT_INITIALIZED: | 126 case video_capture::mojom::DeviceAccessResultCode::NOT_INITIALIZED: |
130 ConcludeLaunchDeviceWithFailure(abort_requested, callbacks, | 127 ConcludeLaunchDeviceWithFailure(abort_requested, callbacks, |
131 std::move(done_cb)); | 128 std::move(done_cb)); |
132 return; | 129 return; |
133 } | 130 } |
134 } | 131 } |
135 | 132 |
136 } // namespace content | 133 } // namespace content |
OLD | NEW |