Index: content/renderer/media/video_capture_impl.cc |
=================================================================== |
--- content/renderer/media/video_capture_impl.cc (revision 102594) |
+++ content/renderer/media/video_capture_impl.cc (working copy) |
@@ -5,6 +5,7 @@ |
#include "content/renderer/media/video_capture_impl.h" |
#include "base/stl_util.h" |
+#include "base/synchronization/waitable_event.h" |
#include "content/common/child_process.h" |
#include "content/common/media/video_capture_messages.h" |
@@ -94,9 +95,19 @@ |
capability)); |
} |
-void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler) { |
- ml_proxy_->PostTask(FROM_HERE, |
- NewRunnableMethod(this, &VideoCaptureImpl::DoStopCapture, handler)); |
+void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler, |
+ bool need_notification) { |
+ if (need_notification) { |
+ ml_proxy_->PostTask(FROM_HERE, |
+ NewRunnableMethod(this, &VideoCaptureImpl::DoStopCapture, handler, |
+ static_cast<base::WaitableEvent*>(NULL))); |
+ } else { |
+ base::WaitableEvent completion(false, false); |
+ ml_proxy_->PostTask(FROM_HERE, |
+ NewRunnableMethod(this, &VideoCaptureImpl::DoStopCapture, handler, |
+ &completion)); |
+ completion.Wait(); |
+ } |
} |
void VideoCaptureImpl::FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) { |
@@ -213,20 +224,27 @@ |
} |
void VideoCaptureImpl::DoStopCapture( |
- media::VideoCapture::EventHandler* handler) { |
+ media::VideoCapture::EventHandler* handler, |
+ base::WaitableEvent* completion) { |
DCHECK(ml_proxy_->BelongsToCurrentThread()); |
ClientInfo::iterator it = pending_clients_.find(handler); |
if (it != pending_clients_.end()) { |
- handler->OnStopped(this); |
pending_clients_.erase(it); |
+ if (!completion) |
+ handler->OnStopped(this); |
+ else |
+ completion->Signal(); |
return; |
} |
if (clients_.find(handler) == clients_.end()) |
return; |
- handler->OnStopped(this); |
+ if (!completion) |
+ handler->OnStopped(this); |
+ else |
+ completion->Signal(); |
clients_.erase(handler); |
master_clients_.remove(handler); |