diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-12 23:27:12 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-12 23:27:12 +0000 |
commit | ceff840da7632736581f06bcd3f1495ef55fe42f (patch) | |
tree | df7716a71e1066cbd8613e47aa9edeea66d20348 /chrome/browser/upgrade_detector.h | |
parent | a2d4b9cfbcbed0bf23d9fe69e690bcc31fc0b780 (diff) | |
download | chromium_src-ceff840da7632736581f06bcd3f1495ef55fe42f.zip chromium_src-ceff840da7632736581f06bcd3f1495ef55fe42f.tar.gz chromium_src-ceff840da7632736581f06bcd3f1495ef55fe42f.tar.bz2 |
Refactor UpgradeDetector.
- Move peroidically timer based detection code into UpgradeDetectorImpl
for use on non-ChromeOS platform;
- Implement ChromeOS upgrade detection via UpdateLibrary observer and
apply a slightly different advisory timing for showing the badges
(show green arrow immediately on upgrade detected, then 2, 4, 7 days
for yellow, red and orange color);
BUG=chromium-os:16146
TEST=Verify fix for chromium-os:16146.
Review URL: http://codereview.chromium.org/7046096
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88800 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/upgrade_detector.h')
-rw-r--r-- | chrome/browser/upgrade_detector.h | 44 |
1 files changed, 15 insertions, 29 deletions
diff --git a/chrome/browser/upgrade_detector.h b/chrome/browser/upgrade_detector.h index 00227d5..31ac709 100644 --- a/chrome/browser/upgrade_detector.h +++ b/chrome/browser/upgrade_detector.h @@ -9,7 +9,6 @@ #include "base/timer.h" #include "ui/gfx/image.h" -template <typename T> struct DefaultSingletonTraits; class PrefService; /////////////////////////////////////////////////////////////////////////////// @@ -39,10 +38,10 @@ class UpgradeDetector { UPGRADE_ICON_TYPE_MENU_ICON, // For showing in the wrench menu. }; - // Returns the singleton instance. + // Returns the singleton implementation instance. static UpgradeDetector* GetInstance(); - ~UpgradeDetector(); + virtual ~UpgradeDetector(); static void RegisterPrefs(PrefService* prefs); @@ -55,41 +54,28 @@ class UpgradeDetector { // within the wrench menu. int GetIconResourceID(UpgradeNotificationIconType type); - private: - friend struct DefaultSingletonTraits<UpgradeDetector>; - + protected: UpgradeDetector(); - // Launches a task on the file thread to check if we have the latest version. - void CheckForUpgrade(); - - // Sends out a notification and starts a one shot timer to wait until - // notifying the user. - void UpgradeDetected(); + // Sends out UPGRADE_DETECTED notification and record upgrade_detected_time_. + void NotifyUpgradeDetected(); - // The function that sends out a notification (after a certain time has - // elapsed) that lets the rest of the UI know we should start notifying the - // user that a new version is available. - void NotifyOnUpgrade(); + // Sends out UPGRADE_RECOMMENDED notification and set notify_upgrade_. + void NotifyUpgradeRecommended(); - // We periodically check to see if Chrome has been upgraded. - base::RepeatingTimer<UpgradeDetector> detect_upgrade_timer_; + // Accessors. + const base::Time& upgrade_detected_time() const { + return upgrade_detected_time_; + } - // After we detect an upgrade we start a recurring timer to see if enough time - // has passed and we should start notifying the user. - base::RepeatingTimer<UpgradeDetector> upgrade_notification_timer_; - - // We use this factory to create callback tasks for UpgradeDetected. We pass - // the task to the actual upgrade detection code, which is in - // DetectUpgradeTask. - ScopedRunnableMethodFactory<UpgradeDetector> method_factory_; + void set_upgrade_notification_stage(UpgradeNotificationAnnoyanceLevel stage) { + upgrade_notification_stage_ = stage; + } + private: // When the upgrade was detected. base::Time upgrade_detected_time_; - // True if this build is a dev or canary channel build. - bool is_unstable_channel_; - // The stage at which the annoyance level for upgrade notifications is at. UpgradeNotificationAnnoyanceLevel upgrade_notification_stage_; |