OLD | NEW |
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_H_ | 5 #ifndef MOJO_SHELL_CHILD_PROCESS_H_ |
6 #define SHELL_CHILD_PROCESS_H_ | 6 #define MOJO_SHELL_CHILD_PROCESS_H_ |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "mojo/edk/embedder/scoped_platform_handle.h" | |
11 | |
12 namespace base { | |
13 class CommandLine; | |
14 } | |
15 | 7 |
16 namespace mojo { | 8 namespace mojo { |
17 namespace shell { | 9 namespace shell { |
18 | 10 |
19 // A base class for child processes -- i.e., code that is actually run within | 11 // Main method for a child process. |
20 // the child process. (Instances are manufactured by |Create()|.) | 12 int ChildProcessMain(); |
21 class ChildProcess { | |
22 public: | |
23 virtual ~ChildProcess(); | |
24 | |
25 // Returns null if the command line doesn't indicate that this is a child | |
26 // process. |main()| should call this, and if it returns non-null it should | |
27 // call |Main()| (without a message loop on the current thread). | |
28 static scoped_ptr<ChildProcess> Create(const base::CommandLine& command_line); | |
29 | |
30 // To be implemented by subclasses. This is the "entrypoint" for a child | |
31 // process. Run with no message loop for the main thread. | |
32 virtual void Main() = 0; | |
33 | |
34 protected: | |
35 ChildProcess(); | |
36 | |
37 embedder::ScopedPlatformHandle* platform_channel() { | |
38 return &platform_channel_; | |
39 } | |
40 | |
41 private: | |
42 // Available in |Main()| (after a successful |Create()|). | |
43 embedder::ScopedPlatformHandle platform_channel_; | |
44 | |
45 DISALLOW_COPY_AND_ASSIGN(ChildProcess); | |
46 }; | |
47 | 13 |
48 } // namespace shell | 14 } // namespace shell |
49 } // namespace mojo | 15 } // namespace mojo |
50 | 16 |
51 #endif // SHELL_CHILD_PROCESS_H_ | 17 #endif // MOJO_SHELL_CHILD_PROCESS_H_ |
OLD | NEW |