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

Side by Side Diff: ash/system/chromeos/power/power_event_observer.cc

Issue 1130823003: Wait for display configuration to finish before suspending (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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 unified diff | Download patch
« no previous file with comments | « no previous file | ui/display/chromeos/display_configurator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/chromeos/power/power_event_observer.h" 5 #include "ash/system/chromeos/power/power_event_observer.h"
6 6
7 #include "ash/session/session_state_delegate.h" 7 #include "ash/session/session_state_delegate.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/tray/system_tray_notifier.h" 9 #include "ash/system/tray/system_tray_notifier.h"
10 #include "ash/wm/power_button_controller.h" 10 #include "ash/wm/power_button_controller.h"
(...skipping 19 matching lines...) Expand all
30 } 30 }
31 } 31 }
32 32
33 // Tells the compositor for each of the displays to resume sending rendering 33 // Tells the compositor for each of the displays to resume sending rendering
34 // requests to the GPU. 34 // requests to the GPU.
35 void ResumeRenderingRequests() { 35 void ResumeRenderingRequests() {
36 for (aura::Window* window : Shell::GetAllRootWindows()) 36 for (aura::Window* window : Shell::GetAllRootWindows())
37 window->GetHost()->compositor()->SetVisible(true); 37 window->GetHost()->compositor()->SetVisible(true);
38 } 38 }
39 39
40 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback,
41 bool status) {
42 suspend_callback.Run();
43 }
44
40 } // namespace 45 } // namespace
41 46
42 PowerEventObserver::PowerEventObserver() 47 PowerEventObserver::PowerEventObserver()
43 : screen_locked_(false), waiting_for_lock_screen_animations_(false) { 48 : screen_locked_(false), waiting_for_lock_screen_animations_(false) {
44 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 49 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
45 AddObserver(this); 50 AddObserver(this);
46 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> 51 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()->
47 AddObserver(this); 52 AddObserver(this);
48 } 53 }
49 54
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 screen_lock_callback_ = chromeos::DBusThreadManager::Get() 111 screen_lock_callback_ = chromeos::DBusThreadManager::Get()
107 ->GetPowerManagerClient() 112 ->GetPowerManagerClient()
108 ->GetSuspendReadinessCallback(); 113 ->GetSuspendReadinessCallback();
109 } else { 114 } else {
110 // The lock-before-suspending pref is not set or the screen has already been 115 // The lock-before-suspending pref is not set or the screen has already been
111 // locked and the animations have completed. Rendering can be stopped now. 116 // locked and the animations have completed. Rendering can be stopped now.
112 StopRenderingRequests(); 117 StopRenderingRequests();
113 } 118 }
114 119
115 ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); 120 ui::UserActivityDetector::Get()->OnDisplayPowerChanging();
116 shell->display_configurator()->SuspendDisplays(); 121 shell->display_configurator()->SuspendDisplays(base::Bind(
122 &OnSuspendDisplaysCompleted, chromeos::DBusThreadManager::Get()
123 ->GetPowerManagerClient()
124 ->GetSuspendReadinessCallback()));
117 } 125 }
118 126
119 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { 127 void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) {
120 Shell::GetInstance()->display_configurator()->ResumeDisplays(); 128 Shell::GetInstance()->display_configurator()->ResumeDisplays();
121 Shell::GetInstance()->system_tray_notifier()->NotifyRefreshClock(); 129 Shell::GetInstance()->system_tray_notifier()->NotifyRefreshClock();
122 130
123 // If the suspend request was being blocked while waiting for the lock 131 // If the suspend request was being blocked while waiting for the lock
124 // animation to complete, clear the blocker since the suspend has already 132 // animation to complete, clear the blocker since the suspend has already
125 // completed. This prevents rendering requests from being blocked after a 133 // completed. This prevents rendering requests from being blocked after a
126 // resume if the lock screen took too long to show. 134 // resume if the lock screen took too long to show.
(...skipping 13 matching lines...) Expand all
140 } else { 148 } else {
141 VLOG(1) << "Screen locked without suspend"; 149 VLOG(1) << "Screen locked without suspend";
142 } 150 }
143 } 151 }
144 152
145 void PowerEventObserver::ScreenIsUnlocked() { 153 void PowerEventObserver::ScreenIsUnlocked() {
146 screen_locked_ = false; 154 screen_locked_ = false;
147 } 155 }
148 156
149 } // namespace ash 157 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/display/chromeos/display_configurator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698