OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/common/child_process_host.h" | 5 #include "chrome/common/child_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "chrome/common/child_process_info.h" | 10 #include "chrome/common/child_process_info.h" |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 } | 148 } |
149 | 149 |
150 void ChildProcessHost::OnChildDied() { | 150 void ChildProcessHost::OnChildDied() { |
151 delete this; | 151 delete this; |
152 } | 152 } |
153 | 153 |
154 ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host) | 154 ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host) |
155 : host_(host) { | 155 : host_(host) { |
156 } | 156 } |
157 | 157 |
158 void ChildProcessHost::ListenerHook::OnMessageReceived( | 158 bool ChildProcessHost::ListenerHook::OnMessageReceived( |
159 const IPC::Message& msg) { | 159 const IPC::Message& msg) { |
160 #ifdef IPC_MESSAGE_LOG_ENABLED | 160 #ifdef IPC_MESSAGE_LOG_ENABLED |
161 IPC::Logging* logger = IPC::Logging::GetInstance(); | 161 IPC::Logging* logger = IPC::Logging::GetInstance(); |
162 if (msg.type() == IPC_LOGGING_ID) { | 162 if (msg.type() == IPC_LOGGING_ID) { |
163 logger->OnReceivedLoggingMessage(msg); | 163 logger->OnReceivedLoggingMessage(msg); |
164 return; | 164 return true; |
165 } | 165 } |
166 | 166 |
167 if (logger->Enabled()) | 167 if (logger->Enabled()) |
168 logger->OnPreDispatchMessage(msg); | 168 logger->OnPreDispatchMessage(msg); |
169 #endif | 169 #endif |
170 | 170 |
171 bool handled = false; | 171 bool handled = false; |
172 for (size_t i = 0; i < host_->filters_.size(); ++i) { | 172 for (size_t i = 0; i < host_->filters_.size(); ++i) { |
173 if (host_->filters_[i]->OnMessageReceived(msg)) { | 173 if (host_->filters_[i]->OnMessageReceived(msg)) { |
174 handled = true; | 174 handled = true; |
175 break; | 175 break; |
176 } | 176 } |
177 } | 177 } |
178 | 178 |
179 if (!handled && msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { | 179 if (!handled && msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { |
180 if (host_->CanShutdown()) | 180 if (host_->CanShutdown()) |
181 host_->Send(new PluginProcessMsg_Shutdown()); | 181 host_->Send(new PluginProcessMsg_Shutdown()); |
182 handled = true; | 182 handled = true; |
183 } | 183 } |
184 | 184 |
185 if (!handled) | 185 if (!handled) |
186 host_->OnMessageReceived(msg); | 186 handled = host_->OnMessageReceived(msg); |
187 | 187 |
188 #ifdef IPC_MESSAGE_LOG_ENABLED | 188 #ifdef IPC_MESSAGE_LOG_ENABLED |
189 if (logger->Enabled()) | 189 if (logger->Enabled()) |
190 logger->OnPostDispatchMessage(msg, host_->channel_id_); | 190 logger->OnPostDispatchMessage(msg, host_->channel_id_); |
191 #endif | 191 #endif |
| 192 return handled; |
192 } | 193 } |
193 | 194 |
194 void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { | 195 void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { |
195 host_->opening_channel_ = false; | 196 host_->opening_channel_ = false; |
196 host_->OnChannelConnected(peer_pid); | 197 host_->OnChannelConnected(peer_pid); |
197 // Notify in the main loop of the connection. | 198 // Notify in the main loop of the connection. |
198 host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); | 199 host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); |
199 | 200 |
200 for (size_t i = 0; i < host_->filters_.size(); ++i) | 201 for (size_t i = 0; i < host_->filters_.size(); ++i) |
201 host_->filters_[i]->OnChannelConnected(peer_pid); | 202 host_->filters_[i]->OnChannelConnected(peer_pid); |
202 } | 203 } |
203 | 204 |
204 void ChildProcessHost::ListenerHook::OnChannelError() { | 205 void ChildProcessHost::ListenerHook::OnChannelError() { |
205 host_->opening_channel_ = false; | 206 host_->opening_channel_ = false; |
206 host_->OnChannelError(); | 207 host_->OnChannelError(); |
207 | 208 |
208 for (size_t i = 0; i < host_->filters_.size(); ++i) | 209 for (size_t i = 0; i < host_->filters_.size(); ++i) |
209 host_->filters_[i]->OnChannelError(); | 210 host_->filters_[i]->OnChannelError(); |
210 | 211 |
211 // This will delete host_, which will also destroy this! | 212 // This will delete host_, which will also destroy this! |
212 host_->OnChildDied(); | 213 host_->OnChildDied(); |
213 } | 214 } |
214 | 215 |
215 void ChildProcessHost::ForceShutdown() { | 216 void ChildProcessHost::ForceShutdown() { |
216 Send(new PluginProcessMsg_Shutdown()); | 217 Send(new PluginProcessMsg_Shutdown()); |
217 } | 218 } |
OLD | NEW |