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

Side by Side Diff: mojo/shell/child_process_host.h

Issue 1049993002: Get mojo_shell building inside chromium checkout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix presubmit Created 5 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 unified diff | Download patch
« no previous file with comments | « mojo/shell/child_process.cc ('k') | mojo/shell/child_process_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef SHELL_CHILD_PROCESS_HOST_H_
6 #define SHELL_CHILD_PROCESS_HOST_H_
7
8 #include "base/macros.h"
9 #include "base/process/process.h"
10 #include "mojo/edk/embedder/platform_channel_pair.h"
11 #include "mojo/edk/embedder/scoped_platform_handle.h"
12 #include "mojo/shell/child_process.h" // For |ChildProcess::Type|.
13
14 namespace mojo {
15 namespace shell {
16
17 class Context;
18
19 // (Base) class for a "child process host". Handles launching and connecting a
20 // platform-specific "pipe" to the child, and supports joining the child
21 // process.
22 //
23 // This class is not thread-safe. It should be created/used/destroyed on a
24 // single thread.
25 //
26 // Note: Does not currently work on Windows before Vista.
27 class ChildProcessHost {
28 public:
29 explicit ChildProcessHost(Context* context);
30 virtual ~ChildProcessHost();
31
32 // |Start()|s the child process; calls |DidStart()| (on the thread on which
33 // |Start()| was called) when the child has been started (or failed to start).
34 // After calling |Start()|, this object must not be destroyed until
35 // |DidStart()| has been called.
36 // TODO(vtl): Consider using weak pointers and removing this requirement.
37 void Start();
38
39 // Waits for the child process to terminate, and returns its exit code.
40 // Note: If |Start()| has been called, this must not be called until the
41 // callback has been called.
42 int Join();
43
44 embedder::ScopedPlatformHandle* platform_channel() {
45 return &platform_channel_;
46 }
47
48 virtual void WillStart() = 0;
49 virtual void DidStart(bool success) = 0;
50
51 protected:
52 Context* context() const { return context_; }
53
54 private:
55 bool DoLaunch();
56
57 Context* const context_;
58
59 base::Process child_process_;
60
61 embedder::PlatformChannelPair platform_channel_pair_;
62
63 // Platform-specific "pipe" to the child process. Valid immediately after
64 // creation.
65 embedder::ScopedPlatformHandle platform_channel_;
66
67 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
68 };
69
70 } // namespace shell
71 } // namespace mojo
72
73 #endif // SHELL_CHILD_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « mojo/shell/child_process.cc ('k') | mojo/shell/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698