OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/version.h" | 9 #include "base/version.h" |
10 #include "base/win/win_util.h" | 10 #include "base/win/win_util.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 const base::string16& error_message, | 50 const base::string16& error_message, |
51 const base::string16& version) OVERRIDE; | 51 const base::string16& version) OVERRIDE; |
52 | 52 |
53 // Update the UI to show the status of the upgrade. | 53 // Update the UI to show the status of the upgrade. |
54 void UpdateStatus(GoogleUpdateUpgradeResult result, | 54 void UpdateStatus(GoogleUpdateUpgradeResult result, |
55 GoogleUpdateErrorCode error_code, | 55 GoogleUpdateErrorCode error_code, |
56 const base::string16& error_message); | 56 const base::string16& error_message); |
57 | 57 |
58 // Got the intalled version so the handling of the UPGRADE_ALREADY_UP_TO_DATE | 58 // Got the intalled version so the handling of the UPGRADE_ALREADY_UP_TO_DATE |
59 // result case can now be completeb on the UI thread. | 59 // result case can now be completeb on the UI thread. |
60 void GotInstalledVersion(const Version& version); | 60 void GotInstalledVersion(const base::Version& version); |
61 | 61 |
62 // Little helper function to create google_updater_. | 62 // Little helper function to create google_updater_. |
63 void CreateGoogleUpdater(); | 63 void CreateGoogleUpdater(); |
64 | 64 |
65 // Helper function to clear google_updater_. | 65 // Helper function to clear google_updater_. |
66 void ClearGoogleUpdater(); | 66 void ClearGoogleUpdater(); |
67 | 67 |
68 // Returns a window that can be used for elevation. | 68 // Returns a window that can be used for elevation. |
69 HWND GetElevationParent(); | 69 HWND GetElevationParent(); |
70 | 70 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 private: | 113 private: |
114 friend class base::RefCountedThreadSafe<VersionReader>; | 114 friend class base::RefCountedThreadSafe<VersionReader>; |
115 | 115 |
116 // The version updater that must be called back when we are done. | 116 // The version updater that must be called back when we are done. |
117 // We use a weak pointer in case the updater gets destroyed while waiting. | 117 // We use a weak pointer in case the updater gets destroyed while waiting. |
118 base::WeakPtr<VersionUpdaterWin> version_updater_; | 118 base::WeakPtr<VersionUpdaterWin> version_updater_; |
119 | 119 |
120 // This is the version that gets read in the FILE thread and set on the | 120 // This is the version that gets read in the FILE thread and set on the |
121 // the updater in the UI thread. | 121 // the updater in the UI thread. |
122 Version installed_version_; | 122 base::Version installed_version_; |
123 }; | 123 }; |
124 | 124 |
125 VersionUpdaterWin::VersionUpdaterWin() | 125 VersionUpdaterWin::VersionUpdaterWin() |
126 : weak_factory_(this) { | 126 : weak_factory_(this) { |
127 CreateGoogleUpdater(); | 127 CreateGoogleUpdater(); |
128 } | 128 } |
129 | 129 |
130 VersionUpdaterWin::~VersionUpdaterWin() { | 130 VersionUpdaterWin::~VersionUpdaterWin() { |
131 // The Google Updater will hold a pointer to the listener until it reports | 131 // The Google Updater will hold a pointer to the listener until it reports |
132 // status, so that pointer must be cleared when the listener is destoyed. | 132 // status, so that pointer must be cleared when the listener is destoyed. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 break; | 234 break; |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 // TODO(mad): Get proper progress value instead of passing 0. | 238 // TODO(mad): Get proper progress value instead of passing 0. |
239 // http://crbug.com/136117 | 239 // http://crbug.com/136117 |
240 callback_.Run(status, 0, message); | 240 callback_.Run(status, 0, message); |
241 #endif // defined(GOOGLE_CHROME_BUILD) | 241 #endif // defined(GOOGLE_CHROME_BUILD) |
242 } | 242 } |
243 | 243 |
244 void VersionUpdaterWin::GotInstalledVersion(const Version& version) { | 244 void VersionUpdaterWin::GotInstalledVersion(const base::Version& version) { |
245 // This must be called on the UI thread so that callback_ can be called. | 245 // This must be called on the UI thread so that callback_ can be called. |
246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 246 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
247 | 247 |
248 // Make sure that the latest version is running and if not, | 248 // Make sure that the latest version is running and if not, |
249 // notify the user by setting the status to NEARLY_UPDATED. | 249 // notify the user by setting the status to NEARLY_UPDATED. |
250 // | 250 // |
251 // The extra version check is necessary on Windows because the application | 251 // The extra version check is necessary on Windows because the application |
252 // may be already up to date on disk though the running app is still | 252 // may be already up to date on disk though the running app is still |
253 // out of date. | 253 // out of date. |
254 chrome::VersionInfo version_info; | 254 chrome::VersionInfo version_info; |
255 Version running_version(version_info.Version()); | 255 base::Version running_version(version_info.Version()); |
256 if (!version.IsValid() || version.CompareTo(running_version) <= 0) { | 256 if (!version.IsValid() || version.CompareTo(running_version) <= 0) { |
257 content::RecordAction( | 257 content::RecordAction( |
258 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); | 258 UserMetricsAction("UpgradeCheck_AlreadyUpToDate")); |
259 callback_.Run(UPDATED, 0, base::string16()); | 259 callback_.Run(UPDATED, 0, base::string16()); |
260 } else { | 260 } else { |
261 content::RecordAction(UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); | 261 content::RecordAction(UserMetricsAction("UpgradeCheck_AlreadyUpgraded")); |
262 callback_.Run(NEARLY_UPDATED, 0, base::string16()); | 262 callback_.Run(NEARLY_UPDATED, 0, base::string16()); |
263 } | 263 } |
264 } | 264 } |
265 | 265 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 << GetCurrentThreadId(); | 299 << GetCurrentThreadId(); |
300 #endif | 300 #endif |
301 return window; | 301 return window; |
302 } | 302 } |
303 | 303 |
304 } // namespace | 304 } // namespace |
305 | 305 |
306 VersionUpdater* VersionUpdater::Create() { | 306 VersionUpdater* VersionUpdater::Create() { |
307 return new VersionUpdaterWin; | 307 return new VersionUpdaterWin; |
308 } | 308 } |
OLD | NEW |