summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvargas <rvargas@chromium.org>2015-01-12 14:23:23 -0800
committerCommit bot <commit-bot@chromium.org>2015-01-12 22:25:04 +0000
commit07b589c1f6c4d0aac24e270a13fa83031bf2038c (patch)
tree18a5284042b77bb6845194277e8dea006576b636
parentd44cce5915db087d726ed2e141896401edeb09b7 (diff)
downloadchromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.zip
chromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.tar.gz
chromium_src-07b589c1f6c4d0aac24e270a13fa83031bf2038c.tar.bz2
MultiProcessTest: Update SpawnChild* to return a Process.
We should not be dealing with raw handles. BUG=417532 Review URL: https://codereview.chromium.org/843113003 Cr-Commit-Position: refs/heads/master@{#311127}
-rw-r--r--base/debug/stack_trace_unittest.cc7
-rw-r--r--base/memory/shared_memory_unittest.cc8
-rw-r--r--base/metrics/stats_table_unittest.cc10
-rw-r--r--base/process/process_util_unittest.cc67
-rw-r--r--base/test/multiprocess_test.cc10
-rw-r--r--base/test/multiprocess_test.h12
-rw-r--r--base/test/multiprocess_test_android.cc12
-rw-r--r--chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc35
-rw-r--r--chrome/common/multi_process_lock_unittest.cc12
-rw-r--r--chrome/common/service_process_util_unittest.cc15
-rw-r--r--components/browser_watcher/exit_code_watcher_win_unittest.cc3
-rw-r--r--content/common/sandbox_mac_diraccess_unittest.mm8
-rw-r--r--content/common/sandbox_mac_unittest_helper.mm8
-rw-r--r--ipc/ipc_channel_posix_unittest.cc30
-rw-r--r--ipc/ipc_test_base.cc18
-rw-r--r--ipc/ipc_test_base.h4
-rw-r--r--ipc/mojo/ipc_channel_mojo_unittest.cc9
-rw-r--r--ipc/mojo/ipc_mojo_bootstrap_unittest.cc2
-rw-r--r--ipc/mojo/ipc_mojo_perftest.cc2
-rw-r--r--ipc/sync_socket_unittest.cc2
-rw-r--r--mojo/edk/test/multiprocess_test_helper.cc20
-rw-r--r--mojo/edk/test/multiprocess_test_helper.h4
-rw-r--r--sandbox/mac/bootstrap_sandbox_unittest.mm27
-rw-r--r--sandbox/mac/xpc_message_server_unittest.cc12
24 files changed, 161 insertions, 176 deletions
diff --git a/base/debug/stack_trace_unittest.cc b/base/debug/stack_trace_unittest.cc
index eb0bd9a..b07fcdb 100644
--- a/base/debug/stack_trace_unittest.cc
+++ b/base/debug/stack_trace_unittest.cc
@@ -146,9 +146,10 @@ MULTIPROCESS_TEST_MAIN(MismatchedMallocChildProcess) {
// and e.g. mismatched new[]/delete would cause a hang because
// of re-entering malloc.
TEST_F(StackTraceTest, AsyncSignalUnsafeSignalHandlerHang) {
- ProcessHandle child = SpawnChild("MismatchedMallocChildProcess");
- ASSERT_NE(kNullProcessHandle, child);
- ASSERT_TRUE(WaitForSingleProcess(child, TestTimeouts::action_timeout()));
+ Process child = SpawnChild("MismatchedMallocChildProcess");
+ ASSERT_TRUE(child.IsValid());
+ ASSERT_TRUE(WaitForSingleProcess(child.Handle(),
+ TestTimeouts::action_timeout()));
}
#endif // !defined(OS_IOS)
diff --git a/base/memory/shared_memory_unittest.cc b/base/memory/shared_memory_unittest.cc
index 265179a..6e5a4d8 100644
--- a/base/memory/shared_memory_unittest.cc
+++ b/base/memory/shared_memory_unittest.cc
@@ -699,15 +699,15 @@ const char* const SharedMemoryProcessTest::s_test_name_ = "MPMem";
TEST_F(SharedMemoryProcessTest, Tasks) {
SharedMemoryProcessTest::CleanUp();
- ProcessHandle handles[kNumTasks];
+ Process processes[kNumTasks];
for (int index = 0; index < kNumTasks; ++index) {
- handles[index] = SpawnChild("SharedMemoryTestMain");
- ASSERT_TRUE(handles[index]);
+ processes[index] = SpawnChild("SharedMemoryTestMain");
+ ASSERT_TRUE(processes[index].IsValid());
}
int exit_code = 0;
for (int index = 0; index < kNumTasks; ++index) {
- EXPECT_TRUE(WaitForExitCode(handles[index], &exit_code));
+ EXPECT_TRUE(processes[index].WaitForExit(&exit_code));
EXPECT_EQ(0, exit_code);
}
diff --git a/base/metrics/stats_table_unittest.cc b/base/metrics/stats_table_unittest.cc
index 45b0a43..38a21cc 100644
--- a/base/metrics/stats_table_unittest.cc
+++ b/base/metrics/stats_table_unittest.cc
@@ -200,19 +200,19 @@ TEST_F(StatsTableTest, DISABLED_MultipleProcesses) {
// Spin up a set of processes to go bang on the various counters.
// After we join the processes, we'll make sure the counters
// contain the values we expected.
- ProcessHandle procs[kMaxProcs];
+ Process procs[kMaxProcs];
// Spawn the processes.
for (int16 index = 0; index < kMaxProcs; index++) {
procs[index] = SpawnChild("StatsTableMultipleProcessMain");
- EXPECT_NE(kNullProcessHandle, procs[index]);
+ EXPECT_TRUE(procs[index].IsValid());
}
// Wait for the processes to finish.
for (int index = 0; index < kMaxProcs; index++) {
- EXPECT_TRUE(WaitForSingleProcess(
- procs[index], base::TimeDelta::FromMinutes(1)));
- CloseProcessHandle(procs[index]);
+ EXPECT_TRUE(WaitForSingleProcess(procs[index].Handle(),
+ base::TimeDelta::FromMinutes(1)));
+ procs[index].Close();
}
StatsCounter zero_counter(kCounterZero);
diff --git a/base/process/process_util_unittest.cc b/base/process/process_util_unittest.cc
index af88fe1..80e103d 100644
--- a/base/process/process_util_unittest.cc
+++ b/base/process/process_util_unittest.cc
@@ -142,11 +142,10 @@ MULTIPROCESS_TEST_MAIN(SimpleChildProcess) {
// TODO(viettrungluu): This should be in a "MultiProcessTestTest".
TEST_F(ProcessUtilTest, SpawnChild) {
- base::ProcessHandle handle = SpawnChild("SimpleChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
- EXPECT_TRUE(base::WaitForSingleProcess(
- handle, TestTimeouts::action_max_timeout()));
- base::CloseProcessHandle(handle);
+ base::Process process = SpawnChild("SimpleChildProcess");
+ ASSERT_TRUE(process.IsValid());
+ EXPECT_TRUE(base::WaitForSingleProcess(process.Handle(),
+ TestTimeouts::action_max_timeout()));
}
MULTIPROCESS_TEST_MAIN(SlowChildProcess) {
@@ -158,12 +157,11 @@ TEST_F(ProcessUtilTest, KillSlowChild) {
const std::string signal_file =
ProcessUtilTest::GetSignalFilePath(kSignalFileSlow);
remove(signal_file.c_str());
- base::ProcessHandle handle = SpawnChild("SlowChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
+ base::Process process = SpawnChild("SlowChildProcess");
+ ASSERT_TRUE(process.IsValid());
SignalChildren(signal_file.c_str());
- EXPECT_TRUE(base::WaitForSingleProcess(
- handle, TestTimeouts::action_max_timeout()));
- base::CloseProcessHandle(handle);
+ EXPECT_TRUE(base::WaitForSingleProcess(process.Handle(),
+ TestTimeouts::action_max_timeout()));
remove(signal_file.c_str());
}
@@ -172,21 +170,20 @@ TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) {
const std::string signal_file =
ProcessUtilTest::GetSignalFilePath(kSignalFileSlow);
remove(signal_file.c_str());
- base::ProcessHandle handle = SpawnChild("SlowChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
+ base::Process process = SpawnChild("SlowChildProcess");
+ ASSERT_TRUE(process.IsValid());
int exit_code = 42;
EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
- base::GetTerminationStatus(handle, &exit_code));
+ base::GetTerminationStatus(process.Handle(), &exit_code));
EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
SignalChildren(signal_file.c_str());
exit_code = 42;
base::TerminationStatus status =
- WaitForChildTermination(handle, &exit_code);
+ WaitForChildTermination(process.Handle(), &exit_code);
EXPECT_EQ(base::TERMINATION_STATUS_NORMAL_TERMINATION, status);
EXPECT_EQ(0, exit_code);
- base::CloseProcessHandle(handle);
remove(signal_file.c_str());
}
@@ -195,12 +192,11 @@ TEST_F(ProcessUtilTest, DISABLED_GetTerminationStatusExit) {
TEST_F(ProcessUtilTest, GetProcId) {
base::ProcessId id1 = base::GetProcId(GetCurrentProcess());
EXPECT_NE(0ul, id1);
- base::ProcessHandle handle = SpawnChild("SimpleChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
- base::ProcessId id2 = base::GetProcId(handle);
+ base::Process process = SpawnChild("SimpleChildProcess");
+ ASSERT_TRUE(process.IsValid());
+ base::ProcessId id2 = process.pid();
EXPECT_NE(0ul, id2);
EXPECT_NE(id1, id2);
- base::CloseProcessHandle(handle);
}
#endif
@@ -239,18 +235,18 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) {
const std::string signal_file =
ProcessUtilTest::GetSignalFilePath(kSignalFileCrash);
remove(signal_file.c_str());
- base::ProcessHandle handle = SpawnChild("CrashingChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
+ base::Process process = SpawnChild("CrashingChildProcess");
+ ASSERT_TRUE(process.IsValid());
int exit_code = 42;
EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
- base::GetTerminationStatus(handle, &exit_code));
+ base::GetTerminationStatus(process.Handle(), &exit_code));
EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
SignalChildren(signal_file.c_str());
exit_code = 42;
base::TerminationStatus status =
- WaitForChildTermination(handle, &exit_code);
+ WaitForChildTermination(process.Handle(), &exit_code);
EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_CRASHED, status);
#if defined(OS_WIN)
@@ -261,7 +257,6 @@ TEST_F(ProcessUtilTest, MAYBE_GetTerminationStatusCrash) {
int signal = WTERMSIG(exit_code);
EXPECT_EQ(SIGSEGV, signal);
#endif
- base::CloseProcessHandle(handle);
// Reset signal handlers back to "normal".
base::debug::EnableInProcessStackDumping();
@@ -286,18 +281,18 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) {
const std::string signal_file =
ProcessUtilTest::GetSignalFilePath(kSignalFileKill);
remove(signal_file.c_str());
- base::ProcessHandle handle = SpawnChild("KilledChildProcess");
- ASSERT_NE(base::kNullProcessHandle, handle);
+ base::Process process = SpawnChild("KilledChildProcess");
+ ASSERT_TRUE(process.IsValid());
int exit_code = 42;
EXPECT_EQ(base::TERMINATION_STATUS_STILL_RUNNING,
- base::GetTerminationStatus(handle, &exit_code));
+ base::GetTerminationStatus(process.Handle(), &exit_code));
EXPECT_EQ(kExpectedStillRunningExitCode, exit_code);
SignalChildren(signal_file.c_str());
exit_code = 42;
base::TerminationStatus status =
- WaitForChildTermination(handle, &exit_code);
+ WaitForChildTermination(process.Handle(), &exit_code);
EXPECT_EQ(base::TERMINATION_STATUS_PROCESS_WAS_KILLED, status);
#if defined(OS_WIN)
EXPECT_EQ(kExpectedKilledExitCode, exit_code);
@@ -307,7 +302,6 @@ TEST_F(ProcessUtilTest, GetTerminationStatusKill) {
int signal = WTERMSIG(exit_code);
EXPECT_EQ(SIGKILL, signal);
#endif
- base::CloseProcessHandle(handle);
remove(signal_file.c_str());
}
@@ -535,9 +529,9 @@ int ProcessUtilTest::CountOpenFDsInChild() {
fd_mapping_vec.push_back(std::pair<int, int>(fds[1], kChildPipe));
base::LaunchOptions options;
options.fds_to_remap = &fd_mapping_vec;
- base::ProcessHandle handle =
+ base::Process process =
SpawnChildWithOptions("ProcessUtilsLeakFDChildProcess", options);
- CHECK(handle);
+ CHECK(process.IsValid());
int ret = IGNORE_EINTR(close(fds[1]));
DPCHECK(ret == 0);
@@ -549,11 +543,12 @@ int ProcessUtilTest::CountOpenFDsInChild() {
#if defined(THREAD_SANITIZER)
// Compiler-based ThreadSanitizer makes this test slow.
- CHECK(base::WaitForSingleProcess(handle, base::TimeDelta::FromSeconds(3)));
+ CHECK(base::WaitForSingleProcess(process.Handle(),
+ base::TimeDelta::FromSeconds(3)));
#else
- CHECK(base::WaitForSingleProcess(handle, base::TimeDelta::FromSeconds(1)));
+ CHECK(base::WaitForSingleProcess(process.Handle(),
+ base::TimeDelta::FromSeconds(1)));
#endif
- base::CloseProcessHandle(handle);
ret = IGNORE_EINTR(close(fds[0]));
DPCHECK(ret == 0);
@@ -888,7 +883,7 @@ bool IsProcessDead(base::ProcessHandle child) {
}
TEST_F(ProcessUtilTest, DelayedTermination) {
- base::Process child_process(SpawnChild("process_util_test_never_die"));
+ base::Process child_process = SpawnChild("process_util_test_never_die");
ASSERT_TRUE(child_process.IsValid());
base::EnsureProcessTerminated(child_process.Duplicate());
base::WaitForSingleProcess(child_process.Handle(),
@@ -906,7 +901,7 @@ MULTIPROCESS_TEST_MAIN(process_util_test_never_die) {
}
TEST_F(ProcessUtilTest, ImmediateTermination) {
- base::Process child_process(SpawnChild("process_util_test_die_immediately"));
+ base::Process child_process = SpawnChild("process_util_test_die_immediately");
ASSERT_TRUE(child_process.IsValid());
// Give it time to die.
sleep(2);
diff --git a/base/test/multiprocess_test.cc b/base/test/multiprocess_test.cc
index 306c109..b95ea98 100644
--- a/base/test/multiprocess_test.cc
+++ b/base/test/multiprocess_test.cc
@@ -10,7 +10,7 @@
namespace base {
#if !defined(OS_ANDROID)
-ProcessHandle SpawnMultiProcessTestChild(
+Process SpawnMultiProcessTestChild(
const std::string& procname,
const CommandLine& base_command_line,
const LaunchOptions& options) {
@@ -21,9 +21,7 @@ ProcessHandle SpawnMultiProcessTestChild(
if (!command_line.HasSwitch(switches::kTestChildProcess))
command_line.AppendSwitchASCII(switches::kTestChildProcess, procname);
- ProcessHandle handle = kNullProcessHandle;
- LaunchProcess(command_line, options, &handle);
- return handle;
+ return LaunchProcess(command_line, options);
}
#endif // !defined(OS_ANDROID)
@@ -36,7 +34,7 @@ CommandLine GetMultiProcessTestChildBaseCommandLine() {
MultiProcessTest::MultiProcessTest() {
}
-ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname) {
+Process MultiProcessTest::SpawnChild(const std::string& procname) {
LaunchOptions options;
#if defined(OS_WIN)
options.start_hidden = true;
@@ -44,7 +42,7 @@ ProcessHandle MultiProcessTest::SpawnChild(const std::string& procname) {
return SpawnChildWithOptions(procname, options);
}
-ProcessHandle MultiProcessTest::SpawnChildWithOptions(
+Process MultiProcessTest::SpawnChildWithOptions(
const std::string& procname,
const LaunchOptions& options) {
return SpawnMultiProcessTestChild(procname, MakeCmdLine(procname), options);
diff --git a/base/test/multiprocess_test.h b/base/test/multiprocess_test.h
index b830f73..e419503 100644
--- a/base/test/multiprocess_test.h
+++ b/base/test/multiprocess_test.h
@@ -9,7 +9,7 @@
#include "base/basictypes.h"
#include "base/process/launch.h"
-#include "base/process/process_handle.h"
+#include "base/process/process.h"
#include "build/build_config.h"
#include "testing/platform_test.h"
@@ -58,7 +58,7 @@ class CommandLine;
// |command_line| should be as provided by
// |GetMultiProcessTestChildBaseCommandLine()| (below), possibly with arguments
// added. Note: On Windows, you probably want to set |options.start_hidden|.
-ProcessHandle SpawnMultiProcessTestChild(
+Process SpawnMultiProcessTestChild(
const std::string& procname,
const CommandLine& command_line,
const LaunchOptions& options);
@@ -105,14 +105,14 @@ class MultiProcessTest : public PlatformTest {
// // do client work here
// }
//
- // Returns the handle to the child, or NULL on failure
- ProcessHandle SpawnChild(const std::string& procname);
+ // Returns the child process.
+ Process SpawnChild(const std::string& procname);
// Run a child process using the given launch options.
//
// Note: On Windows, you probably want to set |options.start_hidden|.
- ProcessHandle SpawnChildWithOptions(const std::string& procname,
- const LaunchOptions& options);
+ Process SpawnChildWithOptions(const std::string& procname,
+ const LaunchOptions& options);
// Set up the command line used to spawn the child process.
// Override this to add things to the command line (calling this first in the
diff --git a/base/test/multiprocess_test_android.cc b/base/test/multiprocess_test_android.cc
index 8f54b82..dc489d1 100644
--- a/base/test/multiprocess_test_android.cc
+++ b/base/test/multiprocess_test_android.cc
@@ -19,9 +19,9 @@ namespace base {
// and we don't have an executable to exec*. This implementation does the bare
// minimum to execute the method specified by procname (in the child process).
// - All options except |fds_to_remap| are ignored.
-ProcessHandle SpawnMultiProcessTestChild(const std::string& procname,
- const CommandLine& base_command_line,
- const LaunchOptions& options) {
+Process SpawnMultiProcessTestChild(const std::string& procname,
+ const CommandLine& base_command_line,
+ const LaunchOptions& options) {
// TODO(viettrungluu): The FD-remapping done below is wrong in the presence of
// cycles (e.g., fd1 -> fd2, fd2 -> fd1). crbug.com/326576
FileHandleMappingVector empty;
@@ -32,11 +32,11 @@ ProcessHandle SpawnMultiProcessTestChild(const std::string& procname,
if (pid < 0) {
PLOG(ERROR) << "fork";
- return kNullProcessHandle;
+ return Process();
}
if (pid > 0) {
// Parent process.
- return pid;
+ return Process(pid);
}
// Child process.
base::hash_set<int> fds_to_keep_open;
@@ -69,7 +69,7 @@ ProcessHandle SpawnMultiProcessTestChild(const std::string& procname,
command_line->AppendSwitchASCII(switches::kTestChildProcess, procname);
_exit(multi_process_function_list::InvokeChildProcessTest(procname));
- return 0;
+ return Process();
}
} // namespace base
diff --git a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
index fd4be0b..43b855e 100644
--- a/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
+++ b/chrome/browser/printing/cloud_print/test/cloud_print_proxy_process_browsertest.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop.h"
#include "base/process/kill.h"
+#include "base/process/process.h"
#include "base/rand_util.h"
#include "base/synchronization/waitable_event.h"
#include "base/test/multiprocess_test.h"
@@ -308,10 +309,10 @@ class CloudPrintProxyPolicyStartupTest : public base::MultiProcessTest,
scoped_refptr<base::MessageLoopProxy> IOMessageLoopProxy() {
return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
}
- base::ProcessHandle Launch(const std::string& name);
+ base::Process Launch(const std::string& name);
void WaitForConnect();
bool Send(IPC::Message* message);
- void ShutdownAndWaitForExitWithTimeout(base::ProcessHandle handle);
+ void ShutdownAndWaitForExitWithTimeout(base::Process process);
// IPC::Listener implementation
bool OnMessageReceived(const IPC::Message& message) override { return false; }
@@ -430,7 +431,7 @@ void CloudPrintProxyPolicyStartupTest::TearDown() {
TestingBrowserProcess::DeleteInstance();
}
-base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch(
+base::Process CloudPrintProxyPolicyStartupTest::Launch(
const std::string& name) {
EXPECT_FALSE(CheckServiceProcessReady());
@@ -450,12 +451,12 @@ base::ProcessHandle CloudPrintProxyPolicyStartupTest::Launch(
kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor));
base::LaunchOptions options;
options.fds_to_remap = &ipc_file_list;
- base::ProcessHandle handle = SpawnChildWithOptions(name, options);
+ base::Process process = SpawnChildWithOptions(name, options);
#else
- base::ProcessHandle handle = SpawnChild(name);
+ base::Process process = SpawnChild(name);
#endif
- EXPECT_TRUE(handle);
- return handle;
+ EXPECT_TRUE(process.IsValid());
+ return process.Pass();
}
void CloudPrintProxyPolicyStartupTest::WaitForConnect() {
@@ -474,16 +475,14 @@ bool CloudPrintProxyPolicyStartupTest::Send(IPC::Message* message) {
}
void CloudPrintProxyPolicyStartupTest::ShutdownAndWaitForExitWithTimeout(
- base::ProcessHandle handle) {
+ base::Process process) {
ASSERT_TRUE(Send(new ServiceMsg_Shutdown()));
int exit_code = -100;
- bool exited =
- base::WaitForExitCodeWithTimeout(handle, &exit_code,
- TestTimeouts::action_timeout());
+ bool exited = process.WaitForExitWithTimeout(TestTimeouts::action_timeout(),
+ &exit_code);
EXPECT_TRUE(exited);
EXPECT_EQ(exit_code, 0);
- base::CloseProcessHandle(handle);
}
void CloudPrintProxyPolicyStartupTest::OnChannelConnected(int32 peer_pid) {
@@ -511,10 +510,10 @@ TEST_F(CloudPrintProxyPolicyStartupTest, StartAndShutdown) {
// constructed.
chrome::TestingIOThreadState testing_io_thread_state;
- base::ProcessHandle handle =
+ base::Process process =
Launch("CloudPrintMockService_StartEnabledWaitForQuit");
WaitForConnect();
- ShutdownAndWaitForExitWithTimeout(handle);
+ ShutdownAndWaitForExitWithTimeout(process.Pass());
content::RunAllPendingInMessageLoop();
}
@@ -527,7 +526,7 @@ KeyedService* CloudPrintProxyServiceFactoryForPolicyTest(
}
TEST_F(CloudPrintProxyPolicyStartupTest, StartBrowserWithoutPolicy) {
- base::ProcessHandle handle =
+ base::Process process =
Launch("CloudPrintMockService_StartEnabledWaitForQuit");
// Setup the Browser Process with a full IOThread::Globals.
@@ -571,13 +570,13 @@ TEST_F(CloudPrintProxyPolicyStartupTest, StartBrowserWithoutPolicy) {
EXPECT_EQ(MockServiceIPCServer::EnabledUserId(),
prefs->GetString(prefs::kCloudPrintEmail));
- ShutdownAndWaitForExitWithTimeout(handle);
+ ShutdownAndWaitForExitWithTimeout(process.Pass());
content::RunAllPendingInMessageLoop();
profile_manager.DeleteTestingProfile("StartBrowserWithoutPolicy");
}
TEST_F(CloudPrintProxyPolicyStartupTest, StartBrowserWithPolicy) {
- base::ProcessHandle handle =
+ base::Process process =
Launch("CloudPrintMockService_StartEnabledExpectDisabled");
TestingBrowserProcess* browser_process =
@@ -622,7 +621,7 @@ TEST_F(CloudPrintProxyPolicyStartupTest, StartBrowserWithPolicy) {
EXPECT_EQ("", prefs->GetString(prefs::kCloudPrintEmail));
- ShutdownAndWaitForExitWithTimeout(handle);
+ ShutdownAndWaitForExitWithTimeout(process.Pass());
content::RunAllPendingInMessageLoop();
profile_manager.DeleteTestingProfile("StartBrowserWithPolicy");
}
diff --git a/chrome/common/multi_process_lock_unittest.cc b/chrome/common/multi_process_lock_unittest.cc
index 773b66e..9158cec 100644
--- a/chrome/common/multi_process_lock_unittest.cc
+++ b/chrome/common/multi_process_lock_unittest.cc
@@ -51,20 +51,20 @@ std::string MultiProcessLockTest::GenerateLockName() {
void MultiProcessLockTest::ExpectLockIsLocked(const std::string &name) {
ScopedEnvironmentVariable var(kLockEnviromentVarName, name);
- base::ProcessHandle handle = SpawnChild("MultiProcessLockTryFailMain");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("MultiProcessLockTryFailMain");
+ ASSERT_TRUE(process.IsValid());
int exit_code = 0;
- EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
+ EXPECT_TRUE(process.WaitForExit(&exit_code));
EXPECT_EQ(exit_code, 0);
}
void MultiProcessLockTest::ExpectLockIsUnlocked(
const std::string &name) {
ScopedEnvironmentVariable var(kLockEnviromentVarName, name);
- base::ProcessHandle handle = SpawnChild("MultiProcessLockTrySucceedMain");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("MultiProcessLockTrySucceedMain");
+ ASSERT_TRUE(process.IsValid());
int exit_code = 0;
- EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
+ EXPECT_TRUE(process.WaitForExit(&exit_code));
EXPECT_EQ(exit_code, 0);
}
diff --git a/chrome/common/service_process_util_unittest.cc b/chrome/common/service_process_util_unittest.cc
index cfc3d51..9e4ba36 100644
--- a/chrome/common/service_process_util_unittest.cc
+++ b/chrome/common/service_process_util_unittest.cc
@@ -94,10 +94,10 @@ void ServiceProcessStateTest::SetUp() {
}
void ServiceProcessStateTest::LaunchAndWait(const std::string& name) {
- base::ProcessHandle handle = SpawnChild(name);
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild(name);
+ ASSERT_TRUE(process.IsValid());
int exit_code = 0;
- ASSERT_TRUE(base::WaitForExitCode(handle, &exit_code));
+ ASSERT_TRUE(process.WaitForExit(&exit_code));
ASSERT_EQ(exit_code, 0);
}
@@ -187,8 +187,8 @@ TEST_F(ServiceProcessStateTest, DISABLED_SharedMem) {
}
TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) {
- base::ProcessHandle handle = SpawnChild("ServiceProcessStateTestShutdown");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("ServiceProcessStateTestShutdown");
+ ASSERT_TRUE(process.IsValid());
for (int i = 0; !CheckServiceProcessReady() && i < 10; ++i) {
base::PlatformThread::Sleep(TestTimeouts::tiny_timeout());
}
@@ -198,9 +198,8 @@ TEST_F(ServiceProcessStateTest, MAYBE_ForceShutdown) {
ASSERT_TRUE(GetServiceProcessData(&version, &pid));
ASSERT_TRUE(ForceServiceProcessShutdown(version, pid));
int exit_code = 0;
- ASSERT_TRUE(base::WaitForExitCodeWithTimeout(handle,
- &exit_code, TestTimeouts::action_max_timeout()));
- base::CloseProcessHandle(handle);
+ ASSERT_TRUE(process.WaitForExitWithTimeout(TestTimeouts::action_max_timeout(),
+ &exit_code));
ASSERT_EQ(exit_code, 0);
}
diff --git a/components/browser_watcher/exit_code_watcher_win_unittest.cc b/components/browser_watcher/exit_code_watcher_win_unittest.cc
index dc6a0e1..a6da2a5 100644
--- a/components/browser_watcher/exit_code_watcher_win_unittest.cc
+++ b/components/browser_watcher/exit_code_watcher_win_unittest.cc
@@ -50,8 +50,7 @@ class ScopedSleeperProcess {
base::CommandLine cmd_line(base::GetMultiProcessTestChildBaseCommandLine());
base::LaunchOptions options;
options.start_hidden = true;
- process_ = base::Process(
- base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options));
+ process_ = base::SpawnMultiProcessTestChild("Sleeper", cmd_line, options);
ASSERT_TRUE(process_.IsValid());
}
diff --git a/content/common/sandbox_mac_diraccess_unittest.mm b/content/common/sandbox_mac_diraccess_unittest.mm
index 7a3fed8..a403ecd 100644
--- a/content/common/sandbox_mac_diraccess_unittest.mm
+++ b/content/common/sandbox_mac_diraccess_unittest.mm
@@ -34,14 +34,14 @@ class MacDirAccessSandboxTest : public base::MultiProcessTest {
public:
bool CheckSandbox(const std::string& directory_to_try) {
setenv(kSandboxAccessPathKey, directory_to_try.c_str(), 1);
- base::ProcessHandle child_process = SpawnChild("mac_sandbox_path_access");
- if (child_process == base::kNullProcessHandle) {
+ base::Process child_process = SpawnChild("mac_sandbox_path_access");
+ if (!child_process.IsValid()) {
LOG(WARNING) << "SpawnChild failed";
return false;
}
int code = -1;
- if (!base::WaitForExitCode(child_process, &code)) {
- LOG(WARNING) << "base::WaitForExitCode failed";
+ if (!child_process.WaitForExit(&code)) {
+ LOG(WARNING) << "Process::WaitForExit failed";
return false;
}
return code == 0;
diff --git a/content/common/sandbox_mac_unittest_helper.mm b/content/common/sandbox_mac_unittest_helper.mm
index faac7ae..cb029d1 100644
--- a/content/common/sandbox_mac_unittest_helper.mm
+++ b/content/common/sandbox_mac_unittest_helper.mm
@@ -77,14 +77,14 @@ bool MacSandboxTest::RunTestInSandbox(SandboxType sandbox_type,
if (test_data)
setenv(kTestDataKey, test_data, 1);
- base::ProcessHandle child_process = SpawnChild("mac_sandbox_test_runner");
- if (child_process == base::kNullProcessHandle) {
+ base::Process child_process = SpawnChild("mac_sandbox_test_runner");
+ if (!child_process.IsValid()) {
LOG(WARNING) << "SpawnChild failed";
return false;
}
int code = -1;
- if (!base::WaitForExitCode(child_process, &code)) {
- LOG(WARNING) << "base::WaitForExitCode failed";
+ if (!child_process.WaitForExit(&code)) {
+ LOG(WARNING) << "Process::WaitForExit failed";
return false;
}
return code == 0;
diff --git a/ipc/ipc_channel_posix_unittest.cc b/ipc/ipc_channel_posix_unittest.cc
index a01710c..93fc13c 100644
--- a/ipc/ipc_channel_posix_unittest.cc
+++ b/ipc/ipc_channel_posix_unittest.cc
@@ -293,8 +293,8 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) {
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
- base::ProcessHandle handle = SpawnChild("IPCChannelPosixTestConnectionProc");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("IPCChannelPosixTestConnectionProc");
+ ASSERT_TRUE(process.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
@@ -304,7 +304,7 @@ TEST_F(IPCChannelPosixTest, AdvancedConnected) {
channel->Send(message);
SpinRunLoop(TestTimeouts::action_timeout());
int exit_code = 0;
- EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
+ EXPECT_TRUE(process.WaitForExit(&exit_code));
EXPECT_EQ(0, exit_code);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -323,16 +323,16 @@ TEST_F(IPCChannelPosixTest, ResetState) {
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
- base::ProcessHandle handle = SpawnChild("IPCChannelPosixTestConnectionProc");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("IPCChannelPosixTestConnectionProc");
+ ASSERT_TRUE(process.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
channel->ResetToAcceptingConnectionState();
ASSERT_FALSE(channel->HasAcceptedConnection());
- base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixTestConnectionProc");
- ASSERT_TRUE(handle2);
+ base::Process process2 = SpawnChild("IPCChannelPosixTestConnectionProc");
+ ASSERT_TRUE(process2.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
@@ -341,9 +341,9 @@ TEST_F(IPCChannelPosixTest, ResetState) {
IPC::Message::PRIORITY_NORMAL);
channel->Send(message);
SpinRunLoop(TestTimeouts::action_timeout());
- EXPECT_TRUE(base::KillProcess(handle, 0, false));
+ EXPECT_TRUE(base::KillProcess(process.Handle(), 0, false));
int exit_code = 0;
- EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code));
+ EXPECT_TRUE(process2.WaitForExit(&exit_code));
EXPECT_EQ(0, exit_code);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
@@ -383,16 +383,16 @@ TEST_F(IPCChannelPosixTest, MultiConnection) {
ASSERT_TRUE(channel->AcceptsConnections());
ASSERT_FALSE(channel->HasAcceptedConnection());
- base::ProcessHandle handle = SpawnChild("IPCChannelPosixTestConnectionProc");
- ASSERT_TRUE(handle);
+ base::Process process = SpawnChild("IPCChannelPosixTestConnectionProc");
+ ASSERT_TRUE(process.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
- base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixFailConnectionProc");
- ASSERT_TRUE(handle2);
+ base::Process process2 = SpawnChild("IPCChannelPosixFailConnectionProc");
+ ASSERT_TRUE(process2.IsValid());
SpinRunLoop(TestTimeouts::action_max_timeout());
int exit_code = 0;
- EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code));
+ EXPECT_TRUE(process2.WaitForExit(&exit_code));
EXPECT_EQ(exit_code, 0);
ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status());
ASSERT_TRUE(channel->HasAcceptedConnection());
@@ -401,7 +401,7 @@ TEST_F(IPCChannelPosixTest, MultiConnection) {
IPC::Message::PRIORITY_NORMAL);
channel->Send(message);
SpinRunLoop(TestTimeouts::action_timeout());
- EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
+ EXPECT_TRUE(process.WaitForExit(&exit_code));
EXPECT_EQ(exit_code, 0);
ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
ASSERT_FALSE(channel->HasAcceptedConnection());
diff --git a/ipc/ipc_test_base.cc b/ipc/ipc_test_base.cc
index ba4e711..17fce0b 100644
--- a/ipc/ipc_test_base.cc
+++ b/ipc/ipc_test_base.cc
@@ -22,8 +22,7 @@ std::string IPCTestBase::GetChannelName(const std::string& test_client_name) {
return test_client_name + "__Channel";
}
-IPCTestBase::IPCTestBase()
- : client_process_(base::kNullProcessHandle) {
+IPCTestBase::IPCTestBase() {
}
IPCTestBase::~IPCTestBase() {
@@ -104,8 +103,8 @@ std::string IPCTestBase::GetTestMainName() const {
}
bool IPCTestBase::DidStartClient() {
- DCHECK_NE(base::kNullProcessHandle, client_process_);
- return client_process_ != base::kNullProcessHandle;
+ DCHECK(client_process_.IsValid());
+ return client_process_.IsValid();
}
#if defined(OS_POSIX)
@@ -117,7 +116,7 @@ bool IPCTestBase::StartClient() {
}
bool IPCTestBase::StartClientWithFD(int ipcfd) {
- DCHECK_EQ(client_process_, base::kNullProcessHandle);
+ DCHECK(!client_process_.IsValid());
base::FileHandleMappingVector fds_to_map;
if (ipcfd > -1)
@@ -133,7 +132,7 @@ bool IPCTestBase::StartClientWithFD(int ipcfd) {
#elif defined(OS_WIN)
bool IPCTestBase::StartClient() {
- DCHECK_EQ(client_process_, base::kNullProcessHandle);
+ DCHECK(!client_process_.IsValid());
client_process_ = SpawnChild(GetTestMainName());
return DidStartClient();
}
@@ -141,12 +140,11 @@ bool IPCTestBase::StartClient() {
#endif
bool IPCTestBase::WaitForClientShutdown() {
- DCHECK(client_process_ != base::kNullProcessHandle);
+ DCHECK(client_process_.IsValid());
- bool rv = base::WaitForSingleProcess(client_process_,
+ bool rv = base::WaitForSingleProcess(client_process_.Handle(),
base::TimeDelta::FromSeconds(5));
- base::CloseProcessHandle(client_process_);
- client_process_ = base::kNullProcessHandle;
+ client_process_.Close();
return rv;
}
diff --git a/ipc/ipc_test_base.h b/ipc/ipc_test_base.h
index 11f6455..5ed7dd5 100644
--- a/ipc/ipc_test_base.h
+++ b/ipc/ipc_test_base.h
@@ -100,7 +100,7 @@ class IPCTestBase : public base::MultiProcessTest {
IPC::Channel* channel() { return channel_.get(); }
IPC::ChannelProxy* channel_proxy() { return channel_proxy_.get(); }
- const base::ProcessHandle& client_process() const { return client_process_; }
+ const base::Process& client_process() const { return client_process_; }
scoped_refptr<base::TaskRunner> task_runner();
virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
@@ -117,7 +117,7 @@ class IPCTestBase : public base::MultiProcessTest {
scoped_ptr<IPC::Channel> channel_;
scoped_ptr<IPC::ChannelProxy> channel_proxy_;
- base::ProcessHandle client_process_;
+ base::Process client_process_;
DISALLOW_COPY_AND_ASSIGN(IPCTestBase);
};
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 2442afe..47e72fc 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -89,7 +89,7 @@ class IPCChannelMojoTest : public IPCTestBase {
bool DidStartClient() override {
bool ok = IPCTestBase::DidStartClient();
DCHECK(ok);
- host_->OnClientLaunched(client_process());
+ host_->OnClientLaunched(client_process().Handle());
return ok;
}
@@ -195,7 +195,7 @@ class IPCChannelMojoErrorTest : public IPCTestBase {
bool DidStartClient() override {
bool ok = IPCTestBase::DidStartClient();
DCHECK(ok);
- host_->OnClientLaunched(client_process());
+ host_->OnClientLaunched(client_process().Handle());
return ok;
}
@@ -269,10 +269,11 @@ class IPCChannelMojoDeadHandleTest : public IPCTestBase {
virtual bool DidStartClient() override {
IPCTestBase::DidStartClient();
- base::ProcessHandle client = client_process();
+ const base::ProcessHandle client = client_process().Handle();
// Forces GetFileHandleForProcess() fail. It happens occasionally
// in production, so we should exercise it somehow.
- ::CloseHandle(client);
+ // TODO(morrita): figure out how to safely test this.
+ // ::CloseHandle(client);
host_->OnClientLaunched(client);
return true;
}
diff --git a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
index a071d66..fbe0fa8 100644
--- a/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
+++ b/ipc/mojo/ipc_mojo_bootstrap_unittest.cc
@@ -55,7 +55,7 @@ TEST_F(IPCMojoBootstrapTest, Connect) {
#else
ASSERT_TRUE(StartClient());
#endif
- bootstrap->OnClientLaunched(client_process());
+ bootstrap->OnClientLaunched(client_process().Handle());
base::MessageLoop::current()->Run();
diff --git a/ipc/mojo/ipc_mojo_perftest.cc b/ipc/mojo/ipc_mojo_perftest.cc
index 29e7839..8bdac8c9 100644
--- a/ipc/mojo/ipc_mojo_perftest.cc
+++ b/ipc/mojo/ipc_mojo_perftest.cc
@@ -40,7 +40,7 @@ public:
bool DidStartClient() override {
bool ok = IPCTestBase::DidStartClient();
DCHECK(ok);
- host_->OnClientLaunched(client_process());
+ host_->OnClientLaunched(client_process().Handle());
return ok;
}
diff --git a/ipc/sync_socket_unittest.cc b/ipc/sync_socket_unittest.cc
index 77ae72d..238f2a8 100644
--- a/ipc/sync_socket_unittest.cc
+++ b/ipc/sync_socket_unittest.cc
@@ -184,7 +184,7 @@ TEST_F(SyncSocketTest, SanityTest) {
#if defined(OS_WIN)
// On windows we need to duplicate the handle into the server process.
BOOL retval = DuplicateHandle(GetCurrentProcess(), pair[1].handle(),
- client_process(), &target_handle,
+ client_process().Handle(), &target_handle,
0, FALSE, DUPLICATE_SAME_ACCESS);
EXPECT_TRUE(retval);
// Set up a message to pass the handle to the server.
diff --git a/mojo/edk/test/multiprocess_test_helper.cc b/mojo/edk/test/multiprocess_test_helper.cc
index 758520a..7f44d82 100644
--- a/mojo/edk/test/multiprocess_test_helper.cc
+++ b/mojo/edk/test/multiprocess_test_helper.cc
@@ -14,14 +14,13 @@
namespace mojo {
namespace test {
-MultiprocessTestHelper::MultiprocessTestHelper()
- : test_child_handle_(base::kNullProcessHandle) {
+MultiprocessTestHelper::MultiprocessTestHelper() {
platform_channel_pair_.reset(new embedder::PlatformChannelPair());
server_platform_handle = platform_channel_pair_->PassServerHandle();
}
MultiprocessTestHelper::~MultiprocessTestHelper() {
- CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
+ CHECK(!test_child_.IsValid());
server_platform_handle.reset();
platform_channel_pair_.reset();
}
@@ -29,7 +28,7 @@ MultiprocessTestHelper::~MultiprocessTestHelper() {
void MultiprocessTestHelper::StartChild(const std::string& test_child_name) {
CHECK(platform_channel_pair_);
CHECK(!test_child_name.empty());
- CHECK_EQ(test_child_handle_, base::kNullProcessHandle);
+ CHECK(!test_child_.IsValid());
std::string test_child_main = test_child_name + "TestChildMain";
@@ -49,21 +48,20 @@ void MultiprocessTestHelper::StartChild(const std::string& test_child_name) {
#error "Not supported yet."
#endif
- test_child_handle_ =
+ test_child_ =
base::SpawnMultiProcessTestChild(test_child_main, command_line, options);
platform_channel_pair_->ChildProcessLaunched();
- CHECK_NE(test_child_handle_, base::kNullProcessHandle);
+ CHECK(test_child_.IsValid());
}
int MultiprocessTestHelper::WaitForChildShutdown() {
- CHECK_NE(test_child_handle_, base::kNullProcessHandle);
+ CHECK(test_child_.IsValid());
int rv = -1;
- CHECK(base::WaitForExitCodeWithTimeout(test_child_handle_, &rv,
- TestTimeouts::action_timeout()));
- base::CloseProcessHandle(test_child_handle_);
- test_child_handle_ = base::kNullProcessHandle;
+ CHECK(test_child_.WaitForExitWithTimeout(TestTimeouts::action_timeout(),
+ &rv));
+ test_child_.Close();
return rv;
}
diff --git a/mojo/edk/test/multiprocess_test_helper.h b/mojo/edk/test/multiprocess_test_helper.h
index d131460..e40b309c 100644
--- a/mojo/edk/test/multiprocess_test_helper.h
+++ b/mojo/edk/test/multiprocess_test_helper.h
@@ -8,7 +8,7 @@
#include <string>
#include "base/macros.h"
-#include "base/process/process_handle.h"
+#include "base/process/process.h"
#include "base/test/multiprocess_test.h"
#include "base/test/test_timeouts.h"
#include "mojo/edk/embedder/scoped_platform_handle.h"
@@ -58,7 +58,7 @@ class MultiprocessTestHelper {
scoped_ptr<embedder::PlatformChannelPair> platform_channel_pair_;
// Valid after |StartChild()| and before |WaitForChildShutdown()|.
- base::ProcessHandle test_child_handle_;
+ base::Process test_child_;
DISALLOW_COPY_AND_ASSIGN(MultiprocessTestHelper);
};
diff --git a/sandbox/mac/bootstrap_sandbox_unittest.mm b/sandbox/mac/bootstrap_sandbox_unittest.mm
index d9d02c7..bd788bd 100644
--- a/sandbox/mac/bootstrap_sandbox_unittest.mm
+++ b/sandbox/mac/bootstrap_sandbox_unittest.mm
@@ -100,14 +100,14 @@ class BootstrapSandboxTest : public base::MultiProcessTest {
sandbox_->PrepareToForkWithPolicy(policy_id);
base::LaunchOptions options;
options.replacement_bootstrap_name = sandbox_->server_bootstrap_name();
- base::ProcessHandle pid = SpawnChildWithOptions(child_name, options);
- ASSERT_GT(pid, 0);
- sandbox_->FinishedFork(pid);
+ base::Process process = SpawnChildWithOptions(child_name, options);
+ ASSERT_TRUE(process.IsValid());
+ sandbox_->FinishedFork(process.Handle());
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
if (out_pid)
- *out_pid = pid;
+ *out_pid = process.pid();
}
protected:
@@ -121,15 +121,15 @@ TEST_F(BootstrapSandboxTest, DistributedNotifications_Unsandboxed) {
base::scoped_nsobject<DistributedNotificationObserver> observer(
[[DistributedNotificationObserver alloc] init]);
- base::ProcessHandle pid = SpawnChild(kNotificationTestMain);
- ASSERT_GT(pid, 0);
+ base::Process process = SpawnChild(kNotificationTestMain);
+ ASSERT_TRUE(process.IsValid());
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
[observer waitForNotification];
EXPECT_EQ(1, [observer receivedCount]);
- EXPECT_EQ(pid, [[observer object] intValue]);
+ EXPECT_EQ(process.pid(), [[observer object] intValue]);
}
// Run the test with the sandbox enabled without notifications on the policy
@@ -439,10 +439,9 @@ TEST_F(BootstrapSandboxTest, ChildOutliveSandbox) {
sandbox_->PrepareToForkWithPolicy(kTestPolicyId);
base::LaunchOptions options;
options.replacement_bootstrap_name = sandbox_->server_bootstrap_name();
- base::ProcessHandle pid =
- SpawnChildWithOptions("ChildOutliveSandbox", options);
- ASSERT_GT(pid, 0);
- sandbox_->FinishedFork(pid);
+ base::Process process = SpawnChildWithOptions("ChildOutliveSandbox", options);
+ ASSERT_TRUE(process.IsValid());
+ sandbox_->FinishedFork(process.Handle());
// Synchronize with the child.
mach_msg_empty_rcv_t rcv_msg;
@@ -468,7 +467,7 @@ TEST_F(BootstrapSandboxTest, ChildOutliveSandbox) {
EXPECT_EQ(KERN_SUCCESS, kr) << mach_error_string(kr);
int code = 0;
- EXPECT_TRUE(base::WaitForExitCode(pid, &code));
+ EXPECT_TRUE(process.WaitForExit(&code));
EXPECT_EQ(0, code);
}
diff --git a/sandbox/mac/xpc_message_server_unittest.cc b/sandbox/mac/xpc_message_server_unittest.cc
index 2632a6e..b9f90562 100644
--- a/sandbox/mac/xpc_message_server_unittest.cc
+++ b/sandbox/mac/xpc_message_server_unittest.cc
@@ -149,21 +149,19 @@ XPC_TEST_F(GetSenderPID) // {
#pragma GCC diagnostic pop
ASSERT_EQ(KERN_SUCCESS, kr);
- base::ProcessHandle child_handle = base::SpawnMultiProcessTestChild(
+ base::Process child = base::SpawnMultiProcessTestChild(
"GetSenderPID",
base::GetMultiProcessTestChildBaseCommandLine(),
base::LaunchOptions());
- ASSERT_NE(base::kNullProcessHandle, child_handle);
+ ASSERT_TRUE(child.IsValid());
int exit_code = -1;
- ASSERT_TRUE(base::WaitForExitCode(child_handle, &exit_code));
+ ASSERT_TRUE(child.WaitForExit(&exit_code));
EXPECT_EQ(0, exit_code);
- EXPECT_EQ(base::GetProcId(child_handle), sender_pid);
- EXPECT_EQ(base::GetProcId(child_handle), child_pid);
+ EXPECT_EQ(child.pid(), sender_pid);
+ EXPECT_EQ(child.pid(), child_pid);
EXPECT_EQ(sender_pid, child_pid);
-
- base::CloseProcessHandle(child_handle);
}
MULTIPROCESS_TEST_MAIN(GetSenderPID) {