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

Unified Diff: chrome/browser/upgrade_detector.cc

Issue 421643002: Make UpgradeDetector listen to VariationsService changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 5 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/upgrade_detector.cc
===================================================================
--- chrome/browser/upgrade_detector.cc (revision 286992)
+++ chrome/browser/upgrade_detector.cc (working copy)
@@ -59,6 +59,8 @@
UpgradeDetector::UpgradeDetector()
: upgrade_available_(UPGRADE_AVAILABLE_NONE),
+ best_effort_experiment_updates_available_(false),
+ critical_experiment_updates_available_(false),
critical_update_acknowledged_(false),
upgrade_notification_stage_(UPGRADE_ANNOYANCE_NONE),
notify_upgrade_(false) {
@@ -67,48 +69,28 @@
UpgradeDetector::~UpgradeDetector() {
}
-void UpgradeDetector::NotifyUpgradeDetected() {
- upgrade_detected_time_ = base::Time::Now();
- critical_update_acknowledged_ = false;
-}
-
void UpgradeDetector::NotifyUpgradeRecommended() {
notify_upgrade_ = true;
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
- content::Source<UpgradeDetector>(this),
- content::NotificationService::NoDetails());
-
- switch (upgrade_available_) {
- case UPGRADE_NEEDED_OUTDATED_INSTALL: {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_OUTDATED_INSTALL,
- content::Source<UpgradeDetector>(this),
- content::NotificationService::NoDetails());
- break;
- }
- case UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU: {
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU,
- content::Source<UpgradeDetector>(this),
- content::NotificationService::NoDetails());
- break;
- }
- case UPGRADE_AVAILABLE_CRITICAL: {
- int idle_timer = UseTestingIntervals() ?
- kIdleRepeatingTimerWait :
- kIdleRepeatingTimerWait * 60; // To minutes.
- idle_check_timer_.Start(FROM_HERE,
- base::TimeDelta::FromSeconds(idle_timer),
- this, &UpgradeDetector::CheckIdle);
- break;
- }
- default:
- break;
+ TriggerNotification(chrome::NOTIFICATION_UPGRADE_RECOMMENDED);
+ if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL) {
+ TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL);
+ } else if (upgrade_available_ == UPGRADE_NEEDED_OUTDATED_INSTALL_NO_AU) {
+ TriggerNotification(chrome::NOTIFICATION_OUTDATED_INSTALL_NO_AU);
+ } else if (upgrade_available_ == UPGRADE_AVAILABLE_CRITICAL ||
+ critical_experiment_updates_available_) {
sky 2014/08/04 18:24:07 nit: align with ( on previous line.
Alexei Svitkine (slow) 2014/08/04 19:43:10 Done.
+ TriggerCriticalUpdate();
}
}
+void UpgradeDetector::TriggerCriticalUpdate() {
+ const base::TimeDelta idle_timer = UseTestingIntervals() ?
+ base::TimeDelta::FromSeconds(kIdleRepeatingTimerWait) :
+ base::TimeDelta::FromMinutes(kIdleRepeatingTimerWait);
+ idle_check_timer_.Start(FROM_HERE, idle_timer, this,
+ &UpgradeDetector::CheckIdle);
+}
+
void UpgradeDetector::CheckIdle() {
// CalculateIdleState expects an interval in seconds.
int idle_time_allowed = UseTestingIntervals() ? kIdleAmount :
@@ -119,6 +101,13 @@
base::Unretained(this)));
}
+void UpgradeDetector::TriggerNotification(chrome::NotificationType type) {
+ content::NotificationService::current()->Notify(
+ type,
+ content::Source<UpgradeDetector>(this),
+ content::NotificationService::NoDetails());
+}
+
void UpgradeDetector::IdleCallback(IdleState state) {
// Don't proceed while an incognito window is open. The timer will still
// keep firing, so this function will get a chance to re-evaluate this.
@@ -134,10 +123,7 @@
case IDLE_STATE_IDLE:
// Computer has been idle for long enough, show warning.
idle_check_timer_.Stop();
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED,
- content::Source<UpgradeDetector>(this),
- content::NotificationService::NoDetails());
+ TriggerNotification(chrome::NOTIFICATION_CRITICAL_UPGRADE_INSTALLED);
break;
case IDLE_STATE_ACTIVE:
case IDLE_STATE_UNKNOWN:

Powered by Google App Engine
This is Rietveld 408576698