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

Unified Diff: ash/system/chromeos/power/tablet_power_button_controller.cc

Issue 2651313004: chromeos: Avoid shutdown for delayed power button events. (Closed)
Patch Set: switch to two seconds Created 3 years, 11 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: ash/system/chromeos/power/tablet_power_button_controller.cc
diff --git a/ash/system/chromeos/power/tablet_power_button_controller.cc b/ash/system/chromeos/power/tablet_power_button_controller.cc
index fb5c1393b24ff10b0b80aaea7babd2c85a55871c..cb316de4c38c476672dec7963eefd3946c0c7ac4 100644
--- a/ash/system/chromeos/power/tablet_power_button_controller.cc
+++ b/ash/system/chromeos/power/tablet_power_button_controller.cc
@@ -22,8 +22,14 @@ namespace ash {
namespace {
// Amount of time the power button must be held to start the pre-shutdown
-// animation when in tablet mode.
-constexpr int kShutdownTimeoutMs = 500;
+// animation when in tablet mode. This differs depending on whether the screen
+// is on or off when the power button is initially pressed.
+constexpr int kShutdownWhenScreenOnTimeoutMs = 500;
+// TODO(derat): This is currently set to a high value to work around delays in
+// powerd's reports of button-up events when the preceding button-down event
+// turns the display on. Set it to a lower value once powerd no longer blocks on
+// asking Chrome to turn the display on: http://crbug.com/685734
+constexpr int kShutdownWhenScreenOffTimeoutMs = 2000;
// Amount of time since last SuspendDone() that power button event needs to be
// ignored.
@@ -221,9 +227,11 @@ void TabletPowerButtonController::OnGotInitialBacklightsForcedOff(
}
void TabletPowerButtonController::StartShutdownTimer() {
- shutdown_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kShutdownTimeoutMs),
- this, &TabletPowerButtonController::OnShutdownTimeout);
+ base::TimeDelta timeout = base::TimeDelta::FromMilliseconds(
+ screen_off_when_power_button_down_ ? kShutdownWhenScreenOffTimeoutMs
+ : kShutdownWhenScreenOnTimeoutMs);
+ shutdown_timer_.Start(FROM_HERE, timeout, this,
+ &TabletPowerButtonController::OnShutdownTimeout);
}
void TabletPowerButtonController::OnShutdownTimeout() {
« 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