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

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

Issue 2296003002: ABANDONED: chromeos: Resume displays when suspend is cancelled. (Closed)
Patch Set: fix comment 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/system/chromeos/power/power_event_observer.cc » ('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 #ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_
6 #define ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ 6 #define ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/cancelable_callback.h"
10 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
12 #include "chromeos/dbus/power_manager_client.h" 14 #include "chromeos/dbus/power_manager_client.h"
13 #include "chromeos/dbus/session_manager_client.h" 15 #include "chromeos/dbus/session_manager_client.h"
14 16
15 namespace ash { 17 namespace ash {
16 18
17 // A class that observes power-management-related events. 19 // A class that observes power-management-related events.
18 class ASH_EXPORT PowerEventObserver 20 class ASH_EXPORT PowerEventObserver
19 : public chromeos::PowerManagerClient::Observer, 21 : public chromeos::PowerManagerClient::Observer,
20 public chromeos::SessionManagerClient::Observer { 22 public chromeos::SessionManagerClient::Observer {
21 public: 23 public:
22 // This class registers/unregisters itself as an observer in ctor/dtor. 24 // This class registers/unregisters itself as an observer in ctor/dtor.
23 PowerEventObserver(); 25 PowerEventObserver();
24 ~PowerEventObserver() override; 26 ~PowerEventObserver() override;
25 27
26 // Called by the WebUIScreenLocker when all the lock screen animations have 28 // Called by the WebUIScreenLocker when all the lock screen animations have
27 // completed. This really should be implemented via an observer but since 29 // completed. This really should be implemented via an observer but since
28 // ash/ isn't allowed to depend on chrome/ we need to have the 30 // ash/ isn't allowed to depend on chrome/ we need to have the
29 // WebUIScreenLocker reach into ash::Shell to make this call. 31 // WebUIScreenLocker reach into ash::Shell to make this call.
30 void OnLockAnimationsComplete(); 32 void OnLockAnimationsComplete();
31 33
32 // chromeos::PowerManagerClient::Observer overrides: 34 // chromeos::PowerManagerClient::Observer overrides:
33 void BrightnessChanged(int level, bool user_initiated) override; 35 void BrightnessChanged(int level, bool user_initiated) override;
34 void SuspendImminent() override; 36 void SuspendImminent() override;
35 void SuspendDone(const base::TimeDelta& sleep_duration) override; 37 void SuspendDone(const base::TimeDelta& sleep_duration) override;
36 38
37 // chromeos::SessionManagerClient::Observer overrides. 39 // chromeos::SessionManagerClient::Observer overrides.
38 void ScreenIsLocked() override; 40 void ScreenIsLocked() override;
39 void ScreenIsUnlocked() override; 41 void ScreenIsUnlocked() override;
40 42
43 private:
44 // Runs ui::DisplayConfigurator::ResumeDisplays() if possible (i.e.
45 // |suspend_displays_in_progress_| is false). Otherwise, sets
46 // |should_undo_suspend_displays_| so this method can be called again once the
47 // in-progress display-suspending finishes.
48 void ResumeDisplays();
49
50 // Callback for ui::DisplayConfigurator::SuspendDisplays().
51 void OnSuspendDisplaysCompleted(const base::Closure& suspend_callback,
52 bool status);
53
41 // Is the screen currently locked? 54 // Is the screen currently locked?
42 bool screen_locked_; 55 bool screen_locked_;
43 56
44 // Have the lock screen animations completed? 57 // Have the lock screen animations completed?
45 bool waiting_for_lock_screen_animations_; 58 bool waiting_for_lock_screen_animations_;
46 59
60 // Is there an in-progress async call to
61 // ui::DisplayConfigurator::SuspendDisplays()?
62 bool suspend_displays_in_progress_;
63
64 // Do we need to undo an in-progress call to
65 // ui::DisplayConfigurator::SuspendDisplays() after it completes?
66 bool should_undo_suspend_displays_;
67
47 // If set, called when the lock screen animations have completed to confirm 68 // If set, called when the lock screen animations have completed to confirm
48 // that the system is ready to be suspended. 69 // that the system is ready to be suspended.
49 base::Closure screen_lock_callback_; 70 base::Closure screen_lock_callback_;
50 71
51 private: 72 // Used by OnSuspendDisplaysCompleted() if |should_undo_suspend_displays_| is
73 // true to run ResumeDisplays(). The task is canceled if it's still pending
74 // when SuspendImminent() is called.
75 base::CancelableClosure undo_suspend_displays_callback_;
76
77 base::WeakPtrFactory<PowerEventObserver> weak_ptr_factory_;
78
52 DISALLOW_COPY_AND_ASSIGN(PowerEventObserver); 79 DISALLOW_COPY_AND_ASSIGN(PowerEventObserver);
53 }; 80 };
54 81
55 } // namespace chromeos 82 } // namespace chromeos
56 83
57 #endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ 84 #endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/system/chromeos/power/power_event_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698