summaryrefslogtreecommitdiff
path: root/base/command_line.h
diff options
context:
space:
mode:
authorLuis Hector Chavez <lhchavez@google.com>2016-07-15 16:23:21 -0700
committerTreehugger Robot <treehugger-gerrit@google.com>2016-07-27 16:41:28 +0000
commit0c4f26a46430b8c503c65f5cae1d2b6876d53e30 (patch)
treefb97dc88b72d681efeb9cfa1b8693a6183180ad9 /base/command_line.h
parent0cfccb799ce68cc66d389e6885f8d73f95ee5c4f (diff)
downloadlibchrome-0c4f26a46430b8c503c65f5cae1d2b6876d53e30.tar.gz
libchrome: Uprev the library to r405848 from Chromium
Pulled the latest and greatest version of libchrome from Chromium. The merge was done against r405848 which corresponds to git commit 909e5d3ecab27bb09cc570c1c215d0221bd6fe53 of Jul 15, 2016 Notable changes are: - base::Bind() now explicitly disallows captures in lambdas (which was never allowed in the style guide). - base::ListValue::iterator now exposes std::unique_ptr<base::Value> instead of raw base::Value*. BUG: 29104761 TEST: All tests in libchrome_test pass on dragonboard-eng build Change-Id: I94b285a3be074efa30c4e71ae93c8f2a99fb0b87
Diffstat (limited to 'base/command_line.h')
-rw-r--r--base/command_line.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/base/command_line.h b/base/command_line.h
index 3de8873e26..3d29f8fee7 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 };
@@ -69,6 +69,13 @@ class BASE_EXPORT CommandLine {
// object and the behavior will be the same as Posix systems (only hyphens
// begin switches, everything else will be an arg).
static void set_slash_is_not_a_switch();
+
+ // Normally when the CommandLine singleton is initialized it gets the command
+ // line via the GetCommandLineW API and then uses the shell32 API
+ // CommandLineToArgvW to parse the command line and convert it back to
+ // argc and argv. Tests who don't want this dependency on shell32 and need
+ // to honor the arguments passed in should use this function.
+ static void InitUsingArgvForTesting(int argc, const char* const* argv);
#endif
// Initialize the current process CommandLine singleton. On Windows, ignores
@@ -83,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
@@ -94,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.
@@ -152,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;
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_; }
@@ -203,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: