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