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

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

Issue 2005753006: ImageCapture: ScopedResultCallback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reillyg@ second round of 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: media/capture/video/fake_video_capture_device.cc
diff --git a/media/capture/video/fake_video_capture_device.cc b/media/capture/video/fake_video_capture_device.cc
index 9e1479d81cfd44ec20c3d1deacaf0dafd3a28a2f..a20efb860f30bf249400729a1fda86a520df435a 100644
--- a/media/capture/video/fake_video_capture_device.cc
+++ b/media/capture/video/fake_video_capture_device.cc
@@ -75,25 +75,26 @@ void DrawPacman(bool use_argb,
// Creates a PNG-encoded frame and sends it back to |callback|. The other
// parameters are used to replicate the PacMan rendering.
-void DoTakeFakePhoto(const VideoCaptureDevice::TakePhotoCallback& callback,
- const VideoCaptureFormat& capture_format,
- base::TimeDelta elapsed_time,
- float fake_capture_rate) {
+void DoTakeFakePhoto(
+ ScopedCallback<VideoCaptureDevice::TakePhotoCallback> callback,
+ const VideoCaptureFormat& capture_format,
+ base::TimeDelta elapsed_time,
+ float fake_capture_rate) {
std::unique_ptr<uint8_t[]> buffer(new uint8_t[VideoFrame::AllocationSize(
PIXEL_FORMAT_ARGB, capture_format.frame_size)]);
DrawPacman(true /* use_argb */, buffer.get(), elapsed_time, fake_capture_rate,
capture_format.frame_size);
- std::unique_ptr<std::vector<uint8_t>> encoded_data(
- new std::vector<uint8_t>());
+ std::vector<uint8_t> encoded_data;
const bool result = gfx::PNGCodec::Encode(
buffer.get(), gfx::PNGCodec::FORMAT_RGBA, capture_format.frame_size,
capture_format.frame_size.width() * 4, true /* discard_transparency */,
- std::vector<gfx::PNGCodec::Comment>(), encoded_data.get());
+ std::vector<gfx::PNGCodec::Comment>(), &encoded_data);
DCHECK(result);
- callback.Run("image/png", std::move(encoded_data));
+ callback.PassCallback().Run("image/png",
+ mojo::Array<uint8_t>::From(encoded_data));
}
FakeVideoCaptureDevice::FakeVideoCaptureDevice(BufferOwnership buffer_ownership,
@@ -161,12 +162,12 @@ void FakeVideoCaptureDevice::StopAndDeAllocate() {
client_.reset();
}
-bool FakeVideoCaptureDevice::TakePhoto(
- const TakePhotoCallback& photo_callback) {
+void FakeVideoCaptureDevice::TakePhoto(
+ ScopedCallback<TakePhotoCallback> callback) {
base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(&DoTakeFakePhoto, photo_callback, capture_format_,
- elapsed_time_, fake_capture_rate_));
- return true;
+ FROM_HERE,
+ base::Bind(&DoTakeFakePhoto, base::Passed(&callback), capture_format_,
+ elapsed_time_, fake_capture_rate_));
}
void FakeVideoCaptureDevice::CaptureUsingOwnBuffers(

Powered by Google App Engine
This is Rietveld 408576698