| Index: mojo/shell/runner/common/client_util.cc
|
| diff --git a/mojo/shell/runner/common/client_util.cc b/mojo/shell/runner/common/client_util.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..2c264bd27812cce7a4a27f3ce2a91f20e6c46a4a
|
| --- /dev/null
|
| +++ b/mojo/shell/runner/common/client_util.cc
|
| @@ -0,0 +1,38 @@
|
| +// 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/runner/common/client_util.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/command_line.h"
|
| +#include "mojo/edk/embedder/embedder.h"
|
| +#include "mojo/shell/runner/common/switches.h"
|
| +
|
| +namespace mojo {
|
| +namespace shell {
|
| +
|
| +mojom::ShellClientPtr PassShellClientRequestOnCommandLine(
|
| + base::CommandLine* command_line) {
|
| + std::string token = edk::GenerateRandomToken();
|
| + command_line->AppendSwitchASCII(switches::kPrimordialPipeToken, token);
|
| +
|
| + mojom::ShellClientPtr client;
|
| + client.Bind(
|
| + mojom::ShellClientPtrInfo(edk::CreateParentMessagePipe(token), 0));
|
| + return client;
|
| +}
|
| +
|
| +mojom::ShellClientRequest GetShellClientRequestFromCommandLine() {
|
| + std::string token =
|
| + base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
|
| + switches::kPrimordialPipeToken);
|
| + mojom::ShellClientRequest request;
|
| + if (!token.empty())
|
| + request.Bind(edk::CreateChildMessagePipe(token));
|
| + return request;
|
| +}
|
| +
|
| +} // namespace shell
|
| +} // namespace mojo
|
|
|