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

Side by Side Diff: ash/wm/lock_state_controller.h

Issue 2497123002: chromeos: Move device shutdown handling out of chrome into ash (Closed)
Patch Set: Created 4 years, 1 month 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
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 #ifndef ASH_WM_LOCK_STATE_CONTROLLER_H_ 5 #ifndef ASH_WM_LOCK_STATE_CONTROLLER_H_
6 #define ASH_WM_LOCK_STATE_CONTROLLER_H_ 6 #define ASH_WM_LOCK_STATE_CONTROLLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_export.h" 10 #include "ash/ash_export.h"
11 #include "ash/common/shell_observer.h" 11 #include "ash/common/shell_observer.h"
12 #include "ash/wm/session_state_animator.h" 12 #include "ash/wm/session_state_animator.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/timer/elapsed_timer.h" 16 #include "base/timer/elapsed_timer.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "ui/aura/window_tree_host_observer.h" 18 #include "ui/aura/window_tree_host_observer.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 class Rect; 21 class Rect;
22 class Size; 22 class Size;
23 } 23 }
24 24
25 namespace service_manager {
26 class Connector;
27 }
28
29 namespace ui { 25 namespace ui {
30 class Layer; 26 class Layer;
31 } 27 }
32 28
33 namespace ash { 29 namespace ash {
34 30
35 namespace mojom { 31 class ShutdownController;
36 class ShutdownClient;
37 }
38 32
39 namespace test { 33 namespace test {
40 class LockStateControllerTest; 34 class LockStateControllerTest;
41 class LockStateControllerTestApi; 35 class LockStateControllerTestApi;
42 class PowerButtonControllerTest; 36 class PowerButtonControllerTest;
43 } 37 }
44 38
45 // Displays onscreen animations and locks or suspends the system in response to 39 // Displays onscreen animations and locks or suspends the system in response to
46 // the power button being pressed or released. 40 // the power button being pressed or released.
47 // Lock workflow: 41 // Lock workflow:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // When the button has been held continuously from the unlocked state, amount 76 // When the button has been held continuously from the unlocked state, amount
83 // of time that we wait after the screen locker window is shown before 77 // of time that we wait after the screen locker window is shown before
84 // starting the pre-shutdown animation. 78 // starting the pre-shutdown animation.
85 static const int kLockToShutdownTimeoutMs; 79 static const int kLockToShutdownTimeoutMs;
86 80
87 // Additional time (beyond kFastCloseAnimMs) to wait after starting the 81 // Additional time (beyond kFastCloseAnimMs) to wait after starting the
88 // fast-close shutdown animation before actually requesting shutdown, to give 82 // fast-close shutdown animation before actually requesting shutdown, to give
89 // the animation time to finish. 83 // the animation time to finish.
90 static const int kShutdownRequestDelayMs; 84 static const int kShutdownRequestDelayMs;
91 85
92 explicit LockStateController(service_manager::Connector* connector); 86 explicit LockStateController(ShutdownController* shutdown_controller);
93 ~LockStateController() override; 87 ~LockStateController() override;
94 88
95 // Starts locking (with slow animation) that can be cancelled. 89 // Starts locking (with slow animation) that can be cancelled.
96 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation() 90 // After locking and |kLockToShutdownTimeoutMs| StartShutdownAnimation()
97 // will be called unless CancelShutdownAnimation() is called, if 91 // will be called unless CancelShutdownAnimation() is called, if
98 // |shutdown_after_lock| is true. 92 // |shutdown_after_lock| is true.
99 void StartLockAnimation(bool shutdown_after_lock); 93 void StartLockAnimation(bool shutdown_after_lock);
100 94
101 // Starts shutting down (with slow animation) that can be cancelled. 95 // Starts shutting down (with slow animation) that can be cancelled.
102 void StartShutdownAnimation(); 96 void StartShutdownAnimation();
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 bool animating_lock_; 234 bool animating_lock_;
241 235
242 // Indicates that lock animation can be undone. 236 // Indicates that lock animation can be undone.
243 bool can_cancel_lock_animation_; 237 bool can_cancel_lock_animation_;
244 238
245 std::unique_ptr<UnlockedStateProperties> unlocked_properties_; 239 std::unique_ptr<UnlockedStateProperties> unlocked_properties_;
246 240
247 // How long has it been since the request to lock the screen? 241 // How long has it been since the request to lock the screen?
248 std::unique_ptr<base::ElapsedTimer> lock_duration_timer_; 242 std::unique_ptr<base::ElapsedTimer> lock_duration_timer_;
249 243
250 // The client that we request to shut down the machine. 244 // Controller used to trigger the actual shut down.
Daniel Erat 2016/11/14 15:42:41 nit: s/shut down/shutdown/
James Cook 2016/11/14 17:21:39 Done.
251 std::unique_ptr<mojom::ShutdownClient> shutdown_client_; 245 ShutdownController* shutdown_controller_;
252 246
253 // Started when we request that the screen be locked. When it fires, we 247 // Started when we request that the screen be locked. When it fires, we
254 // assume that our request got dropped. 248 // assume that our request got dropped.
255 base::OneShotTimer lock_fail_timer_; 249 base::OneShotTimer lock_fail_timer_;
256 250
257 // Started when the screen is locked while the power button is held. Adds a 251 // Started when the screen is locked while the power button is held. Adds a
258 // delay between the appearance of the lock screen and the beginning of the 252 // delay between the appearance of the lock screen and the beginning of the
259 // pre-shutdown animation. 253 // pre-shutdown animation.
260 base::OneShotTimer lock_to_shutdown_timer_; 254 base::OneShotTimer lock_to_shutdown_timer_;
261 255
262 // Started when we begin displaying the pre-shutdown animation. When it 256 // Started when we begin displaying the pre-shutdown animation. When it
263 // fires, we start the shutdown animation and get ready to request shutdown. 257 // fires, we start the shutdown animation and get ready to request shutdown.
264 base::OneShotTimer pre_shutdown_timer_; 258 base::OneShotTimer pre_shutdown_timer_;
265 259
266 // Started when we display the shutdown animation. When it fires, we actually 260 // Started when we display the shutdown animation. When it fires, we actually
267 // request shutdown. Gives the animation time to complete before Chrome, X, 261 // request shutdown. Gives the animation time to complete before Chrome, X,
268 // etc. are shut down. 262 // etc. are shut down.
269 base::OneShotTimer real_shutdown_timer_; 263 base::OneShotTimer real_shutdown_timer_;
270 264
271 base::Closure lock_screen_displayed_callback_; 265 base::Closure lock_screen_displayed_callback_;
272 266
273 base::WeakPtrFactory<LockStateController> weak_ptr_factory_; 267 base::WeakPtrFactory<LockStateController> weak_ptr_factory_;
274 268
275 DISALLOW_COPY_AND_ASSIGN(LockStateController); 269 DISALLOW_COPY_AND_ASSIGN(LockStateController);
276 }; 270 };
277 271
278 } // namespace ash 272 } // namespace ash
279 273
280 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_ 274 #endif // ASH_WM_LOCK_STATE_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698