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

Unified Diff: chrome/browser/upgrade_detector_impl.cc

Issue 421643002: Make UpgradeDetector listen to VariationsService changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix gpu bot failures Created 6 years, 4 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
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/browser/upgrade_detector_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/upgrade_detector_impl.cc
===================================================================
--- chrome/browser/upgrade_detector_impl.cc (revision 287812)
+++ chrome/browser/upgrade_detector_impl.cc (working copy)
@@ -244,6 +244,14 @@
return;
}
+ // Register for experiment notifications. Note that since this class is a
+ // singleton, it does not need to unregister for notifications when destroyed,
+ // since it outlives the VariationsService.
+ chrome_variations::VariationsService* variations_service =
+ g_browser_process->variations_service();
+ if (variations_service)
+ variations_service->AddObserver(this);
+
base::Closure start_upgrade_check_timer_task =
base::Bind(&UpgradeDetectorImpl::StartTimerForUpgradeCheck,
weak_factory_.GetWeakPtr());
@@ -346,6 +354,24 @@
this, &UpgradeDetectorImpl::CheckForUpgrade);
}
+void UpgradeDetectorImpl::StartUpgradeNotificationTimer() {
+ // The timer may already be running (e.g. due to both a software upgrade and
+ // experiment updates being available).
+ if (upgrade_notification_timer_.IsRunning())
+ return;
+
+ upgrade_detected_time_ = base::Time::Now();
+
+ // Start the repeating timer for notifying the user after a certain period.
+ // The called function will eventually figure out that enough time has passed
+ // and stop the timer.
+ const int cycle_time_ms = IsTesting() ?
+ kNotifyCycleTimeForTestingMs : kNotifyCycleTimeMs;
+ upgrade_notification_timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(cycle_time_ms),
+ this, &UpgradeDetectorImpl::NotifyOnUpgrade);
+}
+
void UpgradeDetectorImpl::CheckForUpgrade() {
// Interrupt any (unlikely) unfinished execution of DetectUpgradeTask, or at
// least prevent the callback from being executed, because we will potentially
@@ -414,30 +440,28 @@
return simulate_outdated;
}
+void UpgradeDetectorImpl::OnExperimentChangesDetected(Severity severity) {
+ set_best_effort_experiment_updates_available(severity == BEST_EFFORT);
+ set_critical_experiment_updates_available(severity == CRITICAL);
+ StartUpgradeNotificationTimer();
+}
+
void UpgradeDetectorImpl::UpgradeDetected(UpgradeAvailable upgrade_available) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- upgrade_available_ = upgrade_available;
+ set_upgrade_available(upgrade_available);
// Stop the recurring timer (that is checking for changes).
detect_upgrade_timer_.Stop();
+ set_critical_update_acknowledged(false);
- NotifyUpgradeDetected();
-
- // Start the repeating timer for notifying the user after a certain period.
- // The called function will eventually figure out that enough time has passed
- // and stop the timer.
- int cycle_time = IsTesting() ?
- kNotifyCycleTimeForTestingMs : kNotifyCycleTimeMs;
- upgrade_notification_timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(cycle_time),
- this, &UpgradeDetectorImpl::NotifyOnUpgrade);
+ StartUpgradeNotificationTimer();
}
-void UpgradeDetectorImpl::NotifyOnUpgrade() {
- const base::TimeDelta time_passed =
- base::Time::Now() - upgrade_detected_time();
-
- bool is_critical_or_outdated = upgrade_available_ > UPGRADE_AVAILABLE_REGULAR;
+void UpgradeDetectorImpl::NotifyOnUpgradeWithTimePassed(
+ base::TimeDelta time_passed) {
+ const bool is_critical_or_outdated =
+ upgrade_available() > UPGRADE_AVAILABLE_REGULAR ||
+ critical_experiment_updates_available();
if (is_unstable_channel_) {
// There's only one threat level for unstable channels like dev and
// canary, and it hits after one hour. During testing, it hits after one
@@ -487,6 +511,12 @@
NotifyUpgradeRecommended();
}
+void UpgradeDetectorImpl::NotifyOnUpgrade() {
+ const base::TimeDelta time_passed =
+ base::Time::Now() - upgrade_detected_time_;
+ NotifyOnUpgradeWithTimePassed(time_passed);
+}
+
// static
UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() {
return Singleton<UpgradeDetectorImpl>::get();
« no previous file with comments | « chrome/browser/upgrade_detector_impl.h ('k') | chrome/browser/upgrade_detector_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698