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

Unified Diff: base/command_line.h

Issue 2148213002: Recommend base::test::ScopedCommandLine usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/command_line.h
diff --git a/base/command_line.h b/base/command_line.h
index 860d1c2c06be27d8784b64924294bd96538f5787..3d29f8fee7fbb8de9e8c1fb691515ddb8bdccbdd 100644
--- a/base/command_line.h
+++ b/base/command_line.h
@@ -33,15 +33,15 @@ class BASE_EXPORT CommandLine {
public:
#if defined(OS_WIN)
// The native command line string type.
- typedef base::string16 StringType;
+ using StringType = string16;
#elif defined(OS_POSIX)
- typedef std::string StringType;
+ using StringType = std::string;
#endif
- typedef StringType::value_type CharType;
- typedef std::vector<StringType> StringVector;
- typedef std::map<std::string, StringType> SwitchMap;
- typedef std::map<base::StringPiece, const StringType*> StringPieceSwitchMap;
+ using CharType = StringType::value_type;
+ using StringVector = std::vector<StringType>;
+ using SwitchMap = std::map<std::string, StringType>;
+ using StringPieceSwitchMap = std::map<StringPiece, const StringType*>;
// A constructor for CommandLines that only carry switches and arguments.
enum NoProgram { NO_PROGRAM };
@@ -90,6 +90,7 @@ class BASE_EXPORT CommandLine {
// you want to reset the base library to its initial state (for example, in an
// outer library that needs to be able to terminate, and be re-initialized).
// If Init is called only once, as in main(), Reset() is not necessary.
+ // Do not call this in tests. Use base::test::ScopedCommandLine instead.
static void Reset();
// Get the singleton CommandLine representing the current process's
@@ -101,7 +102,7 @@ class BASE_EXPORT CommandLine {
static bool InitializedForCurrentProcess();
#if defined(OS_WIN)
- static CommandLine FromString(const base::string16& command_line);
+ static CommandLine FromString(const string16& command_line);
#endif
// Initialize from an argv vector.
@@ -159,15 +160,15 @@ class BASE_EXPORT CommandLine {
// The second override provides an optimized version to avoid inlining codegen
// at every callsite to find the length of the constant and construct a
// StringPiece.
- bool HasSwitch(const base::StringPiece& switch_string) const;
+ bool HasSwitch(const StringPiece& switch_string) const;
Lei Zhang 2016/07/14 10:24:22 Shall we pass these by value while we are here?
Mark Mentovai 2016/07/14 14:24:02 Lei Zhang (Slow Thursday) wrote:
Lei Zhang 2016/07/15 00:44:39 base::StringPiece (and base::Time) says to prefer
bool HasSwitch(const char switch_constant[]) const;
// Returns the value associated with the given switch. If the switch has no
// value or isn't present, this method returns the empty string.
// Switch names must be lowercase.
- std::string GetSwitchValueASCII(const base::StringPiece& switch_string) const;
- FilePath GetSwitchValuePath(const base::StringPiece& switch_string) const;
- StringType GetSwitchValueNative(const base::StringPiece& switch_string) const;
+ std::string GetSwitchValueASCII(const StringPiece& switch_string) const;
+ FilePath GetSwitchValuePath(const StringPiece& switch_string) const;
+ StringType GetSwitchValueNative(const StringPiece& switch_string) const;
// Get a copy of all switches, along with their values.
const SwitchMap& GetSwitches() const { return switches_; }
@@ -210,7 +211,7 @@ class BASE_EXPORT CommandLine {
#if defined(OS_WIN)
// Initialize by parsing the given command line string.
// The program name is assumed to be the first item in the string.
- void ParseFromString(const base::string16& command_line);
+ void ParseFromString(const string16& command_line);
#endif
private:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698