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

Unified Diff: media/video/capture/screen/screen_capturer_win.cc

Issue 12211101: Assert both display and system keep-alive on each capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 7 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/video/capture/screen/screen_capturer_win.cc
diff --git a/media/video/capture/screen/screen_capturer_win.cc b/media/video/capture/screen/screen_capturer_win.cc
index 796af5f85ea86b648598767a10e3fb9ef8914cdb..139b1a01fc21d8c18cfa9b792afde5b8d6369452 100644
--- a/media/video/capture/screen/screen_capturer_win.cc
+++ b/media/video/capture/screen/screen_capturer_win.cc
@@ -132,6 +132,9 @@ class ScreenCapturerWin : public ScreenCapturer {
base::ScopedNativeLibrary dwmapi_library_;
DwmEnableCompositionFunc composition_func_;
+ // Used to suppress duplicate logging of SetThreadExecutionState errors.
+ bool set_thread_execution_state_failed_;
+
DISALLOW_COPY_AND_ASSIGN(ScreenCapturerWin);
};
@@ -203,7 +206,8 @@ void ScreenCaptureFrameWin::AllocateBitmap(HDC desktop_dc,
ScreenCapturerWin::ScreenCapturerWin()
: delegate_(NULL),
desktop_dc_rect_(SkIRect::MakeEmpty()),
- composition_func_(NULL) {
+ composition_func_(NULL),
+ set_thread_execution_state_failed_(false) {
}
ScreenCapturerWin::~ScreenCapturerWin() {
@@ -216,8 +220,14 @@ void ScreenCapturerWin::InvalidateRegion(const SkRegion& invalid_region) {
void ScreenCapturerWin::CaptureFrame() {
base::Time capture_start_time = base::Time::Now();
- // Force the system to power-up display hardware, if it has been suspended.
- SetThreadExecutionState(ES_DISPLAY_REQUIRED);
+ // Request that the system not power-down the system, or the display hardware.
+ if (!SetThreadExecutionState(ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED)) {
+ if (!set_thread_execution_state_failed_) {
+ set_thread_execution_state_failed_ = true;
+ LOG_GETLASTERROR(WARNING)
+ << "Failed to make system & display power assertion";
+ }
+ }
// Make sure the GDI capture resources are up-to-date.
PrepareCaptureResources();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698