diff options
author | rockot <rockot@chromium.org> | 2016-03-14 16:38:28 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-14 23:40:38 +0000 |
commit | d5669c5cce5e182f29a4387807cda0c74e8265eb (patch) | |
tree | 40ca09f1547e7ec5e5afbb193854cdd27d52b1b3 /mojo/shell/runner/common/client_util.cc | |
parent | 1afe4c3c566b3270b346c86f7698086e85b93730 (diff) | |
download | chromium_src-d5669c5cce5e182f29a4387807cda0c74e8265eb.zip chromium_src-d5669c5cce5e182f29a4387807cda0c74e8265eb.tar.gz chromium_src-d5669c5cce5e182f29a4387807cda0c74e8265eb.tar.bz2 |
Change primordial pipes to ShellClient
Changes shell client startup pipes to be ShellClient instead
of ShellClientFactory. This simplifies a lot of startup code.
Due to this change, apps must now take responsibility for
shutting themselves down when they feel it's appropriate. For
now, all relevant apps are force-exited to mimic the old
behavior.
Once apptests are deleted, we should expose a clean quit
closure to apps so they have something to run when they want
to quit. Hard-exiting the process is definitely not the right
thing to do.
BUG=
Review URL: https://codereview.chromium.org/1801963002
Cr-Commit-Position: refs/heads/master@{#381114}
Diffstat (limited to 'mojo/shell/runner/common/client_util.cc')
-rw-r--r-- | mojo/shell/runner/common/client_util.cc | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/mojo/shell/runner/common/client_util.cc b/mojo/shell/runner/common/client_util.cc new file mode 100644 index 0000000..2c264bd --- /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 |