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

Side by Side Diff: shell/child_process_host.h

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

Powered by Google App Engine
This is Rietveld 408576698