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