| OLD | NEW |
| 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_SUSPEND_OBSERVER_H_ | 5 #ifndef ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ |
| 6 #define ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_ | 6 #define ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chromeos/dbus/power_manager_client.h" | 11 #include "chromeos/dbus/power_manager_client.h" |
| 12 #include "chromeos/dbus/session_manager_client.h" | 12 #include "chromeos/dbus/session_manager_client.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 // A class to observe suspend events. | 17 // A class that observes power-management-related events. |
| 18 class SuspendObserver : public chromeos::PowerManagerClient::Observer, | 18 class PowerEventObserver : public chromeos::PowerManagerClient::Observer, |
| 19 public chromeos::SessionManagerClient::Observer { | 19 public chromeos::SessionManagerClient::Observer { |
| 20 public: | 20 public: |
| 21 // This class registers/unregisters itself as an observer in ctor/dtor. | 21 // This class registers/unregisters itself as an observer in ctor/dtor. |
| 22 SuspendObserver(); | 22 PowerEventObserver(); |
| 23 virtual ~SuspendObserver(); | 23 virtual ~PowerEventObserver(); |
| 24 | 24 |
| 25 // chromeos::PowerManagerClient::Observer override. | 25 // chromeos::PowerManagerClient::Observer overrides: |
| 26 virtual void BrightnessChanged(int level, bool user_initiated) OVERRIDE; |
| 26 virtual void SuspendImminent() OVERRIDE; | 27 virtual void SuspendImminent() OVERRIDE; |
| 28 virtual void SystemResumed(const base::TimeDelta& sleep_duration) OVERRIDE; |
| 27 | 29 |
| 28 // chromeos::SessionManagerClient::Observer overrides. | 30 // chromeos::SessionManagerClient::Observer overrides. |
| 29 virtual void ScreenIsLocked() OVERRIDE; | 31 virtual void ScreenIsLocked() OVERRIDE; |
| 30 virtual void ScreenIsUnlocked() OVERRIDE; | 32 virtual void ScreenIsUnlocked() OVERRIDE; |
| 31 | 33 |
| 32 private: | |
| 33 chromeos::PowerManagerClient* power_client_; // not owned | |
| 34 chromeos::SessionManagerClient* session_client_; // not owned | |
| 35 | |
| 36 // Is the screen currently locked? | 34 // Is the screen currently locked? |
| 37 bool screen_locked_; | 35 bool screen_locked_; |
| 38 | 36 |
| 39 // If set, called when the lock screen has been shown to confirm that the | 37 // If set, called when the lock screen has been shown to confirm that the |
| 40 // system is ready to be suspended. | 38 // system is ready to be suspended. |
| 41 base::Closure screen_lock_callback_; | 39 base::Closure screen_lock_callback_; |
| 42 | 40 |
| 43 DISALLOW_COPY_AND_ASSIGN(SuspendObserver); | 41 private: |
| 42 DISALLOW_COPY_AND_ASSIGN(PowerEventObserver); |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 } // namespace internal | 45 } // namespace internal |
| 47 } // namespace ash | 46 } // namespace chromeos |
| 48 | 47 |
| 49 #endif // ASH_SYSTEM_CHROMEOS_POWER_SUSPEND_OBSERVER_H_ | 48 #endif // ASH_SYSTEM_CHROMEOS_POWER_POWER_EVENT_OBSERVER_H_ |
| OLD | NEW |