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

Unified Diff: content/browser/media/capture/web_contents_video_capture_device.cc

Issue 1140113002: Implement screen capture for android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ScreenCaptureMachineAndroid which inherited from content::VideoCaptureMachine Created 5 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/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()) {

Powered by Google App Engine
This is Rietveld 408576698