Content settings: remove some plugin-related code/resources when... there are no...
[chromium-blink-merge.git] / content / public / browser / browser_child_process_host.h
blob1cf5745c79a0043d48d21196ff8d77cfa29b7a9f
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_
6 #define CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_
8 #include "base/environment.h"
9 #include "base/process/kill.h"
10 #include "base/process/process_handle.h"
11 #include "base/process/process_metrics.h"
12 #include "base/strings/string16.h"
13 #include "build/build_config.h"
14 #include "content/common/content_export.h"
15 #include "content/public/common/process_type.h"
16 #include "ipc/ipc_sender.h"
18 namespace base {
19 class CommandLine;
20 class FilePath;
23 namespace content {
25 class BrowserChildProcessHostDelegate;
26 class ChildProcessHost;
27 class SandboxedProcessLauncherDelegate;
28 class ServiceRegistry;
29 struct ChildProcessData;
31 // This represents child processes of the browser process, i.e. plugins. They
32 // will get terminated at browser shutdown.
33 class CONTENT_EXPORT BrowserChildProcessHost : public IPC::Sender {
34 public:
35 // Used to create a child process host. The delegate must outlive this object.
36 // |process_type| needs to be either an enum value from ProcessType or an
37 // embedder-defined value.
38 static BrowserChildProcessHost* Create(
39 content::ProcessType process_type,
40 BrowserChildProcessHostDelegate* delegate);
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);
47 ~BrowserChildProcessHost() override {}
49 // Derived classes call this to launch the child process asynchronously.
50 // Takes ownership of |cmd_line| and |delegate|.
51 virtual void Launch(
52 SandboxedProcessLauncherDelegate* delegate,
53 base::CommandLine* cmd_line,
54 bool terminate_on_shutdown) = 0;
56 virtual const ChildProcessData& GetData() const = 0;
58 // Returns the ChildProcessHost object used by this object.
59 virtual ChildProcessHost* GetHost() const = 0;
61 // Returns the termination status of a child. |exit_code| is the
62 // status returned when the process exited (for posix, as returned
63 // from waitpid(), for Windows, as returned from
64 // GetExitCodeProcess()). |exit_code| may be nullptr.
65 // |known_dead| indicates that the child is already dead. On Linux, this
66 // information is necessary to retrieve accurate information. See
67 // ChildProcessLauncher::GetChildTerminationStatus() for more details.
68 virtual base::TerminationStatus GetTerminationStatus(
69 bool known_dead, int* exit_code) = 0;
71 // Sets the user-visible name of the process.
72 virtual void SetName(const base::string16& name) = 0;
74 // Set the handle of the process. BrowserChildProcessHost will do this when
75 // the Launch method is used to start the process. However if the owner
76 // of this object doesn't call Launch and starts the process in another way,
77 // they need to call this method so that the process handle is associated with
78 // this object.
79 virtual void SetHandle(base::ProcessHandle handle) = 0;
81 // Get the Mojo service registry connected to the child process. Returns
82 // nullptr if no service registry exists.
83 virtual ServiceRegistry* GetServiceRegistry() = 0;
85 #if defined(OS_MACOSX) && !defined(OS_IOS)
86 // Returns a PortProvider used to get process metrics for child processes.
87 static base::ProcessMetrics::PortProvider* GetPortProvider();
88 #endif
91 }; // namespace content
93 #endif // CONTENT_PUBLIC_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_