Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1007)

Side by Side Diff: chrome/browser/chromeos/system/automatic_reboot_manager.h

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

Powered by Google App Engine
This is Rietveld 408576698