Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ | 5 #ifndef CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ |
| 6 #define CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ | 6 #define CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 9 #include "base/timer.h" | 9 #include "base/timer.h" |
| 10 #include "chrome/browser/upgrade_detector.h" | 10 #include "chrome/browser/upgrade_detector.h" |
| 11 | 11 |
| 12 template <typename T> struct DefaultSingletonTraits; | 12 template <typename T> struct DefaultSingletonTraits; |
| 13 | 13 |
| 14 class UpgradeDetectorImpl : public UpgradeDetector { | 14 class UpgradeDetectorImpl : public UpgradeDetector { |
| 15 public: | 15 public: |
| 16 virtual ~UpgradeDetectorImpl(); | 16 virtual ~UpgradeDetectorImpl(); |
| 17 | 17 |
| 18 // Returns the singleton instance. | 18 // Returns the singleton instance. |
| 19 static UpgradeDetectorImpl* GetInstance(); | 19 static UpgradeDetectorImpl* GetInstance(); |
| 20 | 20 |
| 21 private: | 21 private: |
| 22 friend struct DefaultSingletonTraits<UpgradeDetectorImpl>; | 22 friend struct DefaultSingletonTraits<UpgradeDetectorImpl>; |
| 23 | 23 |
| 24 UpgradeDetectorImpl(); | 24 UpgradeDetectorImpl(); |
| 25 | 25 |
| 26 // Start the timer that will call |CheckForUpgrade()|. | |
| 27 void StartCheckForUpgradeTimer(); | |
| 28 | |
| 26 // Launches a task on the file thread to check if we have the latest version. | 29 // Launches a task on the file thread to check if we have the latest version. |
| 27 void CheckForUpgrade(); | 30 void CheckForUpgrade(); |
| 28 | 31 |
| 29 // Sends out a notification and starts a one shot timer to wait until | 32 // Sends out a notification and starts a one shot timer to wait until |
| 30 // notifying the user. | 33 // notifying the user. |
| 31 void UpgradeDetected(); | 34 void UpgradeDetected(UpgradeAvailable upgrade_available, |
| 35 bool unstable_channel); | |
| 36 | |
| 37 // Returns true after calling UpgradeDetected if current install is outdated. | |
|
Finnur
2013/02/04 11:12:04
If you change what I suggested, then you can remov
MAD
2013/02/04 17:17:02
I didn't... I hope it's OK... :-)
| |
| 38 bool CheckForOutdatedInstall(); | |
| 32 | 39 |
| 33 // The function that sends out a notification (after a certain time has | 40 // The function that sends out a notification (after a certain time has |
| 34 // elapsed) that lets the rest of the UI know we should start notifying the | 41 // elapsed) that lets the rest of the UI know we should start notifying the |
| 35 // user that a new version is available. | 42 // user that a new version is available. |
| 36 void NotifyOnUpgrade(); | 43 void NotifyOnUpgrade(); |
| 37 | 44 |
| 45 // Called on the FILE thread to detect an upgrade. Calls back UpgradeDetected | |
| 46 // on the UI thread if so. | |
| 47 static void DetectUpgradeTask( | |
|
Finnur
2013/02/04 11:12:04
Does this still need to be static. If so, I'd like
MAD
2013/02/04 17:17:02
For the same reason that we call InvalidateWeakPtr
Finnur
2013/02/04 21:30:17
I need a fresh mind to think about this. I'll try
Finnur
2013/02/05 10:52:19
So, to answer your question: No, I don't prefer th
MAD
2013/02/05 16:49:16
Ha! Now I see where the confusion is... It used to
Finnur
2013/02/05 22:14:50
Member function would be my preference.
MAD
2013/02/06 03:14:28
You mean not static?
(cause... you know... technic
Finnur
2013/02/06 10:26:49
I see.
| |
| 48 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector); | |
| 49 | |
| 38 // We periodically check to see if Chrome has been upgraded. | 50 // We periodically check to see if Chrome has been upgraded. |
| 39 base::RepeatingTimer<UpgradeDetectorImpl> detect_upgrade_timer_; | 51 base::RepeatingTimer<UpgradeDetectorImpl> detect_upgrade_timer_; |
| 40 | 52 |
| 41 // After we detect an upgrade we start a recurring timer to see if enough time | 53 // After we detect an upgrade we start a recurring timer to see if enough time |
| 42 // has passed and we should start notifying the user. | 54 // has passed and we should start notifying the user. |
| 43 base::RepeatingTimer<UpgradeDetectorImpl> upgrade_notification_timer_; | 55 base::RepeatingTimer<UpgradeDetectorImpl> upgrade_notification_timer_; |
| 44 | 56 |
| 45 // We use this factory to create callback tasks for UpgradeDetected. We pass | 57 // We use this factory to create callback tasks for UpgradeDetected. We pass |
| 46 // the task to the actual upgrade detection code, which is in | 58 // the task to the actual upgrade detection code, which is in |
| 47 // DetectUpgradeTask. | 59 // DetectUpgradeTask. |
| 48 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_; | 60 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_; |
| 49 | 61 |
| 50 // True if this build is a dev or canary channel build. | 62 // True if this build is a dev or canary channel build. |
| 51 bool is_unstable_channel_; | 63 bool is_unstable_channel_; |
| 52 | 64 |
| 65 // The date the binaries were built. | |
| 66 base::Time build_date_; | |
| 67 | |
| 53 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl); | 68 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl); |
| 54 }; | 69 }; |
| 55 | 70 |
| 56 | 71 |
| 57 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ | 72 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ |
| OLD | NEW |