Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2602)

Unified Diff: media/capture/video/video_capture_system_impl.cc

Issue 2805863002: Remove VideoCaptureDeviceFactory::EnumerateDeviceDescriptors() (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/video_capture_system_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/video_capture_system_impl.cc
diff --git a/media/capture/video/video_capture_system_impl.cc b/media/capture/video/video_capture_system_impl.cc
index a100468e263e9b3ba77e44ba381f42c4f04cbbe6..bcb4e1219eb94e17bc98467047ef006479d9cdf1 100644
--- a/media/capture/video/video_capture_system_impl.cc
+++ b/media/capture/video/video_capture_system_impl.cc
@@ -68,33 +68,14 @@ VideoCaptureSystemImpl::~VideoCaptureSystemImpl() = default;
void VideoCaptureSystemImpl::GetDeviceInfosAsync(
const DeviceInfoCallback& result_callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- // Use of Unretained() is safe assuming that |result_callback| has ownership
- // of |this|.
- factory_->EnumerateDeviceDescriptors(media::BindToCurrentLoop(
- base::Bind(&VideoCaptureSystemImpl::OnDescriptorsReceived,
- base::Unretained(this), result_callback)));
-}
-
-// Creates a VideoCaptureDevice object. Returns NULL if something goes wrong.
-std::unique_ptr<VideoCaptureDevice> VideoCaptureSystemImpl::CreateDevice(
- const std::string& device_id) {
- DCHECK(thread_checker_.CalledOnValidThread());
- const VideoCaptureDeviceInfo* device_info = LookupDeviceInfoFromId(device_id);
- if (!device_info)
- return nullptr;
- return factory_->CreateDevice(device_info->descriptor);
-}
-
-void VideoCaptureSystemImpl::OnDescriptorsReceived(
- const DeviceInfoCallback& result_callback,
- std::unique_ptr<VideoCaptureDeviceDescriptors> descriptors) {
- DCHECK(thread_checker_.CalledOnValidThread());
+ VideoCaptureDeviceDescriptors descriptors;
+ factory_->GetDeviceDescriptors(&descriptors);
// For devices for which we already have an entry in |devices_info_cache_|,
// we do not want to query the |factory_| for supported formats again. We
// simply copy them from |devices_info_cache_|.
std::vector<VideoCaptureDeviceInfo> new_devices_info_cache;
- new_devices_info_cache.reserve(descriptors->size());
- for (const auto& descriptor : *descriptors) {
+ new_devices_info_cache.reserve(descriptors.size());
+ for (const auto& descriptor : descriptors) {
if (auto* cached_info = LookupDeviceInfoFromId(descriptor.device_id)) {
new_devices_info_cache.push_back(*cached_info);
} else {
@@ -110,6 +91,16 @@ void VideoCaptureSystemImpl::OnDescriptorsReceived(
result_callback.Run(devices_info_cache_);
}
+// Creates a VideoCaptureDevice object. Returns NULL if something goes wrong.
+std::unique_ptr<VideoCaptureDevice> VideoCaptureSystemImpl::CreateDevice(
+ const std::string& device_id) {
+ DCHECK(thread_checker_.CalledOnValidThread());
+ const VideoCaptureDeviceInfo* device_info = LookupDeviceInfoFromId(device_id);
+ if (!device_info)
+ return nullptr;
+ return factory_->CreateDevice(device_info->descriptor);
+}
+
const VideoCaptureDeviceInfo* VideoCaptureSystemImpl::LookupDeviceInfoFromId(
const std::string& device_id) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « media/capture/video/video_capture_system_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698