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

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

Issue 775343004: Move //mojo/shell to //shell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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 MOJO_SHELL_CHILD_PROCESS_HOST_H_
6 #define MOJO_SHELL_CHILD_PROCESS_HOST_H_
7
8 #include "base/macros.h"
9 #include "base/process/process_handle.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. Intended for use as a base class, but may be used on its own in
22 // simple cases.
23 //
24 // This class is not thread-safe. It should be created/used/destroyed on a
25 // single thread.
26 //
27 // Note: Does not currently work on Windows before Vista.
28 class ChildProcessHost {
29 public:
30 class Delegate {
31 public:
32 virtual void WillStart() = 0;
33 virtual void DidStart(bool success) = 0;
34 };
35
36 ChildProcessHost(Context* context,
37 Delegate* delegate,
38 ChildProcess::Type type);
39 virtual ~ChildProcessHost();
40
41 // |Start()|s the child process; calls the delegate's |DidStart()| (on the
42 // thread on which |Start()| was called) when the child has been started (or
43 // failed to start). After calling |Start()|, this object must not be
44 // destroyed until |DidStart()| has been called.
45 // TODO(vtl): Consider using weak pointers and removing this requirement.
46 void Start();
47
48 // Waits for the child process to terminate, and returns its exit code.
49 // Note: If |Start()| has been called, this must not be called until the
50 // callback has been called.
51 int Join();
52
53 embedder::ScopedPlatformHandle* platform_channel() {
54 return &platform_channel_;
55 }
56
57 protected:
58 Context* context() const {
59 return context_;
60 }
61
62 private:
63 bool DoLaunch();
64 void DidLaunch(bool success);
65
66 Context* const context_;
67 Delegate* const delegate_;
68 const ChildProcess::Type type_;
69
70 base::ProcessHandle child_process_handle_;
71
72 embedder::PlatformChannelPair platform_channel_pair_;
73
74 // Platform-specific "pipe" to the child process. Valid immediately after
75 // creation.
76 embedder::ScopedPlatformHandle platform_channel_;
77
78 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
79 };
80
81 } // namespace shell
82 } // namespace mojo
83
84 #endif // MOJO_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