OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
| 6 #define CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
| 7 |
| 8 #include "base/singleton.h" |
| 9 #include "base/timer.h" |
| 10 |
| 11 /////////////////////////////////////////////////////////////////////////////// |
| 12 // UpgradeDetector |
| 13 // |
| 14 // This class is a singleton class that monitors when an upgrade happens in the |
| 15 // background. We basically ask Omaha what it thinks the latest version is and |
| 16 // if our version is lower we send out a notification upon: |
| 17 // a) Detecting an upgrade and... |
| 18 // b) When we think the user should be notified about the upgrade. |
| 19 // The latter happens much later, since we don't want to be too annoying. |
| 20 // |
| 21 class UpgradeDetector { |
| 22 public: |
| 23 ~UpgradeDetector(); |
| 24 |
| 25 bool notify_upgrade() { return notify_upgrade_; } |
| 26 |
| 27 private: |
| 28 UpgradeDetector(); |
| 29 friend struct DefaultSingletonTraits<UpgradeDetector>; |
| 30 |
| 31 // Checks with Omaha if we have the latest version. If not, sends out a |
| 32 // notification and starts a one shot timer to wait until notifying the |
| 33 // user. |
| 34 void CheckForUpgrade(); |
| 35 |
| 36 // The function that sends out a notification (after a certain time has |
| 37 // elapsed) that lets the rest of the UI know we should start notifying the |
| 38 // user that a new version is available. |
| 39 void NotifyOnUpgrade(); |
| 40 |
| 41 // We periodically check to see if Chrome has been upgraded. |
| 42 base::RepeatingTimer<UpgradeDetector> detect_upgrade_timer_; |
| 43 |
| 44 // After we detect an upgrade we wait a set time before notifying the user. |
| 45 base::OneShotTimer<UpgradeDetector> upgrade_notification_timer_; |
| 46 |
| 47 // Whether we have detected an upgrade happening while we were running. |
| 48 bool upgrade_detected_; |
| 49 |
| 50 // Whether we have waited long enough after detecting an upgrade (to see |
| 51 // is we should start nagging about upgrading). |
| 52 bool notify_upgrade_; |
| 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(UpgradeDetector); |
| 55 }; |
| 56 |
| 57 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_H_ |
OLD | NEW |