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

Unified Diff: media/capture/content/screen_capture_device_core.cc

Issue 2364413002: Screen Video Capture: Implement suspend optimization. (Closed)
Patch Set: Created 4 years, 3 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/content/screen_capture_device_core.cc
diff --git a/media/capture/content/screen_capture_device_core.cc b/media/capture/content/screen_capture_device_core.cc
index 0f06dfa51c5d59f4d73c3539873558ceaeb81452..728581aef8f911e1791c44ddfb81e034f898482a 100644
--- a/media/capture/content/screen_capture_device_core.cc
+++ b/media/capture/content/screen_capture_device_core.cc
@@ -69,7 +69,7 @@ void ScreenCaptureDeviceCore::AllocateAndStart(
void ScreenCaptureDeviceCore::RequestRefreshFrame() {
DCHECK(thread_checker_.CalledOnValidThread());
- if (state_ != kCapturing)
+ if (state_ != kCapturing && state_ != kSuspended)
return;
if (oracle_proxy_->AttemptPassiveRefresh())
@@ -77,12 +77,34 @@ void ScreenCaptureDeviceCore::RequestRefreshFrame() {
capture_machine_->MaybeCaptureForRefresh();
}
-void ScreenCaptureDeviceCore::StopAndDeAllocate() {
+void ScreenCaptureDeviceCore::Suspend() {
DCHECK(thread_checker_.CalledOnValidThread());
if (state_ != kCapturing)
return;
+ TransitionStateTo(kSuspended);
+
+ capture_machine_->Suspend();
+}
+
+void ScreenCaptureDeviceCore::Resume() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (state_ != kSuspended)
+ return;
+
+ TransitionStateTo(kCapturing);
+
+ capture_machine_->Resume();
+}
+
+void ScreenCaptureDeviceCore::StopAndDeAllocate() {
+ DCHECK(thread_checker_.CalledOnValidThread());
+
+ if (state_ != kCapturing && state_ != kSuspended)
+ return;
+
oracle_proxy_->Stop();
oracle_proxy_ = NULL;
@@ -105,7 +127,7 @@ ScreenCaptureDeviceCore::ScreenCaptureDeviceCore(
ScreenCaptureDeviceCore::~ScreenCaptureDeviceCore() {
DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK_NE(state_, kCapturing);
+ DCHECK(state_ != kCapturing && state_ != kSuspended);
if (capture_machine_) {
capture_machine_->Stop(
base::Bind(&DeleteCaptureMachine, base::Passed(&capture_machine_)));
@@ -117,7 +139,8 @@ void ScreenCaptureDeviceCore::TransitionStateTo(State next_state) {
DCHECK(thread_checker_.CalledOnValidThread());
#ifndef NDEBUG
- static const char* kStateNames[] = {"Idle", "Capturing", "Error"};
+ static constexpr char* kStateNames[] = {"Idle", "Capturing", "Suspended",
braveyao 2016/09/26 17:14:47 Compiling failure for Android: ISO C++11 does not
miu 2016/09/27 20:46:50 Fixed.
+ "Error"};
static_assert(arraysize(kStateNames) == kLastCaptureState,
"Different number of states and textual descriptions");
DVLOG(1) << "State change: " << kStateNames[state_] << " --> "

Powered by Google App Engine
This is Rietveld 408576698