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

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

Issue 816403003: Make callers of CommandLine use it via the base:: namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 5 years, 12 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
« no previous file with comments | « chrome/browser/upgrade_detector.cc ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/build_time.h" 10 #include "base/build_time.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 // Same as kNotifyCycleTimeMs but only used during testing. 52 // Same as kNotifyCycleTimeMs but only used during testing.
53 const int kNotifyCycleTimeForTestingMs = 500; // Half a second. 53 const int kNotifyCycleTimeForTestingMs = 500; // Half a second.
54 54
55 // The number of days after which we identify a build/install as outdated. 55 // The number of days after which we identify a build/install as outdated.
56 const uint64 kOutdatedBuildAgeInDays = 12 * 7; 56 const uint64 kOutdatedBuildAgeInDays = 12 * 7;
57 57
58 // Return the string that was passed as a value for the 58 // Return the string that was passed as a value for the
59 // kCheckForUpdateIntervalSec switch. 59 // kCheckForUpdateIntervalSec switch.
60 std::string CmdLineInterval() { 60 std::string CmdLineInterval() {
61 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); 61 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
62 return cmd_line.GetSwitchValueASCII(switches::kCheckForUpdateIntervalSec); 62 return cmd_line.GetSwitchValueASCII(switches::kCheckForUpdateIntervalSec);
63 } 63 }
64 64
65 // Check if one of the outdated simulation switches was present on the command 65 // Check if one of the outdated simulation switches was present on the command
66 // line. 66 // line.
67 bool SimulatingOutdated() { 67 bool SimulatingOutdated() {
68 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); 68 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
69 return cmd_line.HasSwitch(switches::kSimulateOutdated) || 69 return cmd_line.HasSwitch(switches::kSimulateOutdated) ||
70 cmd_line.HasSwitch(switches::kSimulateOutdatedNoAU); 70 cmd_line.HasSwitch(switches::kSimulateOutdatedNoAU);
71 } 71 }
72 72
73 // Check if any of the testing switches was present on the command line. 73 // Check if any of the testing switches was present on the command line.
74 bool IsTesting() { 74 bool IsTesting() {
75 const CommandLine& cmd_line = *CommandLine::ForCurrentProcess(); 75 const base::CommandLine& cmd_line = *base::CommandLine::ForCurrentProcess();
76 return cmd_line.HasSwitch(switches::kSimulateUpgrade) || 76 return cmd_line.HasSwitch(switches::kSimulateUpgrade) ||
77 cmd_line.HasSwitch(switches::kCheckForUpdateIntervalSec) || 77 cmd_line.HasSwitch(switches::kCheckForUpdateIntervalSec) ||
78 cmd_line.HasSwitch(switches::kSimulateCriticalUpdate) || 78 cmd_line.HasSwitch(switches::kSimulateCriticalUpdate) ||
79 SimulatingOutdated(); 79 SimulatingOutdated();
80 } 80 }
81 81
82 // How often to check for an upgrade. 82 // How often to check for an upgrade.
83 int GetCheckForUpgradeEveryMs() { 83 int GetCheckForUpgradeEveryMs() {
84 // Check for a value passed via the command line. 84 // Check for a value passed via the command line.
85 int interval_ms; 85 int interval_ms;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 InstallUtil::GetChromeVersion(dist, system_install, &installed_version); 162 InstallUtil::GetChromeVersion(dist, system_install, &installed_version);
163 if (critical_update && installed_version.IsValid()) { 163 if (critical_update && installed_version.IsValid()) {
164 InstallUtil::GetCriticalUpdateVersion(dist, system_install, 164 InstallUtil::GetCriticalUpdateVersion(dist, system_install,
165 critical_update); 165 critical_update);
166 } 166 }
167 #elif defined(OS_MACOSX) 167 #elif defined(OS_MACOSX)
168 installed_version = 168 installed_version =
169 Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion())); 169 Version(base::UTF16ToASCII(keystone_glue::CurrentlyInstalledVersion()));
170 #elif defined(OS_POSIX) 170 #elif defined(OS_POSIX)
171 // POSIX but not Mac OS X: Linux, etc. 171 // POSIX but not Mac OS X: Linux, etc.
172 CommandLine command_line(*CommandLine::ForCurrentProcess()); 172 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
173 command_line.AppendSwitch(switches::kProductVersion); 173 command_line.AppendSwitch(switches::kProductVersion);
174 std::string reply; 174 std::string reply;
175 if (!base::GetAppOutput(command_line, &reply)) { 175 if (!base::GetAppOutput(command_line, &reply)) {
176 DLOG(ERROR) << "Failed to get current file version"; 176 DLOG(ERROR) << "Failed to get current file version";
177 return installed_version; 177 return installed_version;
178 } 178 }
179 179
180 installed_version = Version(reply); 180 installed_version = Version(reply);
181 #endif 181 #endif
182 return installed_version; 182 return installed_version;
183 } 183 }
184 184
185 } // namespace 185 } // namespace
186 186
187 UpgradeDetectorImpl::UpgradeDetectorImpl() 187 UpgradeDetectorImpl::UpgradeDetectorImpl()
188 : is_unstable_channel_(false), 188 : is_unstable_channel_(false),
189 is_auto_update_enabled_(true), 189 is_auto_update_enabled_(true),
190 build_date_(base::GetBuildTime()), 190 build_date_(base::GetBuildTime()),
191 weak_factory_(this) { 191 weak_factory_(this) {
192 CommandLine command_line(*CommandLine::ForCurrentProcess()); 192 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
193 // The different command line switches that affect testing can't be used 193 // The different command line switches that affect testing can't be used
194 // simultaneously, if they do, here's the precedence order, based on the order 194 // simultaneously, if they do, here's the precedence order, based on the order
195 // of the if statements below: 195 // of the if statements below:
196 // - kDisableBackgroundNetworking prevents any of the other command line 196 // - kDisableBackgroundNetworking prevents any of the other command line
197 // switch from being taken into account. 197 // switch from being taken into account.
198 // - kSimulateUpgrade supersedes critical or outdated upgrade switches. 198 // - kSimulateUpgrade supersedes critical or outdated upgrade switches.
199 // - kSimulateCriticalUpdate has precedence over kSimulateOutdated. 199 // - kSimulateCriticalUpdate has precedence over kSimulateOutdated.
200 // - kSimulateOutdatedNoAU has precedence over kSimulateOutdated. 200 // - kSimulateOutdatedNoAU has precedence over kSimulateOutdated.
201 // - kSimulateOutdated[NoAu] can work on its own, or with a specified date. 201 // - kSimulateOutdated[NoAu] can work on its own, or with a specified date.
202 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking)) 202 if (command_line.HasSwitch(switches::kDisableBackgroundNetworking))
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 506
507 // static 507 // static
508 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { 508 UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() {
509 return Singleton<UpgradeDetectorImpl>::get(); 509 return Singleton<UpgradeDetectorImpl>::get();
510 } 510 }
511 511
512 // static 512 // static
513 UpgradeDetector* UpgradeDetector::GetInstance() { 513 UpgradeDetector* UpgradeDetector::GetInstance() {
514 return UpgradeDetectorImpl::GetInstance(); 514 return UpgradeDetectorImpl::GetInstance();
515 } 515 }
OLDNEW
« no previous file with comments | « chrome/browser/upgrade_detector.cc ('k') | chrome/browser/web_applications/web_app_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698