summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 02:14:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-30 02:14:22 +0000
commitd420c31e107cd932582a4a8add0ce2676e4b52da (patch)
tree0e666287eac5bbd12cc709a932a84d4bb852964b
parentf6215a232664e488b9c6c66e191c6507d377edcb (diff)
downloadchromium_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
-rw-r--r--base/command_line.cc15
-rw-r--r--base/command_line.h7
-rw-r--r--base/multiprocess_test.h16
-rw-r--r--base/process_util_unittest.cc12
-rw-r--r--base/shared_memory_unittest.cc2
-rw-r--r--base/stats_table_unittest.cc2
-rw-r--r--chrome/common/process_watcher_unittest.cc4
-rw-r--r--chrome/common/sandbox_mac_diraccess_unittest.mm2
-rw-r--r--chrome/common/sandbox_mac_unittest_helper.mm2
-rw-r--r--chrome/renderer/renderer_main_unittest.cc10
-rw-r--r--ipc/ipc_tests.cc27
-rw-r--r--ipc/ipc_tests.h5
12 files changed, 53 insertions, 51 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]);
}
diff --git a/chrome/common/process_watcher_unittest.cc b/chrome/common/process_watcher_unittest.cc
index af4aaa2..159ebb59 100644
--- a/chrome/common/process_watcher_unittest.cc
+++ b/chrome/common/process_watcher_unittest.cc
@@ -29,7 +29,7 @@ bool IsProcessDead(base::ProcessHandle child) {
TEST_F(ProcessWatcherTest, DelayedTermination) {
base::ProcessHandle child_process =
- SpawnChild(L"process_watcher_test_never_die");
+ SpawnChild("process_watcher_test_never_die");
ProcessWatcher::EnsureProcessTerminated(child_process);
base::WaitForSingleProcess(child_process, 5000);
@@ -47,7 +47,7 @@ MULTIPROCESS_TEST_MAIN(process_watcher_test_never_die) {
TEST_F(ProcessWatcherTest, ImmediateTermination) {
base::ProcessHandle child_process =
- SpawnChild(L"process_watcher_test_die_immediately");
+ SpawnChild("process_watcher_test_die_immediately");
// Give it time to die.
sleep(2);
ProcessWatcher::EnsureProcessTerminated(child_process);
diff --git a/chrome/common/sandbox_mac_diraccess_unittest.mm b/chrome/common/sandbox_mac_diraccess_unittest.mm
index f356453..1f68a6b 100644
--- a/chrome/common/sandbox_mac_diraccess_unittest.mm
+++ b/chrome/common/sandbox_mac_diraccess_unittest.mm
@@ -34,7 +34,7 @@ class MacDirAccessSandboxTest : public MultiProcessTest {
public:
bool CheckSandbox(std::string directory_to_try) {
setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1);
- base::ProcessHandle child_process = SpawnChild(L"mac_sandbox_path_access");
+ base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access");
int code = -1;
if (!base::WaitForExitCode(child_process, &code)) {
LOG(WARNING) << "base::WaitForExitCode failed";
diff --git a/chrome/common/sandbox_mac_unittest_helper.mm b/chrome/common/sandbox_mac_unittest_helper.mm
index a14370f..5ad7260 100644
--- a/chrome/common/sandbox_mac_unittest_helper.mm
+++ b/chrome/common/sandbox_mac_unittest_helper.mm
@@ -71,7 +71,7 @@ bool MacSandboxTest::RunTestInSandbox(sandbox::SandboxProcessType sandbox_type,
if (test_data)
setenv(kTestDataKey, test_data, 1);
- base::ProcessHandle child_process = SpawnChild(L"mac_sandbox_test_runner");
+ base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner");
int code = -1;
if (!base::WaitForExitCode(child_process, &code)) {
LOG(WARNING) << "base::WaitForExitCode failed";
diff --git a/chrome/renderer/renderer_main_unittest.cc b/chrome/renderer/renderer_main_unittest.cc
index 4b561f8..fcc4f6f 100644
--- a/chrome/renderer/renderer_main_unittest.cc
+++ b/chrome/renderer/renderer_main_unittest.cc
@@ -30,8 +30,8 @@ class RendererMainTest : public MultiProcessTest {
virtual void TearDown();
// Spawns a child process of the specified type
- base::ProcessHandle SpawnChild(const std::wstring &procname,
- IPC::Channel *channel);
+ base::ProcessHandle SpawnChild(const std::string& procname,
+ IPC::Channel* channel);
// Created around each test instantiation.
MessageLoopForIO *message_loop_;
@@ -51,8 +51,8 @@ void RendererMainTest::TearDown() {
MultiProcessTest::TearDown();
}
-ProcessHandle RendererMainTest::SpawnChild(const std::wstring &procname,
- IPC::Channel *channel) {
+ProcessHandle RendererMainTest::SpawnChild(const std::string& procname,
+ IPC::Channel* channel) {
base::file_handle_mapping_vector fds_to_map;
const int ipcfd = channel->GetClientFileDescriptor();
if (ipcfd > -1) {
@@ -90,7 +90,7 @@ TEST_F(RendererMainTest, CreateDestroy) {
IPC::Channel control_channel(kRendererTestChannelName,
IPC::Channel::MODE_SERVER,
&listener);
- base::ProcessHandle renderer_pid = SpawnChild(L"SimpleRenderer",
+ base::ProcessHandle renderer_pid = SpawnChild("SimpleRenderer",
&control_channel);
control_channel.Connect();
diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc
index c11fb70..c82eef9 100644
--- a/ipc/ipc_tests.cc
+++ b/ipc/ipc_tests.cc
@@ -67,20 +67,15 @@ base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
switch (child_type) {
case TEST_CLIENT:
- return MultiProcessTest::SpawnChild(L"RunTestClient", debug_on_start);
- break;
+ return MultiProcessTest::SpawnChild("RunTestClient", debug_on_start);
case TEST_REFLECTOR:
- return MultiProcessTest::SpawnChild(L"RunReflector", debug_on_start);
- break;
+ return MultiProcessTest::SpawnChild("RunReflector", debug_on_start);
case FUZZER_SERVER:
- return MultiProcessTest::SpawnChild(L"RunFuzzServer", debug_on_start);
- break;
+ return MultiProcessTest::SpawnChild("RunFuzzServer", debug_on_start);
case SYNC_SOCKET_SERVER:
- return MultiProcessTest::SpawnChild(L"RunSyncSocketServer", debug_on_start);
- break;
+ return MultiProcessTest::SpawnChild("RunSyncSocketServer", debug_on_start);
default:
return NULL;
- break;
}
}
#elif defined(OS_POSIX)
@@ -99,32 +94,32 @@ base::ProcessHandle IPCChannelTest::SpawnChild(ChildType child_type,
base::ProcessHandle ret = NULL;
switch (child_type) {
case TEST_CLIENT:
- ret = MultiProcessTest::SpawnChild(L"RunTestClient",
+ ret = MultiProcessTest::SpawnChild("RunTestClient",
fds_to_map,
debug_on_start);
break;
case TEST_DESCRIPTOR_CLIENT:
- ret = MultiProcessTest::SpawnChild(L"RunTestDescriptorClient",
+ ret = MultiProcessTest::SpawnChild("RunTestDescriptorClient",
fds_to_map,
debug_on_start);
break;
case TEST_DESCRIPTOR_CLIENT_SANDBOXED:
- ret = MultiProcessTest::SpawnChild(L"RunTestDescriptorClientSandboxed",
+ ret = MultiProcessTest::SpawnChild("RunTestDescriptorClientSandboxed",
fds_to_map,
debug_on_start);
break;
case TEST_REFLECTOR:
- ret = MultiProcessTest::SpawnChild(L"RunReflector",
+ ret = MultiProcessTest::SpawnChild("RunReflector",
fds_to_map,
debug_on_start);
break;
case FUZZER_SERVER:
- ret = MultiProcessTest::SpawnChild(L"RunFuzzServer",
+ ret = MultiProcessTest::SpawnChild("RunFuzzServer",
fds_to_map,
debug_on_start);
break;
case SYNC_SOCKET_SERVER:
- ret = MultiProcessTest::SpawnChild(L"RunSyncSocketServer",
+ ret = MultiProcessTest::SpawnChild("RunSyncSocketServer",
fds_to_map,
debug_on_start);
break;
@@ -272,7 +267,7 @@ TEST_F(IPCChannelTest, ChannelProxyTest) {
}
base::ProcessHandle process_handle = MultiProcessTest::SpawnChild(
- L"RunTestClient",
+ "RunTestClient",
fds_to_map,
debug_on_start);
#endif // defined(OS_POSIX)
diff --git a/ipc/ipc_tests.h b/ipc/ipc_tests.h
index 89117ab..09a5ab8 100644
--- a/ipc/ipc_tests.h
+++ b/ipc/ipc_tests.h
@@ -40,11 +40,10 @@ class IPCChannelTest : public MultiProcessTest {
virtual void TearDown();
// Spawns a child process of the specified type
- base::ProcessHandle SpawnChild(ChildType child_type,
- IPC::Channel *channel);
+ base::ProcessHandle SpawnChild(ChildType child_type, IPC::Channel* channel);
// Created around each test instantiation.
- MessageLoopForIO *message_loop_;
+ MessageLoopForIO* message_loop_;
};
#endif // IPC_IPC_TESTS_H__