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

Side by Side Diff: chrome/test/base/mojo_test_connector.cc

Issue 2610173003: Add RegisterService, split out of Connect(). (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
« no previous file with comments | « no previous file | content/browser/browser_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/test/base/mojo_test_connector.h" 5 #include "chrome/test/base/mojo_test_connector.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 child_token_); 67 child_token_);
68 68
69 std::unique_ptr<service_manager::ConnectParams> params( 69 std::unique_ptr<service_manager::ConnectParams> params(
70 new service_manager::ConnectParams); 70 new service_manager::ConnectParams);
71 params->set_source(service_manager::CreateServiceManagerIdentity()); 71 params->set_source(service_manager::CreateServiceManagerIdentity());
72 // Use the default instance name (which should be "browser"). Otherwise a 72 // Use the default instance name (which should be "browser"). Otherwise a
73 // service (e.g. ash) that connects to the default "content_browser" 73 // service (e.g. ash) that connects to the default "content_browser"
74 // will spawn a new instance. 74 // will spawn a new instance.
75 params->set_target(service_manager::Identity( 75 params->set_target(service_manager::Identity(
76 kTestName, service_manager::mojom::kRootUserID)); 76 kTestName, service_manager::mojom::kRootUserID));
77 77 params->set_client_process_info(std::move(service),
78 service_manager::mojom::ClientProcessConnectionPtr 78 MakeRequest(&pid_receiver_));
79 client_process_connection =
80 service_manager::mojom::ClientProcessConnection::New();
81 client_process_connection->service =
82 service.PassInterface().PassHandle();
83 client_process_connection->pid_receiver_request =
84 mojo::MakeRequest(&pid_receiver_).PassMessagePipe();
85 params->set_client_process_connection(std::move(client_process_connection));
86 service_manager->Connect(std::move(params)); 79 service_manager->Connect(std::move(params));
87 } 80 }
88 81
89 // Called after the test process has launched. Completes the registration done 82 // Called after the test process has launched. Completes the registration done
90 // in Connect(). 83 // in Connect().
91 void ChildProcessLaunched(base::ProcessHandle handle, base::ProcessId pid) { 84 void ChildProcessLaunched(base::ProcessHandle handle, base::ProcessId pid) {
92 pid_receiver_->SetPID(pid); 85 pid_receiver_->SetPID(pid);
93 mojo_ipc_channel_->ChildProcessLaunched(); 86 mojo_ipc_channel_->ChildProcessLaunched();
94 mojo::edk::ChildProcessLaunched( 87 mojo::edk::ChildProcessLaunched(
95 handle, mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle( 88 handle, mojo::edk::ScopedPlatformHandle(mojo::edk::PlatformHandle(
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 MojoTestConnector::~MojoTestConnector() {} 253 MojoTestConnector::~MojoTestConnector() {}
261 254
262 std::unique_ptr<content::TestState> MojoTestConnector::PrepareForTest( 255 std::unique_ptr<content::TestState> MojoTestConnector::PrepareForTest(
263 base::CommandLine* command_line, 256 base::CommandLine* command_line,
264 base::TestLauncher::LaunchOptions* test_launch_options) { 257 base::TestLauncher::LaunchOptions* test_launch_options) {
265 std::unique_ptr<MojoTestState> test_state( 258 std::unique_ptr<MojoTestState> test_state(
266 new MojoTestState(&background_service_manager_)); 259 new MojoTestState(&background_service_manager_));
267 test_state->Init(command_line, test_launch_options); 260 test_state->Init(command_line, test_launch_options);
268 return std::move(test_state); 261 return std::move(test_state);
269 } 262 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698