Chromium Code Reviews| 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: |