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/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
11 #include "chrome/browser/metrics/variations/variations_service.h" | 11 #include "chrome/browser/metrics/variations/variations_service.h" |
12 #include "chrome/browser/upgrade_detector.h" | 12 #include "chrome/browser/upgrade_detector.h" |
13 | 13 |
| 14 namespace base { |
14 template <typename T> struct DefaultSingletonTraits; | 15 template <typename T> struct DefaultSingletonTraits; |
| 16 } |
15 | 17 |
16 class UpgradeDetectorImpl : | 18 class UpgradeDetectorImpl : |
17 public UpgradeDetector, | 19 public UpgradeDetector, |
18 public chrome_variations::VariationsService::Observer { | 20 public chrome_variations::VariationsService::Observer { |
19 public: | 21 public: |
20 ~UpgradeDetectorImpl() override; | 22 ~UpgradeDetectorImpl() override; |
21 | 23 |
22 // Returns the currently installed Chrome version, which may be newer than the | 24 // Returns the currently installed Chrome version, which may be newer than the |
23 // one currently running. Not supported on Android, iOS or ChromeOS. Must be | 25 // one currently running. Not supported on Android, iOS or ChromeOS. Must be |
24 // run on a thread where I/O operations are allowed (e.g. FILE thread). | 26 // run on a thread where I/O operations are allowed (e.g. FILE thread). |
25 static base::Version GetCurrentlyInstalledVersion(); | 27 static base::Version GetCurrentlyInstalledVersion(); |
26 | 28 |
27 // Returns the singleton instance. | 29 // Returns the singleton instance. |
28 static UpgradeDetectorImpl* GetInstance(); | 30 static UpgradeDetectorImpl* GetInstance(); |
29 | 31 |
30 protected: | 32 protected: |
31 UpgradeDetectorImpl(); | 33 UpgradeDetectorImpl(); |
32 | 34 |
33 // chrome_variations::VariationsService::Observer: | 35 // chrome_variations::VariationsService::Observer: |
34 void OnExperimentChangesDetected(Severity severity) override; | 36 void OnExperimentChangesDetected(Severity severity) override; |
35 | 37 |
36 // Trigger an "on upgrade" notification based on the specified |time_passed| | 38 // Trigger an "on upgrade" notification based on the specified |time_passed| |
37 // interval. Exposed as protected for testing. | 39 // interval. Exposed as protected for testing. |
38 void NotifyOnUpgradeWithTimePassed(base::TimeDelta time_passed); | 40 void NotifyOnUpgradeWithTimePassed(base::TimeDelta time_passed); |
39 | 41 |
40 private: | 42 private: |
41 friend struct DefaultSingletonTraits<UpgradeDetectorImpl>; | 43 friend struct base::DefaultSingletonTraits<UpgradeDetectorImpl>; |
42 | 44 |
43 // Start the timer that will call |CheckForUpgrade()|. | 45 // Start the timer that will call |CheckForUpgrade()|. |
44 void StartTimerForUpgradeCheck(); | 46 void StartTimerForUpgradeCheck(); |
45 | 47 |
46 // Launches a task on the file thread to check if we have the latest version. | 48 // Launches a task on the file thread to check if we have the latest version. |
47 void CheckForUpgrade(); | 49 void CheckForUpgrade(); |
48 | 50 |
49 // Starts the upgrade notification timer that will check periodically whether | 51 // Starts the upgrade notification timer that will check periodically whether |
50 // enough time has elapsed to update the severity (which maps to visual | 52 // enough time has elapsed to update the severity (which maps to visual |
51 // badging) of the notification. | 53 // badging) of the notification. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // We use this factory to create callback tasks for UpgradeDetected. We pass | 97 // We use this factory to create callback tasks for UpgradeDetected. We pass |
96 // the task to the actual upgrade detection code, which is in | 98 // the task to the actual upgrade detection code, which is in |
97 // DetectUpgradeTask. | 99 // DetectUpgradeTask. |
98 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_; | 100 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_; |
99 | 101 |
100 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl); | 102 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl); |
101 }; | 103 }; |
102 | 104 |
103 | 105 |
104 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ | 106 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ |
OLD | NEW |