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

Unified Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2005753006: ImageCapture: ScopedResultCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: miu@s comments Created 4 years, 7 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
Index: content/browser/renderer_host/media/video_capture_manager.cc
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 5756ae95387e08616d08466d3af1b113fa64c40e..f7b556dec2c30c49c925aa9da5bad176fd856a5e 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -840,36 +840,23 @@ void VideoCaptureManager::MaybePostDesktopCaptureWindowId(
notification_window_ids_.erase(window_id_it);
}
-bool VideoCaptureManager::TakePhoto(
+void VideoCaptureManager::TakePhoto(
int session_id,
- const VideoCaptureDevice::TakePhotoCallback& photo_callback) {
+ media::ScopedCallback<VideoCaptureDevice::TakePhotoCallback> callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
SessionMap::const_iterator session_it = sessions_.find(session_id);
if (session_it == sessions_.end())
- return false;
+ return;
DeviceEntry* const device_info =
GetDeviceEntryForMediaStreamDevice(session_it->second);
if (!device_info)
- return false;
+ return;
device_task_runner_->PostTask(
FROM_HERE,
- base::Bind(&VideoCaptureManager::DoTakePhotoOnDeviceThread, this,
- device_info->video_capture_device(), photo_callback));
- return true;
-}
-
-void VideoCaptureManager::DoTakePhotoOnDeviceThread(
- media::VideoCaptureDevice* device,
- const VideoCaptureDevice::TakePhotoCallback& photo_callback) {
- DCHECK(IsOnDeviceThread());
- if (device->TakePhoto(photo_callback))
- return;
-
- // TakePhoto() failed synchronously: Make sure |photo_callback| is Run().
- std::unique_ptr<std::vector<uint8_t>> empty_vector(
- new std::vector<uint8_t>());
- photo_callback.Run("", std::move(empty_vector));
+ base::Bind(&VideoCaptureDevice::TakePhoto,
+ base::Unretained(device_info->video_capture_device()),
+ base::Passed(&callback)));
}
void VideoCaptureManager::DoStopDeviceOnDeviceThread(

Powered by Google App Engine
This is Rietveld 408576698