| 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 "chromeos/dbus/power_manager_client.h" | 17 #include "chromeos/dbus/power_manager_client.h" |
| 17 #include "chromeos/dbus/update_engine_client.h" | 18 #include "chromeos/dbus/update_engine_client.h" |
| 18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
| 19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
| 20 #include "ui/wm/core/user_activity_observer.h" | 21 #include "ui/wm/core/user_activity_observer.h" |
| 21 | 22 |
| 22 class PrefRegistrySimple; | 23 class PrefRegistrySimple; |
| 23 | 24 |
| 24 namespace base { | 25 namespace base { |
| 25 class TickClock; | 26 class TickClock; |
| 26 } | 27 } |
| 27 | 28 |
| 28 namespace chromeos { | 29 namespace chromeos { |
| 29 namespace system { | 30 namespace system { |
| 30 | 31 |
| 31 class AutomaticRebootManagerObserver; | |
| 32 | |
| 33 // Schedules and executes automatic reboots. | 32 // Schedules and executes automatic reboots. |
| 34 // | 33 // |
| 35 // Automatic reboots may be scheduled for any number of reasons. Currently, the | 34 // Automatic reboots may be scheduled for any number of reasons. Currently, the |
| 36 // following are implemented: | 35 // following are implemented: |
| 37 // * When Chrome OS has applied a system update, a reboot may become necessary | 36 // * When Chrome OS has applied a system update, a reboot may become necessary |
| 38 // to complete the update process. If the policy to automatically reboot after | 37 // to complete the update process. If the policy to automatically reboot after |
| 39 // an update is enabled, a reboot is scheduled at that point. | 38 // an update is enabled, a reboot is scheduled at that point. |
| 40 // * If an uptime limit is set through policy, a reboot is scheduled when the | 39 // * If an uptime limit is set through policy, a reboot is scheduled when the |
| 41 // device's uptime reaches the limit. Time spent sleeping counts as uptime as | 40 // device's uptime reaches the limit. Time spent sleeping counts as uptime as |
| 42 // well. | 41 // well. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 bool has_boot_time; | 85 bool has_boot_time; |
| 87 base::TimeTicks boot_time; | 86 base::TimeTicks boot_time; |
| 88 | 87 |
| 89 bool has_update_reboot_needed_time; | 88 bool has_update_reboot_needed_time; |
| 90 base::TimeTicks update_reboot_needed_time; | 89 base::TimeTicks update_reboot_needed_time; |
| 91 }; | 90 }; |
| 92 | 91 |
| 93 explicit AutomaticRebootManager(scoped_ptr<base::TickClock> clock); | 92 explicit AutomaticRebootManager(scoped_ptr<base::TickClock> clock); |
| 94 virtual ~AutomaticRebootManager(); | 93 virtual ~AutomaticRebootManager(); |
| 95 | 94 |
| 95 AutomaticRebootManagerObserver::Reason reboot_reason() const { |
| 96 return reboot_reason_; |
| 97 } |
| 98 bool reboot_requested() const { return reboot_requested_; } |
| 99 |
| 96 void AddObserver(AutomaticRebootManagerObserver* observer); | 100 void AddObserver(AutomaticRebootManagerObserver* observer); |
| 97 void RemoveObserver(AutomaticRebootManagerObserver* observer); | 101 void RemoveObserver(AutomaticRebootManagerObserver* observer); |
| 98 | 102 |
| 99 // PowerManagerClient::Observer: | 103 // PowerManagerClient::Observer: |
| 100 virtual void SuspendDone(const base::TimeDelta& sleep_duration) override; | 104 virtual void SuspendDone(const base::TimeDelta& sleep_duration) override; |
| 101 | 105 |
| 102 // UpdateEngineClient::Observer: | 106 // UpdateEngineClient::Observer: |
| 103 virtual void UpdateStatusChanged( | 107 virtual void UpdateStatusChanged( |
| 104 const UpdateEngineClient::Status& status) override; | 108 const UpdateEngineClient::Status& status) override; |
| 105 | 109 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 | 154 |
| 151 // The time at which the device was booted, in |clock_| ticks. | 155 // The time at which the device was booted, in |clock_| ticks. |
| 152 bool have_boot_time_; | 156 bool have_boot_time_; |
| 153 base::TimeTicks boot_time_; | 157 base::TimeTicks boot_time_; |
| 154 | 158 |
| 155 // The time at which an update was applied and a reboot became necessary to | 159 // The time at which an update was applied and a reboot became necessary to |
| 156 // complete the update process, in |clock_| ticks. | 160 // complete the update process, in |clock_| ticks. |
| 157 bool have_update_reboot_needed_time_; | 161 bool have_update_reboot_needed_time_; |
| 158 base::TimeTicks update_reboot_needed_time_; | 162 base::TimeTicks update_reboot_needed_time_; |
| 159 | 163 |
| 164 // The reason for the reboot request. Updated whenever a reboot is scheduled. |
| 165 AutomaticRebootManagerObserver::Reason reboot_reason_; |
| 166 |
| 160 // Whether a reboot has been requested. | 167 // Whether a reboot has been requested. |
| 161 bool reboot_requested_; | 168 bool reboot_requested_; |
| 162 | 169 |
| 163 // Timers that start and end the grace period. | 170 // Timers that start and end the grace period. |
| 164 scoped_ptr<base::OneShotTimer<AutomaticRebootManager> > grace_start_timer_; | 171 scoped_ptr<base::OneShotTimer<AutomaticRebootManager> > grace_start_timer_; |
| 165 scoped_ptr<base::OneShotTimer<AutomaticRebootManager> > grace_end_timer_; | 172 scoped_ptr<base::OneShotTimer<AutomaticRebootManager> > grace_end_timer_; |
| 166 | 173 |
| 167 ObserverList<AutomaticRebootManagerObserver, true> observers_; | 174 ObserverList<AutomaticRebootManagerObserver, true> observers_; |
| 168 | 175 |
| 169 base::WeakPtrFactory<AutomaticRebootManager> weak_ptr_factory_; | 176 base::WeakPtrFactory<AutomaticRebootManager> weak_ptr_factory_; |
| 170 | 177 |
| 171 DISALLOW_COPY_AND_ASSIGN(AutomaticRebootManager); | 178 DISALLOW_COPY_AND_ASSIGN(AutomaticRebootManager); |
| 172 }; | 179 }; |
| 173 | 180 |
| 174 } // namespace system | 181 } // namespace system |
| 175 } // namespace chromeos | 182 } // namespace chromeos |
| 176 | 183 |
| 177 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ | 184 #endif // CHROME_BROWSER_CHROMEOS_SYSTEM_AUTOMATIC_REBOOT_MANAGER_H_ |
| OLD | NEW |