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

Side by Side Diff: chrome/browser/upgrade_detector_impl.h

Issue 421643002: Make UpgradeDetector listen to VariationsService changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/upgrade_detector.h" 12 #include "chrome/browser/upgrade_detector.h"
12 13
13 template <typename T> struct DefaultSingletonTraits; 14 template <typename T> struct DefaultSingletonTraits;
14 15
15 class UpgradeDetectorImpl : public UpgradeDetector { 16 class UpgradeDetectorImpl :
17 public UpgradeDetector,
18 public chrome_variations::VariationsService::Observer {
16 public: 19 public:
17 virtual ~UpgradeDetectorImpl(); 20 virtual ~UpgradeDetectorImpl();
18 21
19 // Returns the currently installed Chrome version, which may be newer than the 22 // Returns the currently installed Chrome version, which may be newer than the
20 // one currently running. Not supported on Android, iOS or ChromeOS. Must be 23 // one currently running. Not supported on Android, iOS or ChromeOS. Must be
21 // run on a thread where I/O operations are allowed (e.g. FILE thread). 24 // run on a thread where I/O operations are allowed (e.g. FILE thread).
22 static base::Version GetCurrentlyInstalledVersion(); 25 static base::Version GetCurrentlyInstalledVersion();
23 26
24 // Returns the singleton instance. 27 // Returns the singleton instance.
25 static UpgradeDetectorImpl* GetInstance(); 28 static UpgradeDetectorImpl* GetInstance();
26 29
30 protected:
31 UpgradeDetectorImpl();
32
33 // chrome_variations::VariationsService::Observer:
34 virtual void OnExperimentChangesDetected(Severity severity) OVERRIDE;
35
36 // Trigger an "on upgrade" notification based on the specified |time_passed|
37 // interval. Exposed as protected for testing.
38 void NotifyOnUpgradeWithTimePassed(base::TimeDelta time_passed);
39
27 private: 40 private:
28 friend struct DefaultSingletonTraits<UpgradeDetectorImpl>; 41 friend struct DefaultSingletonTraits<UpgradeDetectorImpl>;
29 42
30 UpgradeDetectorImpl();
31
32 // Start the timer that will call |CheckForUpgrade()|. 43 // Start the timer that will call |CheckForUpgrade()|.
33 void StartTimerForUpgradeCheck(); 44 void StartTimerForUpgradeCheck();
34 45
35 // Launches a task on the file thread to check if we have the latest version. 46 // Launches a task on the file thread to check if we have the latest version.
36 void CheckForUpgrade(); 47 void CheckForUpgrade();
37 48
49 // Starts the upgrade notification timer that will check periodically whether
50 // enough time has elapsed to update the severity (which maps to visual
51 // badging) of the notification.
52 void StartUpgradeNotificationTimer();
53
38 // Sends out a notification and starts a one shot timer to wait until 54 // Sends out a notification and starts a one shot timer to wait until
39 // notifying the user. 55 // notifying the user.
40 void UpgradeDetected(UpgradeAvailable upgrade_available); 56 void UpgradeDetected(UpgradeAvailable upgrade_available);
41 57
42 // Returns true after calling UpgradeDetected if current install is outdated. 58 // Returns true after calling UpgradeDetected if current install is outdated.
43 bool DetectOutdatedInstall(); 59 bool DetectOutdatedInstall();
44 60
45 // The function that sends out a notification (after a certain time has 61 // The function that sends out a notification (after a certain time has
46 // elapsed) that lets the rest of the UI know we should start notifying the 62 // elapsed) that lets the rest of the UI know we should start notifying the
47 // user that a new version is available. 63 // user that a new version is available.
(...skipping 19 matching lines...) Expand all
67 // the task to the actual upgrade detection code, which is in 83 // the task to the actual upgrade detection code, which is in
68 // DetectUpgradeTask. 84 // DetectUpgradeTask.
69 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_; 85 base::WeakPtrFactory<UpgradeDetectorImpl> weak_factory_;
70 86
71 // True if this build is a dev or canary channel build. 87 // True if this build is a dev or canary channel build.
72 bool is_unstable_channel_; 88 bool is_unstable_channel_;
73 89
74 // True if auto update is turned on. 90 // True if auto update is turned on.
75 bool is_auto_update_enabled_; 91 bool is_auto_update_enabled_;
76 92
93 // When the upgrade was detected - either a software update or a variations
94 // update, whichever happened first.
95 base::Time upgrade_detected_time_;
96
77 // The date the binaries were built. 97 // The date the binaries were built.
78 base::Time build_date_; 98 base::Time build_date_;
79 99
80 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl); 100 DISALLOW_COPY_AND_ASSIGN(UpgradeDetectorImpl);
81 }; 101 };
82 102
83 103
84 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_ 104 #endif // CHROME_BROWSER_UPGRADE_DETECTOR_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698