Index: content/browser/media/capture/web_contents_video_capture_device.cc |
diff --git a/content/browser/media/capture/web_contents_video_capture_device.cc b/content/browser/media/capture/web_contents_video_capture_device.cc |
index 8380682fc5064f11b55813af04cb4549994a244e..5a855f5449e80a84b4d15aec3f3e04d82682f508 100644 |
--- a/content/browser/media/capture/web_contents_video_capture_device.cc |
+++ b/content/browser/media/capture/web_contents_video_capture_device.cc |
@@ -218,8 +218,9 @@ class WebContentsCaptureMachine : public VideoCaptureMachine { |
~WebContentsCaptureMachine() override; |
// VideoCaptureMachine overrides. |
- bool Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
- const media::VideoCaptureParams& params) override; |
+ void Start(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
+ const media::VideoCaptureParams& params, |
+ const base::Callback<void(bool)> callback) override; |
void Stop(const base::Closure& callback) override; |
// Starts a copy from the backing store or the composited surface. Must be run |
@@ -233,6 +234,9 @@ class WebContentsCaptureMachine : public VideoCaptureMachine { |
deliver_frame_cb); |
private: |
+ bool InternalStart(const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
+ const media::VideoCaptureParams& params); |
+ void InternalStop(const base::Closure& callback); |
bool IsStarted() const; |
// Computes the preferred size of the target RenderWidget for optimal capture. |
@@ -482,7 +486,22 @@ bool WebContentsCaptureMachine::IsStarted() const { |
return weak_ptr_factory_.HasWeakPtrs(); |
} |
-bool WebContentsCaptureMachine::Start( |
+void WebContentsCaptureMachine::Start( |
+ const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
+ const media::VideoCaptureParams& params, |
+ const base::Callback<void(bool)> callback) { |
+ // Starts the capture machine asynchronously. |
+ BrowserThread::PostTaskAndReplyWithResult( |
+ BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&WebContentsCaptureMachine::InternalStart, |
+ base::Unretained(this), |
+ oracle_proxy, |
+ params), |
+ callback); |
+} |
+ |
+bool WebContentsCaptureMachine::InternalStart( |
const scoped_refptr<ThreadSafeCaptureOracle>& oracle_proxy, |
const media::VideoCaptureParams& params) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
@@ -509,6 +528,15 @@ bool WebContentsCaptureMachine::Start( |
} |
void WebContentsCaptureMachine::Stop(const base::Closure& callback) { |
+ // Stops the capture machine asynchronously. |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, base::Bind( |
+ &WebContentsCaptureMachine::InternalStop, |
+ base::Unretained(this), |
+ callback)); |
+} |
+ |
+void WebContentsCaptureMachine::InternalStop(const base::Closure& callback) { |
DCHECK_CURRENTLY_ON(BrowserThread::UI); |
if (!IsStarted()) { |