Remove PlatformFile from profile_browsertest
[chromium-blink-merge.git] / content / browser / browser_child_process_host_impl.h
blob24bc1e78c3c2b83d03f60911bb23ced88cb6ce32
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_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_
8 #include <list>
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/process/process.h"
13 #include "base/synchronization/waitable_event_watcher.h"
14 #include "content/browser/child_process_launcher.h"
15 #include "content/browser/power_monitor_message_broadcaster.h"
16 #include "content/public/browser/browser_child_process_host.h"
17 #include "content/public/browser/child_process_data.h"
18 #include "content/public/common/child_process_host_delegate.h"
20 namespace base {
21 class CommandLine;
24 namespace content {
26 class BrowserChildProcessHostIterator;
27 class BrowserChildProcessObserver;
28 class BrowserMessageFilter;
30 // Plugins/workers and other child processes that live on the IO thread use this
31 // class. RenderProcessHostImpl is the main exception that doesn't use this
32 /// class because it lives on the UI thread.
33 class CONTENT_EXPORT BrowserChildProcessHostImpl
34 : public BrowserChildProcessHost,
35 public NON_EXPORTED_BASE(ChildProcessHostDelegate),
36 public ChildProcessLauncher::Client {
37 public:
38 BrowserChildProcessHostImpl(
39 int process_type,
40 BrowserChildProcessHostDelegate* delegate);
41 virtual ~BrowserChildProcessHostImpl();
43 // Terminates all child processes and deletes each BrowserChildProcessHost
44 // instance.
45 static void TerminateAll();
47 // BrowserChildProcessHost implementation:
48 virtual bool Send(IPC::Message* message) OVERRIDE;
49 virtual void Launch(
50 SandboxedProcessLauncherDelegate* delegate,
51 base::CommandLine* cmd_line) OVERRIDE;
52 virtual const ChildProcessData& GetData() const OVERRIDE;
53 virtual ChildProcessHost* GetHost() const OVERRIDE;
54 virtual base::TerminationStatus GetTerminationStatus(
55 bool known_dead, int* exit_code) OVERRIDE;
56 virtual void SetNaClDebugStubPort(int port) OVERRIDE;
57 virtual void SetName(const base::string16& name) OVERRIDE;
58 virtual void SetHandle(base::ProcessHandle handle) OVERRIDE;
60 // ChildProcessHostDelegate implementation:
61 virtual bool CanShutdown() OVERRIDE;
62 virtual void OnChildDisconnected() OVERRIDE;
63 virtual base::ProcessHandle GetHandle() const OVERRIDE;
64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
65 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
66 virtual void OnChannelError() OVERRIDE;
68 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown
69 void ForceShutdown();
71 // Callers can reduce the BrowserChildProcess' priority.
72 void SetBackgrounded(bool backgrounded);
74 // Controls whether the child process should be terminated on browser
75 // shutdown. Default is to always terminate.
76 void SetTerminateChildOnShutdown(bool terminate_on_shutdown);
78 // Adds an IPC message filter.
79 void AddFilter(BrowserMessageFilter* filter);
81 // Called when an instance of a particular child is created in a page.
82 static void NotifyProcessInstanceCreated(const ChildProcessData& data);
84 BrowserChildProcessHostDelegate* delegate() const { return delegate_; }
86 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList;
87 private:
88 friend class BrowserChildProcessHostIterator;
89 friend class BrowserChildProcessObserver;
91 static BrowserChildProcessList* GetIterator();
93 static void AddObserver(BrowserChildProcessObserver* observer);
94 static void RemoveObserver(BrowserChildProcessObserver* observer);
96 // ChildProcessLauncher::Client implementation.
97 virtual void OnProcessLaunched() OVERRIDE;
98 virtual void OnProcessLaunchFailed() OVERRIDE;
100 #if defined(OS_WIN)
101 void DeleteProcessWaitableEvent(base::WaitableEvent* event);
102 void OnProcessExitedEarly(base::WaitableEvent* event);
103 #endif
105 ChildProcessData data_;
106 BrowserChildProcessHostDelegate* delegate_;
107 scoped_ptr<ChildProcessHost> child_process_host_;
109 scoped_ptr<ChildProcessLauncher> child_process_;
111 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_;
113 #if defined(OS_WIN)
114 // Watches to see if the child process exits before the IPC channel has
115 // been connected. Thereafter, its exit is determined by an error on the
116 // IPC channel.
117 base::WaitableEventWatcher early_exit_watcher_;
118 #endif
121 } // namespace content
123 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_