OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/shell/tests/util.h" | 5 #include "mojo/shell/tests/util.h" |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Generate a token for the child to find and connect to a primordial pipe | 59 // Generate a token for the child to find and connect to a primordial pipe |
60 // and pass that as well. | 60 // and pass that as well. |
61 std::string primordial_pipe_token = mojo::edk::GenerateRandomToken(); | 61 std::string primordial_pipe_token = mojo::edk::GenerateRandomToken(); |
62 child_command_line.AppendSwitchASCII(switches::kPrimordialPipeToken, | 62 child_command_line.AppendSwitchASCII(switches::kPrimordialPipeToken, |
63 primordial_pipe_token); | 63 primordial_pipe_token); |
64 | 64 |
65 // Allocate the pipe locally. | 65 // Allocate the pipe locally. |
66 mojo::ScopedMessagePipeHandle pipe = | 66 mojo::ScopedMessagePipeHandle pipe = |
67 mojo::edk::CreateParentMessagePipe(primordial_pipe_token); | 67 mojo::edk::CreateParentMessagePipe(primordial_pipe_token); |
68 | 68 |
69 mojo::shell::mojom::ShellClientFactoryPtr factory; | 69 mojo::shell::mojom::ShellClientPtr client; |
70 factory.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClientFactory>( | 70 client.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClient>( |
71 std::move(pipe), 0u)); | 71 std::move(pipe), 0u)); |
72 mojo::shell::mojom::PIDReceiverPtr receiver; | 72 mojo::shell::mojom::PIDReceiverPtr receiver; |
73 | 73 |
74 mojo::Connector::ConnectParams params(target); | 74 mojo::Connector::ConnectParams params(target); |
75 params.set_client_process_connection(std::move(factory), GetProxy(&receiver)); | 75 params.set_client_process_connection(std::move(client), GetProxy(&receiver)); |
76 scoped_ptr<mojo::Connection> connection = connector->Connect(¶ms); | 76 scoped_ptr<mojo::Connection> connection = connector->Connect(¶ms); |
77 { | 77 { |
78 base::RunLoop loop; | 78 base::RunLoop loop; |
79 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); | 79 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); |
80 base::MessageLoop::ScopedNestableTaskAllower allow( | 80 base::MessageLoop::ScopedNestableTaskAllower allow( |
81 base::MessageLoop::current()); | 81 base::MessageLoop::current()); |
82 loop.Run(); | 82 loop.Run(); |
83 } | 83 } |
84 | 84 |
85 base::LaunchOptions options; | 85 base::LaunchOptions options; |
86 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
87 options.handles_to_inherit = &handle_passing_info; | 87 options.handles_to_inherit = &handle_passing_info; |
88 #elif defined(OS_POSIX) | 88 #elif defined(OS_POSIX) |
89 options.fds_to_remap = &handle_passing_info; | 89 options.fds_to_remap = &handle_passing_info; |
90 #endif | 90 #endif |
91 *process = base::LaunchProcess(child_command_line, options); | 91 *process = base::LaunchProcess(child_command_line, options); |
92 DCHECK(process->IsValid()); | 92 DCHECK(process->IsValid()); |
93 receiver->SetPID(process->Pid()); | 93 receiver->SetPID(process->Pid()); |
94 mojo::edk::ChildProcessLaunched(process->Handle(), | 94 mojo::edk::ChildProcessLaunched(process->Handle(), |
95 platform_channel_pair.PassServerHandle()); | 95 platform_channel_pair.PassServerHandle()); |
96 return connection; | 96 return connection; |
97 } | 97 } |
98 | 98 |
99 } // namespace test | 99 } // namespace test |
100 } // namespace shell | 100 } // namespace shell |
101 } // namespace mojo | 101 } // namespace mojo |
OLD | NEW |