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