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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" |
12 #include "base/process/process.h" | 13 #include "base/process/process.h" |
13 #include "base/synchronization/waitable_event_watcher.h" | 14 #include "base/synchronization/waitable_event_watcher.h" |
14 #include "content/browser/child_process_launcher.h" | 15 #include "content/browser/child_process_launcher.h" |
15 #include "content/browser/power_monitor_message_broadcaster.h" | 16 #include "content/browser/power_monitor_message_broadcaster.h" |
16 #include "content/public/browser/browser_child_process_host.h" | 17 #include "content/public/browser/browser_child_process_host.h" |
17 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
18 #include "content/public/common/child_process_host_delegate.h" | 19 #include "content/public/common/child_process_host_delegate.h" |
19 | 20 |
20 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
21 #include "base/win/object_watcher.h" | 22 #include "base/win/object_watcher.h" |
22 #endif | 23 #endif |
23 | 24 |
24 namespace base { | 25 namespace base { |
25 class CommandLine; | 26 class CommandLine; |
26 } | 27 } |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 class BrowserChildProcessHostIterator; | 31 class BrowserChildProcessHostIterator; |
31 class BrowserChildProcessObserver; | 32 class BrowserChildProcessObserver; |
32 class BrowserMessageFilter; | 33 class BrowserMessageFilter; |
| 34 class ServiceRegistry; |
33 | 35 |
34 // Plugins/workers and other child processes that live on the IO thread use this | 36 // Plugins/workers and other child processes that live on the IO thread use this |
35 // class. RenderProcessHostImpl is the main exception that doesn't use this | 37 // class. RenderProcessHostImpl is the main exception that doesn't use this |
36 /// class because it lives on the UI thread. | 38 /// class because it lives on the UI thread. |
37 class CONTENT_EXPORT BrowserChildProcessHostImpl | 39 class CONTENT_EXPORT BrowserChildProcessHostImpl |
38 : public BrowserChildProcessHost, | 40 : public BrowserChildProcessHost, |
39 public NON_EXPORTED_BASE(ChildProcessHostDelegate), | 41 public NON_EXPORTED_BASE(ChildProcessHostDelegate), |
40 #if defined(OS_WIN) | 42 #if defined(OS_WIN) |
41 public base::win::ObjectWatcher::Delegate, | 43 public base::win::ObjectWatcher::Delegate, |
42 #endif | 44 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
54 bool Send(IPC::Message* message) override; | 56 bool Send(IPC::Message* message) override; |
55 void Launch(SandboxedProcessLauncherDelegate* delegate, | 57 void Launch(SandboxedProcessLauncherDelegate* delegate, |
56 base::CommandLine* cmd_line, | 58 base::CommandLine* cmd_line, |
57 bool terminate_on_shutdown) override; | 59 bool terminate_on_shutdown) override; |
58 const ChildProcessData& GetData() const override; | 60 const ChildProcessData& GetData() const override; |
59 ChildProcessHost* GetHost() const override; | 61 ChildProcessHost* GetHost() const override; |
60 base::TerminationStatus GetTerminationStatus(bool known_dead, | 62 base::TerminationStatus GetTerminationStatus(bool known_dead, |
61 int* exit_code) override; | 63 int* exit_code) override; |
62 void SetName(const base::string16& name) override; | 64 void SetName(const base::string16& name) override; |
63 void SetHandle(base::ProcessHandle handle) override; | 65 void SetHandle(base::ProcessHandle handle) override; |
| 66 ServiceRegistry* GetServiceRegistry() override; |
64 | 67 |
65 // ChildProcessHostDelegate implementation: | 68 // ChildProcessHostDelegate implementation: |
66 bool CanShutdown() override; | 69 bool CanShutdown() override; |
67 void OnChildDisconnected() override; | 70 void OnChildDisconnected() override; |
68 const base::Process& GetProcess() const override; | 71 const base::Process& GetProcess() const override; |
69 bool OnMessageReceived(const IPC::Message& message) override; | 72 bool OnMessageReceived(const IPC::Message& message) override; |
70 void OnChannelConnected(int32 peer_pid) override; | 73 void OnChannelConnected(int32 peer_pid) override; |
71 void OnChannelError() override; | 74 void OnChannelError() override; |
72 void OnBadMessageReceived(const IPC::Message& message) override; | 75 void OnBadMessageReceived(const IPC::Message& message) override; |
73 | 76 |
74 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown | 77 // Removes this host from the host list. Calls ChildProcessHost::ForceShutdown |
75 void ForceShutdown(); | 78 void ForceShutdown(); |
76 | 79 |
77 // Callers can reduce the BrowserChildProcess' priority. | 80 // Callers can reduce the BrowserChildProcess' priority. |
78 void SetBackgrounded(bool backgrounded); | 81 void SetBackgrounded(bool backgrounded); |
79 | 82 |
80 // Adds an IPC message filter. | 83 // Adds an IPC message filter. |
81 void AddFilter(BrowserMessageFilter* filter); | 84 void AddFilter(BrowserMessageFilter* filter); |
82 | 85 |
| 86 // Set the Mojo service registry connected to the child process. |
| 87 void SetServiceRegistry(base::WeakPtr<ServiceRegistry> service_registry); |
| 88 |
83 // Called when an instance of a particular child is created in a page. | 89 // Called when an instance of a particular child is created in a page. |
84 static void NotifyProcessInstanceCreated(const ChildProcessData& data); | 90 static void NotifyProcessInstanceCreated(const ChildProcessData& data); |
85 | 91 |
86 static void HistogramBadMessageTerminated(int process_type); | 92 static void HistogramBadMessageTerminated(int process_type); |
87 | 93 |
88 BrowserChildProcessHostDelegate* delegate() const { return delegate_; } | 94 BrowserChildProcessHostDelegate* delegate() const { return delegate_; } |
89 | 95 |
90 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; | 96 typedef std::list<BrowserChildProcessHostImpl*> BrowserChildProcessList; |
91 private: | 97 private: |
92 friend class BrowserChildProcessHostIterator; | 98 friend class BrowserChildProcessHostIterator; |
(...skipping 14 matching lines...) Expand all Loading... |
107 #endif | 113 #endif |
108 | 114 |
109 ChildProcessData data_; | 115 ChildProcessData data_; |
110 BrowserChildProcessHostDelegate* delegate_; | 116 BrowserChildProcessHostDelegate* delegate_; |
111 scoped_ptr<ChildProcessHost> child_process_host_; | 117 scoped_ptr<ChildProcessHost> child_process_host_; |
112 | 118 |
113 scoped_ptr<ChildProcessLauncher> child_process_; | 119 scoped_ptr<ChildProcessLauncher> child_process_; |
114 | 120 |
115 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; | 121 PowerMonitorMessageBroadcaster power_monitor_message_broadcaster_; |
116 | 122 |
| 123 base::WeakPtr<ServiceRegistry> service_registry_; |
| 124 |
117 #if defined(OS_WIN) | 125 #if defined(OS_WIN) |
118 // Watches to see if the child process exits before the IPC channel has | 126 // Watches to see if the child process exits before the IPC channel has |
119 // been connected. Thereafter, its exit is determined by an error on the | 127 // been connected. Thereafter, its exit is determined by an error on the |
120 // IPC channel. | 128 // IPC channel. |
121 base::win::ObjectWatcher early_exit_watcher_; | 129 base::win::ObjectWatcher early_exit_watcher_; |
122 #endif | 130 #endif |
123 }; | 131 }; |
124 | 132 |
125 } // namespace content | 133 } // namespace content |
126 | 134 |
127 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ | 135 #endif // CONTENT_BROWSER_BROWSER_CHILD_PROCESS_HOST_IMPL_H_ |
OLD | NEW |