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

Side by Side Diff: services/service_manager/tests/util.cc

Issue 2617883002: Add a new BindInterface() method to Connector. (Closed)
Patch Set: . Created 3 years, 11 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 unified diff | Download patch
OLDNEW
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 "services/service_manager/tests/util.h" 5 #include "services/service_manager/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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // Allocate the pipe locally. 67 // Allocate the pipe locally.
68 std::string child_token = mojo::edk::GenerateRandomToken(); 68 std::string child_token = mojo::edk::GenerateRandomToken();
69 mojo::ScopedMessagePipeHandle pipe = 69 mojo::ScopedMessagePipeHandle pipe =
70 mojo::edk::CreateParentMessagePipe(primordial_pipe_token, child_token); 70 mojo::edk::CreateParentMessagePipe(primordial_pipe_token, child_token);
71 71
72 service_manager::mojom::ServicePtr client; 72 service_manager::mojom::ServicePtr client;
73 client.Bind(mojo::InterfacePtrInfo<service_manager::mojom::Service>( 73 client.Bind(mojo::InterfacePtrInfo<service_manager::mojom::Service>(
74 std::move(pipe), 0u)); 74 std::move(pipe), 0u));
75 service_manager::mojom::PIDReceiverPtr receiver; 75 service_manager::mojom::PIDReceiverPtr receiver;
76 76
77 connector->Start(target, std::move(client), MakeRequest(&receiver)); 77 connector->StartService(target, std::move(client), MakeRequest(&receiver));
78 std::unique_ptr<service_manager::Connection> connection = 78 std::unique_ptr<service_manager::Connection> connection =
79 connector->Connect(target); 79 connector->Connect(target);
80 { 80 {
81 base::RunLoop loop; 81 base::RunLoop loop;
82 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop)); 82 connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop));
83 base::MessageLoop::ScopedNestableTaskAllower allow( 83 base::MessageLoop::ScopedNestableTaskAllower allow(
84 base::MessageLoop::current()); 84 base::MessageLoop::current());
85 loop.Run(); 85 loop.Run();
86 } 86 }
87 87
88 base::LaunchOptions options; 88 base::LaunchOptions options;
89 #if defined(OS_WIN) 89 #if defined(OS_WIN)
90 options.handles_to_inherit = &handle_passing_info; 90 options.handles_to_inherit = &handle_passing_info;
91 #elif defined(OS_POSIX) 91 #elif defined(OS_POSIX)
92 options.fds_to_remap = &handle_passing_info; 92 options.fds_to_remap = &handle_passing_info;
93 #endif 93 #endif
94 *process = base::LaunchProcess(child_command_line, options); 94 *process = base::LaunchProcess(child_command_line, options);
95 DCHECK(process->IsValid()); 95 DCHECK(process->IsValid());
96 receiver->SetPID(process->Pid()); 96 receiver->SetPID(process->Pid());
97 mojo::edk::ChildProcessLaunched(process->Handle(), 97 mojo::edk::ChildProcessLaunched(process->Handle(),
98 platform_channel_pair.PassServerHandle(), 98 platform_channel_pair.PassServerHandle(),
99 child_token); 99 child_token);
100 return connection; 100 return connection;
101 } 101 }
102 102
103 } // namespace test 103 } // namespace test
104 } // namespace service_manager 104 } // namespace service_manager
OLDNEW
« no previous file with comments | « services/service_manager/tests/shutdown/shutdown_unittest.cc ('k') | services/tracing/public/cpp/provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698