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

Unified Diff: mojo/shell/tests/util.cc

Issue 1877753003: Move mojo\shell to services\shell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@62scan
Patch Set: . Created 4 years, 8 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/shell/tests/util.h ('k') | services/shell/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/shell/tests/util.cc
diff --git a/mojo/shell/tests/util.cc b/mojo/shell/tests/util.cc
deleted file mode 100644
index 8326ebe3ab17682583ec50b303953022851f4bdf..0000000000000000000000000000000000000000
--- a/mojo/shell/tests/util.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "mojo/shell/tests/util.h"
-
-#include "base/base_paths.h"
-#include "base/base_switches.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/files/file_path.h"
-#include "base/macros.h"
-#include "base/message_loop/message_loop.h"
-#include "base/path_service.h"
-#include "base/process/process.h"
-#include "base/run_loop.h"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/platform_channel_pair.h"
-#include "mojo/edk/embedder/scoped_platform_handle.h"
-#include "mojo/shell/public/cpp/connection.h"
-#include "mojo/shell/public/cpp/connector.h"
-#include "mojo/shell/public/interfaces/connector.mojom.h"
-#include "mojo/shell/public/interfaces/shell_client_factory.mojom.h"
-#include "mojo/shell/runner/common/switches.h"
-
-namespace mojo {
-namespace shell {
-namespace test {
-namespace {
-void QuitLoop(base::RunLoop* loop) {
- loop->Quit();
-}
-} // namespace
-
-scoped_ptr<Connection> LaunchAndConnectToProcess(
- const std::string& target_exe_name,
- const Identity target,
- mojo::Connector* connector,
- base::Process* process) {
- base::FilePath target_path;
- CHECK(base::PathService::Get(base::DIR_EXE, &target_path));
- target_path = target_path.AppendASCII(target_exe_name);
-
- base::CommandLine child_command_line(target_path);
- // Forward the wait-for-debugger flag but nothing else - we don't want to
- // stamp on the platform-channel flag.
- if (base::CommandLine::ForCurrentProcess()->HasSwitch(
- switches::kWaitForDebugger)) {
- child_command_line.AppendSwitch(switches::kWaitForDebugger);
- }
-
- // Create the channel to be shared with the target process. Pass one end
- // on the command line.
- mojo::edk::PlatformChannelPair platform_channel_pair;
- mojo::edk::HandlePassingInformation handle_passing_info;
- platform_channel_pair.PrepareToPassClientHandleToChildProcess(
- &child_command_line, &handle_passing_info);
-
- // Generate a token for the child to find and connect to a primordial pipe
- // and pass that as well.
- std::string primordial_pipe_token = mojo::edk::GenerateRandomToken();
- child_command_line.AppendSwitchASCII(switches::kPrimordialPipeToken,
- primordial_pipe_token);
-
- // Allocate the pipe locally.
- mojo::ScopedMessagePipeHandle pipe =
- mojo::edk::CreateParentMessagePipe(primordial_pipe_token);
-
- mojo::shell::mojom::ShellClientPtr client;
- client.Bind(mojo::InterfacePtrInfo<mojo::shell::mojom::ShellClient>(
- std::move(pipe), 0u));
- mojo::shell::mojom::PIDReceiverPtr receiver;
-
- mojo::Connector::ConnectParams params(target);
- params.set_client_process_connection(std::move(client), GetProxy(&receiver));
- scoped_ptr<mojo::Connection> connection = connector->Connect(&params);
- {
- base::RunLoop loop;
- connection->AddConnectionCompletedClosure(base::Bind(&QuitLoop, &loop));
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
- loop.Run();
- }
-
- base::LaunchOptions options;
-#if defined(OS_WIN)
- options.handles_to_inherit = &handle_passing_info;
-#elif defined(OS_POSIX)
- options.fds_to_remap = &handle_passing_info;
-#endif
- *process = base::LaunchProcess(child_command_line, options);
- DCHECK(process->IsValid());
- receiver->SetPID(process->Pid());
- mojo::edk::ChildProcessLaunched(process->Handle(),
- platform_channel_pair.PassServerHandle());
- return connection;
-}
-
-} // namespace test
-} // namespace shell
-} // namespace mojo
« no previous file with comments | « mojo/shell/tests/util.h ('k') | services/shell/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698