OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/browser/child_process_host.h" | 5 #include "chrome/browser/child_process_host.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)), | 73 ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)), |
74 resource_dispatcher_host_(resource_dispatcher_host), | 74 resource_dispatcher_host_(resource_dispatcher_host), |
75 opening_channel_(false) { | 75 opening_channel_(false) { |
76 Singleton<ChildProcessList>::get()->push_back(this); | 76 Singleton<ChildProcessList>::get()->push_back(this); |
77 } | 77 } |
78 | 78 |
79 | 79 |
80 ChildProcessHost::~ChildProcessHost() { | 80 ChildProcessHost::~ChildProcessHost() { |
81 Singleton<ChildProcessList>::get()->remove(this); | 81 Singleton<ChildProcessList>::get()->remove(this); |
82 | 82 |
83 resource_dispatcher_host_->CancelRequestsForProcess(id()); | 83 if (resource_dispatcher_host_) |
| 84 resource_dispatcher_host_->CancelRequestsForProcess(id()); |
84 } | 85 } |
85 | 86 |
86 // static | 87 // static |
87 FilePath ChildProcessHost::GetChildPath(bool allow_self) { | 88 FilePath ChildProcessHost::GetChildPath(bool allow_self) { |
88 FilePath child_path; | 89 FilePath child_path; |
89 | 90 |
90 child_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 91 child_path = CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
91 switches::kBrowserSubprocessPath); | 92 switches::kBrowserSubprocessPath); |
92 if (!child_path.empty()) | 93 if (!child_path.empty()) |
93 return child_path; | 94 return child_path; |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 if (msg.type() == IPC_LOGGING_ID) { | 211 if (msg.type() == IPC_LOGGING_ID) { |
211 logger->OnReceivedLoggingMessage(msg); | 212 logger->OnReceivedLoggingMessage(msg); |
212 return; | 213 return; |
213 } | 214 } |
214 | 215 |
215 if (logger->Enabled()) | 216 if (logger->Enabled()) |
216 logger->OnPreDispatchMessage(msg); | 217 logger->OnPreDispatchMessage(msg); |
217 #endif | 218 #endif |
218 | 219 |
219 bool msg_is_ok = true; | 220 bool msg_is_ok = true; |
220 bool handled = host_->resource_dispatcher_host_->OnMessageReceived( | 221 bool handled = false; |
221 msg, host_, &msg_is_ok); | 222 |
| 223 if (host_->resource_dispatcher_host_) |
| 224 host_->resource_dispatcher_host_->OnMessageReceived( |
| 225 msg, host_, &msg_is_ok); |
222 | 226 |
223 if (!handled) { | 227 if (!handled) { |
224 if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { | 228 if (msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { |
225 // Must remove the process from the list now, in case it gets used for a | 229 // Must remove the process from the list now, in case it gets used for a |
226 // new instance before our watcher tells us that the process terminated. | 230 // new instance before our watcher tells us that the process terminated. |
227 Singleton<ChildProcessList>::get()->remove(host_); | 231 Singleton<ChildProcessList>::get()->remove(host_); |
228 if (host_->CanShutdown()) | 232 if (host_->CanShutdown()) |
229 host_->Send(new PluginProcessMsg_Shutdown()); | 233 host_->Send(new PluginProcessMsg_Shutdown()); |
230 } else { | 234 } else { |
231 host_->OnMessageReceived(msg); | 235 host_->OnMessageReceived(msg); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 306 |
303 return *iterator_; | 307 return *iterator_; |
304 } while (true); | 308 } while (true); |
305 | 309 |
306 return NULL; | 310 return NULL; |
307 } | 311 } |
308 | 312 |
309 bool ChildProcessHost::Iterator::Done() { | 313 bool ChildProcessHost::Iterator::Done() { |
310 return iterator_ == Singleton<ChildProcessList>::get()->end(); | 314 return iterator_ == Singleton<ChildProcessList>::get()->end(); |
311 } | 315 } |
OLD | NEW |