diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 02:14:22 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 02:14:22 +0000 |
commit | d420c31e107cd932582a4a8add0ce2676e4b52da (patch) | |
tree | 0e666287eac5bbd12cc709a932a84d4bb852964b /base | |
parent | f6215a232664e488b9c6c66e191c6507d377edcb (diff) | |
download | chromium_src-d420c31e107cd932582a4a8add0ce2676e4b52da.zip chromium_src-d420c31e107cd932582a4a8add0ce2676e4b52da.tar.gz chromium_src-d420c31e107cd932582a4a8add0ce2676e4b52da.tar.bz2 |
Add an AppendSwitchASCII to CommandLine, and convert a test to it.
I'm removing all the AppendSwitchWithValue() users due to wstrings,
and this is one caller. Since fixing this one caller requires
touching many files, I thought I'd isolate this change from
the other WithValue->ASCII conversions.
Review URL: http://codereview.chromium.org/2878065
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54257 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/command_line.cc | 15 | ||||
-rw-r--r-- | base/command_line.h | 7 | ||||
-rw-r--r-- | base/multiprocess_test.h | 16 | ||||
-rw-r--r-- | base/process_util_unittest.cc | 12 | ||||
-rw-r--r-- | base/shared_memory_unittest.cc | 2 | ||||
-rw-r--r-- | base/stats_table_unittest.cc | 2 |
6 files changed, 31 insertions, 23 deletions
diff --git a/base/command_line.cc b/base/command_line.cc index 19f508a..b94e837 100644 --- a/base/command_line.cc +++ b/base/command_line.cc @@ -383,6 +383,11 @@ void CommandLine::AppendSwitch(const std::string& switch_string) { switches_[switch_string] = L""; } +void CommandLine::AppendSwitchASCII(const std::string& switch_string, + const std::string& value_string) { + AppendSwitchNative(switch_string, ASCIIToWide(value_string)); +} + void CommandLine::AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string) { AppendSwitchNative(switch_string, value_string); @@ -453,6 +458,11 @@ void CommandLine::AppendSwitchNative(const std::string& switch_string, switches_[switch_string] = value; } +void CommandLine::AppendSwitchASCII(const std::string& switch_string, + const std::string& value_string) { + AppendSwitchNative(switch_string, value_string); +} + void CommandLine::AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string) { // TODO(evanm): deprecate. @@ -493,11 +503,6 @@ void CommandLine::AppendSwitchPath(const std::string& switch_string, AppendSwitchNative(switch_string, path.value()); } -void CommandLine::AppendSwitchWithValue(const std::string& switch_string, - const std::string& value_string) { - AppendSwitchWithValue(switch_string, ASCIIToWide(value_string)); -} - void CommandLine::CopySwitchesFrom(const CommandLine& source, const char* const switches[], size_t count) { diff --git a/base/command_line.h b/base/command_line.h index 89df392..ae05021 100644 --- a/base/command_line.h +++ b/base/command_line.h @@ -162,14 +162,17 @@ class CommandLine { void AppendSwitchPath(const std::string& switch_string, const FilePath& path); void AppendSwitchNative(const std::string& switch_string, const StringType& value); + void AppendSwitchASCII(const std::string& switch_string, + const std::string& value); // Append a switch and value to the command line. // TODO(evanm): remove all AppendSwitchWithValue() instances. - // TODO(evanm): add an *ASCII() version. void AppendSwitchWithValue(const std::string& switch_string, const std::wstring& value_string); void AppendSwitchWithValue(const std::string& switch_string, - const std::string& value_string); + const std::string& value_string) { + AppendSwitchASCII(switch_string, value_string); + } // Append a loose value to the command line. void AppendLooseValue(const std::wstring& value); diff --git a/base/multiprocess_test.h b/base/multiprocess_test.h index 459f175..37d5228 100644 --- a/base/multiprocess_test.h +++ b/base/multiprocess_test.h @@ -41,7 +41,7 @@ static const char kRunClientProcess[] = "client"; // testing/multiprocess_func_list.h. // See the declaration of the MULTIPROCESS_TEST_MAIN macro // in that file for an example. -// 3) Call SpawnChild(L"foo"), where "foo" is the name of +// 3) Call SpawnChild("foo"), where "foo" is the name of // the function you wish to run in the child processes. // That's it! // @@ -61,11 +61,11 @@ class MultiProcessTest : public PlatformTest { // // TODO(darin): re-enable this once we have base/debug_util.h // ProcessDebugFlags(&cl, DebugUtil::UNKNOWN, false); - base::ProcessHandle SpawnChild(const std::wstring& procname) { + base::ProcessHandle SpawnChild(const std::string& procname) { return SpawnChild(procname, false); } - base::ProcessHandle SpawnChild(const std::wstring& procname, + base::ProcessHandle SpawnChild(const std::string& procname, bool debug_on_start) { #if defined(OS_WIN) return SpawnChildImpl(procname, debug_on_start); @@ -77,7 +77,7 @@ class MultiProcessTest : public PlatformTest { #if defined(OS_POSIX) base::ProcessHandle SpawnChild( - const std::wstring& procname, + const std::string& procname, const base::file_handle_mapping_vector& fds_to_map, bool debug_on_start) { return SpawnChildImpl(procname, fds_to_map, debug_on_start); @@ -85,9 +85,9 @@ class MultiProcessTest : public PlatformTest { #endif protected: - CommandLine MakeCmdLine(const std::wstring& procname, bool debug_on_start) { + CommandLine MakeCmdLine(const std::string& procname, bool debug_on_start) { CommandLine cl(*CommandLine::ForCurrentProcess()); - cl.AppendSwitchWithValue(kRunClientProcess, procname); + cl.AppendSwitchASCII(kRunClientProcess, procname); if (debug_on_start) cl.AppendSwitch(switches::kDebugOnStart); return cl; @@ -95,7 +95,7 @@ protected: private: #if defined(OS_WIN) - base::ProcessHandle SpawnChildImpl(const std::wstring& procname, + base::ProcessHandle SpawnChildImpl(const std::string& procname, bool debug_on_start) { base::ProcessHandle handle = static_cast<base::ProcessHandle>(NULL); base::LaunchApp(MakeCmdLine(procname, debug_on_start), @@ -107,7 +107,7 @@ protected: // TODO(port): with the CommandLine refactoring, this code is very similar // to the Windows code. Investigate whether this can be made shorter. base::ProcessHandle SpawnChildImpl( - const std::wstring& procname, + const std::string& procname, const base::file_handle_mapping_vector& fds_to_map, bool debug_on_start) { base::ProcessHandle handle = base::kNullProcessHandle; diff --git a/base/process_util_unittest.cc b/base/process_util_unittest.cc index 481c759..92031c9 100644 --- a/base/process_util_unittest.cc +++ b/base/process_util_unittest.cc @@ -74,7 +74,7 @@ MULTIPROCESS_TEST_MAIN(SimpleChildProcess) { } TEST_F(ProcessUtilTest, SpawnChild) { - base::ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); + base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); base::CloseProcessHandle(handle); @@ -87,7 +87,7 @@ MULTIPROCESS_TEST_MAIN(SlowChildProcess) { TEST_F(ProcessUtilTest, KillSlowChild) { remove("SlowChildProcess.die"); - base::ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); + base::ProcessHandle handle = this->SpawnChild("SlowChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); SignalChildren("SlowChildProcess.die"); EXPECT_TRUE(base::WaitForSingleProcess(handle, 5000)); @@ -97,7 +97,7 @@ TEST_F(ProcessUtilTest, KillSlowChild) { TEST_F(ProcessUtilTest, DidProcessCrash) { remove("SlowChildProcess.die"); - base::ProcessHandle handle = this->SpawnChild(L"SlowChildProcess"); + base::ProcessHandle handle = this->SpawnChild("SlowChildProcess"); ASSERT_NE(base::kNullProcessHandle, handle); bool child_exited = true; @@ -117,7 +117,7 @@ TEST_F(ProcessUtilTest, DidProcessCrash) { // Note: a platform may not be willing or able to lower the priority of // a process. The calls to SetProcessBackground should be noops then. TEST_F(ProcessUtilTest, SetProcessBackgrounded) { - base::ProcessHandle handle = this->SpawnChild(L"SimpleChildProcess"); + base::ProcessHandle handle = this->SpawnChild("SimpleChildProcess"); base::Process process(handle); int old_priority = process.GetPriority(); process.SetProcessBackgrounded(true); @@ -225,7 +225,7 @@ TEST_F(ProcessUtilTest, LaunchAsUser) { base::UserTokenHandle token; ASSERT_TRUE(OpenProcessToken(GetCurrentProcess(), TOKEN_ALL_ACCESS, &token)); std::wstring cmdline = - this->MakeCmdLine(L"SimpleChildProcess", false).command_line_string(); + this->MakeCmdLine("SimpleChildProcess", false).command_line_string(); EXPECT_TRUE(base::LaunchAppAsUser(token, cmdline, false, NULL)); } @@ -290,7 +290,7 @@ int ProcessUtilTest::CountOpenFDsInChild() { base::file_handle_mapping_vector fd_mapping_vec; fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe)); base::ProcessHandle handle = this->SpawnChild( - L"ProcessUtilsLeakFDChildProcess", fd_mapping_vec, false); + "ProcessUtilsLeakFDChildProcess", fd_mapping_vec, false); CHECK(handle); int ret = HANDLE_EINTR(close(fds[1])); DPCHECK(ret == 0); diff --git a/base/shared_memory_unittest.cc b/base/shared_memory_unittest.cc index 459b423..88b5fa0 100644 --- a/base/shared_memory_unittest.cc +++ b/base/shared_memory_unittest.cc @@ -326,7 +326,7 @@ TEST_F(SharedMemoryProcessTest, Tasks) { base::ProcessHandle handles[kNumTasks]; for (int index = 0; index < kNumTasks; ++index) { - handles[index] = SpawnChild(L"SharedMemoryTestMain"); + handles[index] = SpawnChild("SharedMemoryTestMain"); } int exit_code = 0; diff --git a/base/stats_table_unittest.cc b/base/stats_table_unittest.cc index 5c8e499..848ef97 100644 --- a/base/stats_table_unittest.cc +++ b/base/stats_table_unittest.cc @@ -204,7 +204,7 @@ TEST_F(StatsTableTest, MultipleProcesses) { // Spawn the processes. for (int16 index = 0; index < kMaxProcs; index++) { - procs[index] = this->SpawnChild(L"StatsTableMultipleProcessMain"); + procs[index] = this->SpawnChild("StatsTableMultipleProcessMain"); EXPECT_NE(base::kNullProcessHandle, procs[index]); } |