blob: 2c264bd27812cce7a4a27f3ce2a91f20e6c46a4a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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
|