OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_H_ | 5 #ifndef CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/process.h" | 14 #include "base/process.h" |
15 #include "base/synchronization/waitable_event_watcher.h" | 15 #include "base/synchronization/waitable_event_watcher.h" |
16 #include "content/browser/child_process_launcher.h" | 16 #include "content/browser/child_process_launcher.h" |
17 #include "content/public/browser/browser_child_process_host.h" | 17 #include "content/public/browser/browser_child_process_host.h" |
18 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
19 #include "content/public/common/child_process_host_delegate.h" | 19 #include "content/public/common/child_process_host_delegate.h" |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class BrowserChildProcessHostIterator; | 22 class BrowserChildProcessHostIterator; |
23 } | 23 } |
24 | 24 |
25 // Plugins/workers and other child processes that live on the IO thread use this | 25 // Plugins/workers and other child processes that live on the IO thread use this |
26 // class. RenderProcessHostImpl is the main exception that doesn't use this | 26 // class. RenderProcessHostImpl is the main exception that doesn't use this |
27 /// class because it lives on the UI thread. | 27 /// class because it lives on the UI thread. |
28 class CONTENT_EXPORT BrowserChildProcessHost : | 28 class CONTENT_EXPORT BrowserChildProcessHostImpl : |
29 public NON_EXPORTED_BASE(content::BrowserChildProcessHost), | 29 public content::BrowserChildProcessHost, |
30 public NON_EXPORTED_BASE(content::ChildProcessHostDelegate), | 30 public NON_EXPORTED_BASE(content::ChildProcessHostDelegate), |
31 public ChildProcessLauncher::Client, | 31 public ChildProcessLauncher::Client, |
32 public base::WaitableEventWatcher::Delegate { | 32 public base::WaitableEventWatcher::Delegate { |
33 public: | 33 public: |
34 BrowserChildProcessHost(content::ProcessType type, | 34 BrowserChildProcessHostImpl( |
35 content::BrowserChildProcessHostDelegate* delegate); | 35 content::ProcessType type, |
36 virtual ~BrowserChildProcessHost(); | 36 content::BrowserChildProcessHostDelegate* delegate); |
| 37 virtual ~BrowserChildProcessHostImpl(); |
37 | 38 |
38 // Terminates all child processes and deletes each BrowserChildProcessHost | 39 // Terminates all child processes and deletes each BrowserChildProcessHost |
39 // instance. | 40 // instance. |
40 static void TerminateAll(); | 41 static void TerminateAll(); |
41 | 42 |
42 // BrowserChildProcessHost implementation: | 43 // BrowserChildProcessHostImpl implementation: |
43 virtual bool Send(IPC::Message* message) OVERRIDE; | 44 virtual bool Send(IPC::Message* message) OVERRIDE; |
44 virtual void Launch( | 45 virtual void Launch( |
45 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
46 const FilePath& exposed_dir, | 47 const FilePath& exposed_dir, |
47 #elif defined(OS_POSIX) | 48 #elif defined(OS_POSIX) |
48 bool use_zygote, | 49 bool use_zygote, |
49 const base::environment_vector& environ, | 50 const base::environment_vector& environ, |
50 #endif | 51 #endif |
51 CommandLine* cmd_line) OVERRIDE; | 52 CommandLine* cmd_line) OVERRIDE; |
52 virtual const content::ChildProcessData& GetData() const OVERRIDE; | 53 virtual const content::ChildProcessData& GetData() const OVERRIDE; |
(...skipping 15 matching lines...) Expand all Loading... |
68 // shutdown. Default is to always terminate. | 69 // shutdown. Default is to always terminate. |
69 void SetTerminateChildOnShutdown(bool terminate_on_shutdown); | 70 void SetTerminateChildOnShutdown(bool terminate_on_shutdown); |
70 | 71 |
71 // Sends the given notification on the UI thread. | 72 // Sends the given notification on the UI thread. |
72 void Notify(int type); | 73 void Notify(int type); |
73 | 74 |
74 content::BrowserChildProcessHostDelegate* delegate() const { | 75 content::BrowserChildProcessHostDelegate* delegate() const { |
75 return delegate_; | 76 return delegate_; |
76 } | 77 } |
77 | 78 |
78 typedef std::list<BrowserChildProcessHost*> BrowserChildProcessList; | 79 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; |
79 private: | 80 private: |
80 friend class content::BrowserChildProcessHostIterator; | 81 friend class content::BrowserChildProcessHostIterator; |
81 | 82 |
82 static BrowserChildProcessList* GetIterator(); | 83 static BrowserChildProcessList* GetIterator(); |
83 | 84 |
84 // ChildProcessHostDelegate implementation: | 85 // ChildProcessHostDelegate implementation: |
85 virtual bool CanShutdown() OVERRIDE; | 86 virtual bool CanShutdown() OVERRIDE; |
86 virtual void OnChildDisconnected() OVERRIDE; | 87 virtual void OnChildDisconnected() OVERRIDE; |
87 virtual void ShutdownStarted() OVERRIDE; | 88 virtual void ShutdownStarted() OVERRIDE; |
88 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 89 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
89 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 90 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
90 virtual void OnChannelError() OVERRIDE; | 91 virtual void OnChannelError() OVERRIDE; |
91 | 92 |
92 // ChildProcessLauncher::Client implementation. | 93 // ChildProcessLauncher::Client implementation. |
93 virtual void OnProcessLaunched() OVERRIDE; | 94 virtual void OnProcessLaunched() OVERRIDE; |
94 | 95 |
95 // public base::WaitableEventWatcher::Delegate implementation: | 96 // public base::WaitableEventWatcher::Delegate implementation: |
96 virtual void OnWaitableEventSignaled( | 97 virtual void OnWaitableEventSignaled( |
97 base::WaitableEvent* waitable_event) OVERRIDE; | 98 base::WaitableEvent* waitable_event) OVERRIDE; |
98 | 99 |
99 content::ChildProcessData data_; | 100 content::ChildProcessData data_; |
100 content::BrowserChildProcessHostDelegate* delegate_; | 101 content::BrowserChildProcessHostDelegate* delegate_; |
101 scoped_ptr<content::ChildProcessHost> child_process_host_; | 102 scoped_ptr<content::ChildProcessHost> child_process_host_; |
102 | 103 |
103 scoped_ptr<ChildProcessLauncher> child_process_; | 104 scoped_ptr<ChildProcessLauncher> child_process_; |
104 #if defined(OS_WIN) | 105 #if defined(OS_WIN) |
105 base::WaitableEventWatcher child_watcher_; | 106 base::WaitableEventWatcher child_watcher_; |
106 #else | 107 #else |
107 base::WeakPtrFactory<BrowserChildProcessHost> task_factory_; | 108 base::WeakPtrFactory<BrowserChildProcessHostImpl> task_factory_; |
108 #endif | 109 #endif |
109 bool disconnect_was_alive_; | 110 bool disconnect_was_alive_; |
110 }; | 111 }; |
111 | 112 |
112 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_H_ | 113 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
OLD | NEW |