OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ |
7 | 7 |
8 #include "ash/wm/user_activity_observer.h" | |
9 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
13 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
14 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
15 #include "base/time/time.h" | 14 #include "base/time/time.h" |
16 #include "base/timer/timer.h" | 15 #include "base/timer/timer.h" |
17 #include "chromeos/dbus/power_manager_client.h" | 16 #include "chromeos/dbus/power_manager_client.h" |
18 #include "chromeos/dbus/update_engine_client.h" | 17 #include "chromeos/dbus/update_engine_client.h" |
19 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
20 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
| 20 #include "ui/wm/core/user_activity_observer.h" |
21 | 21 |
22 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
23 | 23 |
24 namespace base { | 24 namespace base { |
25 class TickClock; | 25 class TickClock; |
26 } | 26 } |
27 | 27 |
28 namespace chromeos { | 28 namespace chromeos { |
29 namespace system { | 29 namespace system { |
30 | 30 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // which a reboot should be requested and the grace period that follows it to | 65 // which a reboot should be requested and the grace period that follows it to |
66 // be recalculated. | 66 // be recalculated. |
67 // | 67 // |
68 // Reboots are scheduled in terms of device uptime. The current uptime is read | 68 // Reboots are scheduled in terms of device uptime. The current uptime is read |
69 // from /proc/uptime. The time at which a reboot became necessary to finish | 69 // from /proc/uptime. The time at which a reboot became necessary to finish |
70 // applying an update is stored in /var/run/chrome/update_reboot_needed_uptime, | 70 // applying an update is stored in /var/run/chrome/update_reboot_needed_uptime, |
71 // making it persist across browser restarts and crashes. Placing the file under | 71 // making it persist across browser restarts and crashes. Placing the file under |
72 // /var/run ensures that it gets cleared automatically on every boot. | 72 // /var/run ensures that it gets cleared automatically on every boot. |
73 class AutomaticRebootManager : public PowerManagerClient::Observer, | 73 class AutomaticRebootManager : public PowerManagerClient::Observer, |
74 public UpdateEngineClient::Observer, | 74 public UpdateEngineClient::Observer, |
75 public ash::UserActivityObserver, | 75 public wm::UserActivityObserver, |
76 public content::NotificationObserver { | 76 public content::NotificationObserver { |
77 public: | 77 public: |
78 // The current uptime and the uptime at which an update was applied and a | 78 // The current uptime and the uptime at which an update was applied and a |
79 // reboot became necessary (if any). Used to pass this information from the | 79 // reboot became necessary (if any). Used to pass this information from the |
80 // blocking thread pool to the UI thread. | 80 // blocking thread pool to the UI thread. |
81 struct SystemEventTimes { | 81 struct SystemEventTimes { |
82 SystemEventTimes(); | 82 SystemEventTimes(); |
83 SystemEventTimes(const base::TimeDelta& uptime, | 83 SystemEventTimes(const base::TimeDelta& uptime, |
84 const base::TimeDelta& update_reboot_needed_uptime); | 84 const base::TimeDelta& update_reboot_needed_uptime); |
85 | 85 |
(...skipping 10 matching lines...) Expand all Loading... |
96 void AddObserver(AutomaticRebootManagerObserver* observer); | 96 void AddObserver(AutomaticRebootManagerObserver* observer); |
97 void RemoveObserver(AutomaticRebootManagerObserver* observer); | 97 void RemoveObserver(AutomaticRebootManagerObserver* observer); |
98 | 98 |
99 // PowerManagerClient::Observer: | 99 // PowerManagerClient::Observer: |
100 virtual void SystemResumed(const base::TimeDelta& sleep_duration) OVERRIDE; | 100 virtual void SystemResumed(const base::TimeDelta& sleep_duration) OVERRIDE; |
101 | 101 |
102 // UpdateEngineClient::Observer: | 102 // UpdateEngineClient::Observer: |
103 virtual void UpdateStatusChanged( | 103 virtual void UpdateStatusChanged( |
104 const UpdateEngineClient::Status& status) OVERRIDE; | 104 const UpdateEngineClient::Status& status) OVERRIDE; |
105 | 105 |
106 // ash::UserActivityObserver: | 106 // wm::UserActivityObserver: |
107 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; | 107 virtual void OnUserActivity(const ui::Event* event) OVERRIDE; |
108 | 108 |
109 // content::NotificationObserver: | 109 // content::NotificationObserver: |
110 virtual void Observe(int type, | 110 virtual void Observe(int type, |
111 const content::NotificationSource& source, | 111 const content::NotificationSource& source, |
112 const content::NotificationDetails& details) OVERRIDE; | 112 const content::NotificationDetails& details) OVERRIDE; |
113 | 113 |
114 static void RegisterPrefs(PrefRegistrySimple* registry); | 114 static void RegisterPrefs(PrefRegistrySimple* registry); |
115 | 115 |
116 private: | 116 private: |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 ObserverList<AutomaticRebootManagerObserver, true> observers_; | 169 ObserverList<AutomaticRebootManagerObserver, true> observers_; |
170 | 170 |
171 DISALLOW_COPY_AND_ASSIGN(AutomaticRebootManager); | 171 DISALLOW_COPY_AND_ASSIGN(AutomaticRebootManager); |
172 }; | 172 }; |
173 | 173 |
174 } // namespace system | 174 } // namespace system |
175 } // namespace chromeos | 175 } // namespace chromeos |
176 | 176 |
177 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ | 177 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ |
OLD | NEW |