OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ |
7 | 7 |
| 8 #include "base/callback.h" |
8 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/memory/weak_ptr.h" |
9 #include "base/time/time.h" | 11 #include "base/time/time.h" |
10 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
11 #include "chromeos/dbus/power_manager_client.h" | 13 #include "chromeos/dbus/power_manager_client.h" |
12 | 14 |
13 namespace chromeos { | 15 namespace chromeos { |
14 | 16 |
15 // Freezes the chrome renderers when the system is about to suspend and thaws | 17 // Freezes the chrome renderers when the system is about to suspend and thaws |
16 // them after the system fully resumes. This class registers itself as a | 18 // them after the system fully resumes. This class registers itself as a |
17 // PowerManagerClient::Observer on creation and unregisters itself on | 19 // PowerManagerClient::Observer on creation and unregisters itself on |
18 // destruction. | 20 // destruction. |
19 class CHROMEOS_EXPORT RendererFreezer : public PowerManagerClient::Observer { | 21 class CHROMEOS_EXPORT RendererFreezer : public PowerManagerClient::Observer { |
20 public: | 22 public: |
21 RendererFreezer(); | 23 RendererFreezer(); |
22 virtual ~RendererFreezer(); | 24 virtual ~RendererFreezer(); |
23 | 25 |
24 // PowerManagerClient::Observer implementation | 26 // PowerManagerClient::Observer implementation |
25 virtual void SuspendImminent() OVERRIDE; | 27 virtual void SuspendImminent() OVERRIDE; |
26 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; | 28 virtual void SuspendDone(const base::TimeDelta& sleep_duration) OVERRIDE; |
27 | 29 |
28 private: | 30 private: |
| 31 void OnReadyToSuspend(); |
| 32 |
29 base::FilePath state_path_; | 33 base::FilePath state_path_; |
30 bool enabled_; | 34 bool enabled_; |
31 bool frozen_; | 35 bool frozen_; |
32 | 36 |
| 37 // Callback used to asynchronously report suspend readiness. |
| 38 base::Closure suspend_readiness_callback_; |
| 39 |
| 40 base::WeakPtrFactory<RendererFreezer> weak_factory_; |
| 41 |
33 DISALLOW_COPY_AND_ASSIGN(RendererFreezer); | 42 DISALLOW_COPY_AND_ASSIGN(RendererFreezer); |
34 }; | 43 }; |
35 | 44 |
36 } // namespace chromeos | 45 } // namespace chromeos |
37 | 46 |
38 #endif // CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ | 47 #endif // CHROME_BROWSER_CHROMEOS_POWER_RENDERER_FREEZER_H_ |
OLD | NEW |