OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
7 | 7 |
8 #include "base/environment.h" | 8 #include "base/environment.h" |
9 #include "base/process/kill.h" | 9 #include "base/process/kill.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
11 #include "base/process/process_metrics.h" | 11 #include "base/process/process_metrics.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/common/process_type.h" | 15 #include "content/public/common/process_type.h" |
16 #include "ipc/ipc_sender.h" | 16 #include "ipc/ipc_sender.h" |
17 | 17 |
18 namespace base { | 18 namespace base { |
19 class CommandLine; | 19 class CommandLine; |
20 class FilePath; | 20 class FilePath; |
21 } | 21 } |
22 | 22 |
23 namespace content { | 23 namespace content { |
24 | 24 |
25 class BrowserChildProcessHostDelegate; | 25 class BrowserChildProcessHostDelegate; |
26 class ChildProcessHost; | 26 class ChildProcessHost; |
27 class SandboxedProcessLauncherDelegate; | 27 class SandboxedProcessLauncherDelegate; |
| 28 class ServiceRegistry; |
28 struct ChildProcessData; | 29 struct ChildProcessData; |
29 | 30 |
30 // This represents child processes of the browser process, i.e. plugins. They | 31 // This represents child processes of the browser process, i.e. plugins. They |
31 // will get terminated at browser shutdown. | 32 // will get terminated at browser shutdown. |
32 class CONTENT_EXPORT BrowserChildProcessHost : public IPC::Sender { | 33 class CONTENT_EXPORT BrowserChildProcessHost : public IPC::Sender { |
33 public: | 34 public: |
34 // Used to create a child process host. The delegate must outlive this object. | 35 // Used to create a child process host. The delegate must outlive this object. |
35 // |process_type| needs to be either an enum value from ProcessType or an | 36 // |process_type| needs to be either an enum value from ProcessType or an |
36 // embedder-defined value. | 37 // embedder-defined value. |
37 static BrowserChildProcessHost* Create( | 38 static BrowserChildProcessHost* Create( |
38 content::ProcessType process_type, | 39 content::ProcessType process_type, |
39 BrowserChildProcessHostDelegate* delegate); | 40 BrowserChildProcessHostDelegate* delegate); |
40 | 41 |
| 42 // Returns the child process host with unique id |child_process_id|, or |
| 43 // nullptr if it doesn't exist. |child_process_id| is NOT the process ID, but |
| 44 // is the same unique ID as |ChildProcessData::id|. |
| 45 static BrowserChildProcessHost* FromID(int child_process_id); |
| 46 |
41 ~BrowserChildProcessHost() override {} | 47 ~BrowserChildProcessHost() override {} |
42 | 48 |
43 // Derived classes call this to launch the child process asynchronously. | 49 // Derived classes call this to launch the child process asynchronously. |
44 // Takes ownership of |cmd_line| and |delegate|. | 50 // Takes ownership of |cmd_line| and |delegate|. |
45 virtual void Launch( | 51 virtual void Launch( |
46 SandboxedProcessLauncherDelegate* delegate, | 52 SandboxedProcessLauncherDelegate* delegate, |
47 base::CommandLine* cmd_line, | 53 base::CommandLine* cmd_line, |
48 bool terminate_on_shutdown) = 0; | 54 bool terminate_on_shutdown) = 0; |
49 | 55 |
50 virtual const ChildProcessData& GetData() const = 0; | 56 virtual const ChildProcessData& GetData() const = 0; |
(...skipping 14 matching lines...) Expand all Loading... |
65 // Sets the user-visible name of the process. | 71 // Sets the user-visible name of the process. |
66 virtual void SetName(const base::string16& name) = 0; | 72 virtual void SetName(const base::string16& name) = 0; |
67 | 73 |
68 // Set the handle of the process. BrowserChildProcessHost will do this when | 74 // Set the handle of the process. BrowserChildProcessHost will do this when |
69 // the Launch method is used to start the process. However if the owner | 75 // the Launch method is used to start the process. However if the owner |
70 // of this object doesn't call Launch and starts the process in another way, | 76 // of this object doesn't call Launch and starts the process in another way, |
71 // they need to call this method so that the process handle is associated with | 77 // they need to call this method so that the process handle is associated with |
72 // this object. | 78 // this object. |
73 virtual void SetHandle(base::ProcessHandle handle) = 0; | 79 virtual void SetHandle(base::ProcessHandle handle) = 0; |
74 | 80 |
| 81 // Get the Mojo service registry connected to the child process. Returns |
| 82 // nullptr if no service registry exists. |
| 83 virtual ServiceRegistry* GetServiceRegistry() = 0; |
| 84 |
75 #if defined(OS_MACOSX) && !defined(OS_IOS) | 85 #if defined(OS_MACOSX) && !defined(OS_IOS) |
76 // Returns a PortProvider used to get process metrics for child processes. | 86 // Returns a PortProvider used to get process metrics for child processes. |
77 static base::ProcessMetrics::PortProvider* GetPortProvider(); | 87 static base::ProcessMetrics::PortProvider* GetPortProvider(); |
78 #endif | 88 #endif |
79 }; | 89 }; |
80 | 90 |
81 }; // namespace content | 91 }; // namespace content |
82 | 92 |
83 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 93 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ |
OLD | NEW |