Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1220)

Unified Diff: mojo/edk/test/multiprocess_test_helper.cc

Issue 2766763002: Fix DCHECK in ipc_perftests (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/test/multiprocess_test_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/test/multiprocess_test_helper.cc
diff --git a/mojo/edk/test/multiprocess_test_helper.cc b/mojo/edk/test/multiprocess_test_helper.cc
index 4bc550f505e2424f62229ace819c41d4dd4932e8..cf377827f577edc08f2c210a1e859bc27f610a9e 100644
--- a/mojo/edk/test/multiprocess_test_helper.cc
+++ b/mojo/edk/test/multiprocess_test_helper.cc
@@ -46,11 +46,13 @@ const char kMojoPrimordialPipeToken[] = "mojo-primordial-pipe-token";
const char kMojoNamedPipeName[] = "mojo-named-pipe-name";
template <typename Func>
-int RunClientFunction(Func handler) {
+int RunClientFunction(Func handler, bool pass_pipe_ownership_to_main) {
CHECK(MultiprocessTestHelper::primordial_pipe.is_valid());
ScopedMessagePipeHandle pipe =
std::move(MultiprocessTestHelper::primordial_pipe);
- return handler(pipe.get().value());
+ MessagePipeHandle pipe_handle =
+ pass_pipe_ownership_to_main ? pipe.release() : pipe.get();
+ return handler(pipe_handle.value());
}
} // namespace
@@ -232,20 +234,25 @@ void MultiprocessTestHelper::ChildSetup() {
// static
int MultiprocessTestHelper::RunClientMain(
- const base::Callback<int(MojoHandle)>& main) {
- return RunClientFunction([main](MojoHandle handle){
- return main.Run(handle);
- });
+ const base::Callback<int(MojoHandle)>& main,
+ bool pass_pipe_ownership_to_main) {
+ return RunClientFunction(
+ [main](MojoHandle handle) { return main.Run(handle); },
+ pass_pipe_ownership_to_main);
}
// static
int MultiprocessTestHelper::RunClientTestMain(
const base::Callback<void(MojoHandle)>& main) {
- return RunClientFunction([main](MojoHandle handle) {
- main.Run(handle);
- return (::testing::Test::HasFatalFailure() ||
- ::testing::Test::HasNonfatalFailure()) ? 1 : 0;
- });
+ return RunClientFunction(
+ [main](MojoHandle handle) {
+ main.Run(handle);
+ return (::testing::Test::HasFatalFailure() ||
+ ::testing::Test::HasNonfatalFailure())
+ ? 1
+ : 0;
+ },
+ true /* close_pipe_on_exit */);
}
// static
« no previous file with comments | « mojo/edk/test/multiprocess_test_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698