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

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

Issue 2258263002: Consistently use namespaced base::Version. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased against master. Created 4 years, 3 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
OLDNEW
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 "chrome/browser/upgrade_detector_impl.h" 5 #include "chrome/browser/upgrade_detector_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 GoogleUpdateSettings::AreAutoupdatesEnabled(); 148 GoogleUpdateSettings::AreAutoupdatesEnabled();
149 } 149 }
150 *is_unstable_channel = IsUnstableChannel(); 150 *is_unstable_channel = IsUnstableChannel();
151 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task); 151 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, callback_task);
152 } 152 }
153 #endif // defined(GOOGLE_CHROME_BUILD) 153 #endif // defined(GOOGLE_CHROME_BUILD)
154 #endif // !defined(OS_WIN) 154 #endif // !defined(OS_WIN)
155 155
156 // Gets the currently installed version. On Windows, if |critical_update| is not 156 // Gets the currently installed version. On Windows, if |critical_update| is not
157 // NULL, also retrieves the critical update version info if available. 157 // NULL, also retrieves the critical update version info if available.
158 base::Version GetCurrentlyInstalledVersionImpl(Version* critical_update) { 158 base::Version GetCurrentlyInstalledVersionImpl(base::Version* critical_update) {
159 base::ThreadRestrictions::AssertIOAllowed(); 159 base::ThreadRestrictions::AssertIOAllowed();
160 160
161 Version installed_version; 161 base::Version installed_version;
162 #if defined(OS_WIN) 162 #if defined(OS_WIN)
163 // Get the version of the currently *installed* instance of Chrome, 163 // Get the version of the currently *installed* instance of Chrome,
164 // which might be newer than the *running* instance if we have been 164 // which might be newer than the *running* instance if we have been
165 // upgraded in the background. 165 // upgraded in the background.
166 bool system_install = IsSystemInstall(); 166 bool system_install = IsSystemInstall();
167 167
168 // TODO(tommi): Check if using the default distribution is always the right 168 // TODO(tommi): Check if using the default distribution is always the right
169 // thing to do. 169 // thing to do.
170 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 170 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
171 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); 171 InstallUtil::GetChromeVersion(dist, system_install, &installed_version);
172 if (critical_update && installed_version.IsValid()) { 172 if (critical_update && installed_version.IsValid()) {
173 InstallUtil::GetCriticalUpdateVersion(dist, system_install, 173 InstallUtil::GetCriticalUpdateVersion(dist, system_install,
174 critical_update); 174 critical_update);
175 } 175 }
176 #elif defined(OS_MACOSX) 176 #elif defined(OS_MACOSX)
177 installed_version = 177 installed_version = base::Version(
178 Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); 178 base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion()));
179 #elif defined(OS_POSIX) 179 #elif defined(OS_POSIX)
180 // POSIX but not Mac OS X: Linux, etc. 180 // POSIX but not Mac OS X: Linux, etc.
181 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess()); 181 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
182 command_line.AppendSwitch(switches::kProductVersion); 182 command_line.AppendSwitch(switches::kProductVersion);
183 std::string reply; 183 std::string reply;
184 if (!base::GetAppOutput(command_line, &reply)) { 184 if (!base::GetAppOutput(command_line, &reply)) {
185 DLOG(ERROR) << "Failed to get current file version"; 185 DLOG(ERROR) << "Failed to get current file version";
186 return installed_version; 186 return installed_version;
187 } 187 }
188 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply); 188 base::TrimWhitespaceASCII(reply, base::TRIM_ALL, &reply);
189 189
190 installed_version = Version(reply); 190 installed_version = base::Version(reply);
191 #endif 191 #endif
192 return installed_version; 192 return installed_version;
193 } 193 }
194 194
195 } // namespace 195 } // namespace
196 196
197 UpgradeDetectorImpl::UpgradeDetectorImpl() 197 UpgradeDetectorImpl::UpgradeDetectorImpl()
198 : is_unstable_channel_(false), 198 : is_unstable_channel_(false),
199 is_auto_update_enabled_(true), 199 is_auto_update_enabled_(true),
200 build_date_(base::GetBuildTime()), 200 build_date_(base::GetBuildTime()),
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 // static 311 // static
312 // This task checks the currently running version of Chrome against the 312 // This task checks the currently running version of Chrome against the
313 // installed version. If the installed version is newer, it calls back 313 // installed version. If the installed version is newer, it calls back
314 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can 314 // UpgradeDetectorImpl::UpgradeDetected using a weak pointer so that it can
315 // be interrupted from the UI thread. 315 // be interrupted from the UI thread.
316 void UpgradeDetectorImpl::DetectUpgradeTask( 316 void UpgradeDetectorImpl::DetectUpgradeTask(
317 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) { 317 base::WeakPtr<UpgradeDetectorImpl> upgrade_detector) {
318 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 318 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
319 319
320 Version critical_update; 320 base::Version critical_update;
321 Version installed_version = 321 base::Version installed_version =
322 GetCurrentlyInstalledVersionImpl(&critical_update); 322 GetCurrentlyInstalledVersionImpl(&critical_update);
323 323
324 // Get the version of the currently *running* instance of Chrome. 324 // Get the version of the currently *running* instance of Chrome.
325 Version running_version(version_info::GetVersionNumber()); 325 base::Version running_version(version_info::GetVersionNumber());
326 if (!running_version.IsValid()) { 326 if (!running_version.IsValid()) {
327 NOTREACHED(); 327 NOTREACHED();
328 return; 328 return;
329 } 329 }
330 330
331 // |installed_version| may be NULL when the user downgrades on Linux (by 331 // |installed_version| may be NULL when the user downgrades on Linux (by
332 // switching from dev to beta channel, for example). The user needs a 332 // switching from dev to beta channel, for example). The user needs a
333 // restart in this case as well. See http://crbug.com/46547 333 // restart in this case as well. See http://crbug.com/46547
334 if (!installed_version.IsValid() || 334 if (!installed_version.IsValid() ||
335 (installed_version.CompareTo(running_version) > 0)) { 335 (installed_version.CompareTo(running_version) > 0)) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 522
523 // static 523 // static
524 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { 524 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() {
525 return base::Singleton<UpgradeDetectorImpl>::get(); 525 return base::Singleton<UpgradeDetectorImpl>::get();
526 } 526 }
527 527
528 // static 528 // static
529 UpgradeDetector* UpgradeDetector::GetInstance() { 529 UpgradeDetector* UpgradeDetector::GetInstance() {
530 return UpgradeDetectorImpl::GetInstance(); 530 return UpgradeDetectorImpl::GetInstance();
531 } 531 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/startup/default_browser_prompt.cc ('k') | chrome/common/chrome_content_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698