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

Unified Diff: chrome/browser/chromeos/system/automatic_reboot_manager.cc

Issue 16844020: app_mode: Add runtime.onRestartRequired event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/system/automatic_reboot_manager.cc
diff --git a/chrome/browser/chromeos/system/automatic_reboot_manager.cc b/chrome/browser/chromeos/system/automatic_reboot_manager.cc
index b13db1ca7ea3a36e8640e387b6dc0d9b887a6cff..c77d06ee1bf935112de276c0f11900a9ab05a2df 100644
--- a/chrome/browser/chromeos/system/automatic_reboot_manager.cc
+++ b/chrome/browser/chromeos/system/automatic_reboot_manager.cc
@@ -33,6 +33,7 @@
#include "base/time/tick_clock.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/chromeos/system/automatic_reboot_manager_observer.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "chromeos/chromeos_paths.h"
@@ -194,6 +195,10 @@ AutomaticRebootManager::AutomaticRebootManager(
}
AutomaticRebootManager::~AutomaticRebootManager() {
+ FOR_EACH_OBSERVER(AutomaticRebootManagerObserver,
+ observers_,
+ WillDestroyAutomaticRebootManager());
+
DBusThreadManager* dbus_thread_manager = DBusThreadManager::Get();
dbus_thread_manager->GetPowerManagerClient()->RemoveObserver(this);
dbus_thread_manager->GetUpdateEngineClient()->RemoveObserver(this);
@@ -201,6 +206,16 @@ AutomaticRebootManager::~AutomaticRebootManager() {
ash::Shell::GetInstance()->user_activity_detector()->RemoveObserver(this);
}
+void AutomaticRebootManager::AddObserver(
+ AutomaticRebootManagerObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void AutomaticRebootManager::RemoveObserver(
+ AutomaticRebootManagerObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
void AutomaticRebootManager::SystemResumed(
const base::TimeDelta& sleep_duration) {
MaybeReboot(true);
@@ -303,6 +318,8 @@ void AutomaticRebootManager::Reschedule() {
reboot_requested_ = false;
const base::TimeDelta kZeroTimeDelta;
+ AutomaticRebootManagerObserver::Reason reboot_reason =
+ AutomaticRebootManagerObserver::REBOOT_REASON_UNKNOWN;
// If an uptime limit is set, calculate the time at which it should cause a
// reboot to be requested.
@@ -310,6 +327,8 @@ void AutomaticRebootManager::Reschedule() {
local_state_registrar_.prefs()->GetInteger(prefs::kUptimeLimit));
base::TimeTicks reboot_request_time = boot_time_ + uptime_limit;
bool have_reboot_request_time = uptime_limit != kZeroTimeDelta;
+ if (have_reboot_request_time)
+ reboot_reason = AutomaticRebootManagerObserver::REBOOT_REASON_PERIODIC;
// If the policy to automatically reboot after an update is enabled and an
// update has been applied, set the time at which a reboot should be
@@ -321,6 +340,7 @@ void AutomaticRebootManager::Reschedule() {
update_reboot_needed_time_ < reboot_request_time)) {
reboot_request_time = update_reboot_needed_time_;
have_reboot_request_time = true;
+ reboot_reason = AutomaticRebootManagerObserver::REBOOT_REASON_OS_UPDATE;
}
// If no reboot should be requested, remove any grace period.
@@ -355,6 +375,12 @@ void AutomaticRebootManager::Reschedule() {
std::max(grace_end_time - now, kZeroTimeDelta),
base::Bind(&AutomaticRebootManager::Reboot,
base::Unretained(this)));
+
+ DCHECK_NE(AutomaticRebootManagerObserver::REBOOT_REASON_UNKNOWN,
+ reboot_reason);
+ FOR_EACH_OBSERVER(AutomaticRebootManagerObserver,
+ observers_,
+ OnRebootScheduled(reboot_reason));
}
void AutomaticRebootManager::RequestReboot() {

Powered by Google App Engine
This is Rietveld 408576698