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

Side by Side Diff: content/renderer/media/capture_video_decoder.cc

Issue 9717021: Make Callback::Reset() return a copy to support use-cases where Run() ends up modifying |*this|. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: no base:: Created 8 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/callback_unittest.cc ('k') | media/base/composite_filter.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/media/capture_video_decoder.h" 5 #include "content/renderer/media/capture_video_decoder.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h"
8 #include "content/renderer/media/video_capture_impl_manager.h" 9 #include "content/renderer/media/video_capture_impl_manager.h"
9 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
10 #include "media/base/limits.h" 11 #include "media/base/limits.h"
11 #include "media/base/video_util.h" 12 #include "media/base/video_util.h"
12 13
13 using media::CopyYPlane; 14 using media::CopyYPlane;
14 using media::CopyUPlane; 15 using media::CopyUPlane;
15 using media::CopyVPlane; 16 using media::CopyVPlane;
16 17
17 CaptureVideoDecoder::CaptureVideoDecoder( 18 CaptureVideoDecoder::CaptureVideoDecoder(
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 196
196 cb.Run(media::PIPELINE_OK); 197 cb.Run(media::PIPELINE_OK);
197 state_ = kNormal; 198 state_ = kNormal;
198 } 199 }
199 200
200 void CaptureVideoDecoder::OnStoppedOnDecoderThread( 201 void CaptureVideoDecoder::OnStoppedOnDecoderThread(
201 media::VideoCapture* capture) { 202 media::VideoCapture* capture) {
202 DVLOG(1) << "OnStoppedOnDecoderThread"; 203 DVLOG(1) << "OnStoppedOnDecoderThread";
203 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 204 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
204 if (!pending_stop_cb_.is_null()) 205 if (!pending_stop_cb_.is_null())
205 media::ResetAndRunCB(&pending_stop_cb_); 206 base::ResetAndReturn(&pending_stop_cb_).Run();
206 vc_manager_->RemoveDevice(video_stream_id_, this); 207 vc_manager_->RemoveDevice(video_stream_id_, this);
207 } 208 }
208 209
209 void CaptureVideoDecoder::OnDeviceInfoReceivedOnDecoderThread( 210 void CaptureVideoDecoder::OnDeviceInfoReceivedOnDecoderThread(
210 media::VideoCapture* capture, 211 media::VideoCapture* capture,
211 const media::VideoCaptureParams& device_info) { 212 const media::VideoCaptureParams& device_info) {
212 DCHECK(message_loop_proxy_->BelongsToCurrentThread()); 213 DCHECK(message_loop_proxy_->BelongsToCurrentThread());
213 if (device_info.width != natural_size_.width() || 214 if (device_info.width != natural_size_.width() ||
214 device_info.height != natural_size_.height()) { 215 device_info.height != natural_size_.height()) {
215 natural_size_.SetSize(device_info.width, device_info.height); 216 natural_size_.SetSize(device_info.width, device_info.height);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 capture->FeedBuffer(buf); 278 capture->FeedBuffer(buf);
278 } 279 }
279 280
280 void CaptureVideoDecoder::DeliverFrame( 281 void CaptureVideoDecoder::DeliverFrame(
281 const scoped_refptr<media::VideoFrame>& video_frame) { 282 const scoped_refptr<media::VideoFrame>& video_frame) {
282 // Reset the callback before running to protect against reentrancy. 283 // Reset the callback before running to protect against reentrancy.
283 ReadCB read_cb = read_cb_; 284 ReadCB read_cb = read_cb_;
284 read_cb_.Reset(); 285 read_cb_.Reset();
285 read_cb.Run(video_frame); 286 read_cb.Run(video_frame);
286 } 287 }
OLDNEW
« no previous file with comments | « base/callback_unittest.cc ('k') | media/base/composite_filter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698