| 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_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
| 7 | 7 |
| 8 #include <list> | 8 #include <list> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 // Terminates all child processes and deletes each BrowserChildProcessHost | 39 // Terminates all child processes and deletes each BrowserChildProcessHost |
| 40 // instance. | 40 // instance. |
| 41 static void TerminateAll(); | 41 static void TerminateAll(); |
| 42 | 42 |
| 43 // BrowserChildProcessHost implementation: | 43 // BrowserChildProcessHost implementation: |
| 44 virtual bool Send(IPC::Message* message) OVERRIDE; | 44 virtual bool Send(IPC::Message* message) OVERRIDE; |
| 45 virtual void Launch( | 45 virtual void Launch( |
| 46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
| 47 SandboxedProcessLauncherDelegate* delegate, | 47 SandboxedProcessLauncherDelegate* delegate, |
| 48 bool launch_elevated, |
| 48 #elif defined(OS_POSIX) | 49 #elif defined(OS_POSIX) |
| 49 bool use_zygote, | 50 bool use_zygote, |
| 50 const base::EnvironmentMap& environ, | 51 const base::EnvironmentMap& environ, |
| 51 #endif | 52 #endif |
| 52 CommandLine* cmd_line) OVERRIDE; | 53 CommandLine* cmd_line) OVERRIDE; |
| 53 virtual const ChildProcessData& GetData() const OVERRIDE; | 54 virtual const ChildProcessData& GetData() const OVERRIDE; |
| 54 virtual ChildProcessHost* GetHost() const OVERRIDE; | 55 virtual ChildProcessHost* GetHost() const OVERRIDE; |
| 55 virtual base::TerminationStatus GetTerminationStatus( | 56 virtual base::TerminationStatus GetTerminationStatus( |
| 56 bool known_dead, int* exit_code) OVERRIDE; | 57 bool known_dead, int* exit_code) OVERRIDE; |
| 57 virtual void SetNaClDebugStubPort(int port) OVERRIDE; | 58 virtual void SetNaClDebugStubPort(int port) OVERRIDE; |
| 58 virtual void SetName(const base::string16& name) OVERRIDE; | 59 virtual void SetName(const base::string16& name) OVERRIDE; |
| 59 virtual void SetHandle(base::ProcessHandle handle) OVERRIDE; | 60 virtual void SetHandle(base::ProcessHandle handle) OVERRIDE; |
| 60 | 61 |
| 61 // Returns the handle of the child process. This can be called only after | 62 // ChildProcessHostDelegate implementation: |
| 62 // OnProcessLaunched is called or it will be invalid and may crash. | 63 virtual bool CanShutdown() OVERRIDE; |
| 63 base::ProcessHandle GetHandle() const; | 64 virtual void OnChildDisconnected() OVERRIDE; |
| 65 virtual base::ProcessHandle GetHandle() const OVERRIDE; |
| 66 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 67 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 68 virtual void OnChannelError() OVERRIDE; |
| 64 | 69 |
| 65 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown | 70 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown |
| 66 void ForceShutdown(); | 71 void ForceShutdown(); |
| 67 | 72 |
| 68 // Callers can reduce the BrowserChildProcess' priority. | 73 // Callers can reduce the BrowserChildProcess' priority. |
| 69 void SetBackgrounded(bool backgrounded); | 74 void SetBackgrounded(bool backgrounded); |
| 70 | 75 |
| 71 // Controls whether the child process should be terminated on browser | 76 // Controls whether the child process should be terminated on browser |
| 72 // shutdown. Default is to always terminate. | 77 // shutdown. Default is to always terminate. |
| 73 void SetTerminateChildOnShutdown(bool terminate_on_shutdown); | 78 void SetTerminateChildOnShutdown(bool terminate_on_shutdown); |
| 74 | 79 |
| 75 // Adds an IPC message filter. | 80 // Adds an IPC message filter. |
| 76 void AddFilter(BrowserMessageFilter* filter); | 81 void AddFilter(BrowserMessageFilter* filter); |
| 77 | 82 |
| 78 // Called when an instance of a particular child is created in a page. | 83 // Called when an instance of a particular child is created in a page. |
| 79 static void NotifyProcessInstanceCreated(const ChildProcessData& data); | 84 static void NotifyProcessInstanceCreated(const ChildProcessData& data); |
| 80 | 85 |
| 81 BrowserChildProcessHostDelegate* delegate() const { return delegate_; } | 86 BrowserChildProcessHostDelegate* delegate() const { return delegate_; } |
| 82 | 87 |
| 83 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; | 88 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; |
| 84 private: | 89 private: |
| 85 friend class BrowserChildProcessHostIterator; | 90 friend class BrowserChildProcessHostIterator; |
| 86 friend class BrowserChildProcessObserver; | 91 friend class BrowserChildProcessObserver; |
| 87 | 92 |
| 88 static BrowserChildProcessList* GetIterator(); | 93 static BrowserChildProcessList* GetIterator(); |
| 89 | 94 |
| 90 static void AddObserver(BrowserChildProcessObserver* observer); | 95 static void AddObserver(BrowserChildProcessObserver* observer); |
| 91 static void RemoveObserver(BrowserChildProcessObserver* observer); | 96 static void RemoveObserver(BrowserChildProcessObserver* observer); |
| 92 | 97 |
| 93 // ChildProcessHostDelegate implementation: | |
| 94 virtual bool CanShutdown() OVERRIDE; | |
| 95 virtual void OnChildDisconnected() OVERRIDE; | |
| 96 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 97 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | |
| 98 virtual void OnChannelError() OVERRIDE; | |
| 99 | |
| 100 // ChildProcessLauncher::Client implementation. | 98 // ChildProcessLauncher::Client implementation. |
| 101 virtual void OnProcessLaunched() OVERRIDE; | 99 virtual void OnProcessLaunched() OVERRIDE; |
| 100 virtual void OnProcessLaunchFailed() OVERRIDE; |
| 102 | 101 |
| 103 #if defined(OS_WIN) | 102 #if defined(OS_WIN) |
| 104 void DeleteProcessWaitableEvent(base::WaitableEvent* event); | 103 void DeleteProcessWaitableEvent(base::WaitableEvent* event); |
| 105 void OnProcessExitedEarly(base::WaitableEvent* event); | 104 void OnProcessExitedEarly(base::WaitableEvent* event); |
| 106 #endif | 105 #endif |
| 107 | 106 |
| 108 ChildProcessData data_; | 107 ChildProcessData data_; |
| 109 BrowserChildProcessHostDelegate* delegate_; | 108 BrowserChildProcessHostDelegate* delegate_; |
| 110 scoped_ptr<ChildProcessHost> child_process_host_; | 109 scoped_ptr<ChildProcessHost> child_process_host_; |
| 111 | 110 |
| 112 scoped_ptr<ChildProcessLauncher> child_process_; | 111 scoped_ptr<ChildProcessLauncher> child_process_; |
| 113 | 112 |
| 114 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; | 113 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; |
| 115 | 114 |
| 116 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
| 117 // Watches to see if the child process exits before the IPC channel has | 116 // Watches to see if the child process exits before the IPC channel has |
| 118 // been connected. Thereafter, its exit is determined by an error on the | 117 // been connected. Thereafter, its exit is determined by an error on the |
| 119 // IPC channel. | 118 // IPC channel. |
| 120 base::WaitableEventWatcher early_exit_watcher_; | 119 base::WaitableEventWatcher early_exit_watcher_; |
| 121 #endif | 120 #endif |
| 122 }; | 121 }; |
| 123 | 122 |
| 124 } // namespace content | 123 } // namespace content |
| 125 | 124 |
| 126 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 125 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
| OLD | NEW |