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

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

Issue 1091513005: Separate mojo/shell into a runner and the application manager (shell) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 7 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.mojom ('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/channel_info_forward.h"
11 #include "mojo/edk/embedder/platform_channel_pair.h"
12 #include "mojo/edk/embedder/scoped_platform_handle.h"
13 #include "mojo/shell/child_process.mojom.h"
14 #include "mojo/shell/child_process_host.h"
15
16 namespace mojo {
17 namespace shell {
18
19 class Context;
20
21 // This class represents a "child process host". Handles launching and
22 // connecting a platform-specific "pipe" to the child, and supports joining the
23 // child process. Currently runs a single app (loaded from the file system).
24 //
25 // This class is not thread-safe. It should be created/used/destroyed on a
26 // single thread.
27 //
28 // Note: Does not currently work on Windows before Vista.
29 // Note: After |Start()|, |StartApp| must be called and this object must
30 // remained alive until the |on_app_complete| callback is called.
31 class ChildProcessHost {
32 public:
33 // |name| is just for debugging ease.
34 ChildProcessHost(Context* context, const std::string& name);
35 virtual ~ChildProcessHost();
36
37 // |Start()|s the child process; calls |DidStart()| (on the thread on which
38 // |Start()| was called) when the child has been started (or failed to start).
39 // After calling |Start()|, this object must not be destroyed until
40 // |DidStart()| has been called.
41 // TODO(vtl): Consider using weak pointers and removing this requirement.
42 void Start();
43
44 // Waits for the child process to terminate, and returns its exit code.
45 // Note: If |Start()| has been called, this must not be called until the
46 // callback has been called.
47 int Join();
48
49 // See |ChildController|:
50 void StartApp(const String& app_path,
51 bool clean_app_path,
52 InterfaceRequest<Application> application_request,
53 const ChildController::StartAppCallback& on_app_complete);
54 void ExitNow(int32_t exit_code);
55
56 protected:
57 // virtual for testing.
58 virtual void DidStart(bool success);
59
60 private:
61 bool DoLaunch();
62
63 void AppCompleted(int32_t result);
64
65 // Callback for |embedder::CreateChannel()|.
66 void DidCreateChannel(embedder::ChannelInfo* channel_info);
67
68 Context* const context_;
69 const std::string name_;
70 base::Process child_process_;
71 embedder::PlatformChannelPair platform_channel_pair_;
72 ChildControllerPtr controller_;
73 embedder::ChannelInfo* channel_info_;
74 ChildController::StartAppCallback on_app_complete_;
75
76 // Platform-specific "pipe" to the child process. Valid immediately after
77 // creation.
78 embedder::ScopedPlatformHandle platform_channel_;
79
80 DISALLOW_COPY_AND_ASSIGN(ChildProcessHost);
81 };
82
83 } // namespace shell
84 } // namespace mojo
85
86 #endif // SHELL_CHILD_PROCESS_HOST_H_
OLDNEW
« no previous file with comments | « mojo/shell/child_process.mojom ('k') | mojo/shell/child_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698