| 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 "base/third_party/dynamic_annotations/dynamic_annotations.h" | 10 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
| 11 #include "chrome/common/child_process_info.h" | 11 #include "chrome/common/child_process_info.h" |
| 12 #include "chrome/common/chrome_constants.h" | 12 #include "chrome/common/chrome_constants.h" |
| 13 #include "chrome/common/chrome_paths_internal.h" | 13 #include "chrome/common/chrome_paths_internal.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/plugin_messages.h" | 15 #include "content/common/child_process_messages.h" |
| 16 #include "ipc/ipc_logging.h" | 16 #include "ipc/ipc_logging.h" |
| 17 | 17 |
| 18 #if defined(OS_LINUX) | 18 #if defined(OS_LINUX) |
| 19 #include "base/linux_util.h" | 19 #include "base/linux_util.h" |
| 20 #endif // OS_LINUX | 20 #endif // OS_LINUX |
| 21 | 21 |
| 22 ChildProcessHost::ChildProcessHost() | 22 ChildProcessHost::ChildProcessHost() |
| 23 : ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)), | 23 : ALLOW_THIS_IN_INITIALIZER_LIST(listener_(this)), |
| 24 opening_channel_(false) { | 24 opening_channel_(false) { |
| 25 } | 25 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 channel_id_, IPC::Channel::MODE_SERVER, &listener_)); | 122 channel_id_, IPC::Channel::MODE_SERVER, &listener_)); |
| 123 if (!channel_->Connect()) | 123 if (!channel_->Connect()) |
| 124 return false; | 124 return false; |
| 125 | 125 |
| 126 for (size_t i = 0; i < filters_.size(); ++i) | 126 for (size_t i = 0; i < filters_.size(); ++i) |
| 127 filters_[i]->OnFilterAdded(channel_.get()); | 127 filters_[i]->OnFilterAdded(channel_.get()); |
| 128 | 128 |
| 129 // Make sure these messages get sent first. | 129 // Make sure these messages get sent first. |
| 130 #if defined(IPC_MESSAGE_LOG_ENABLED) | 130 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 131 bool enabled = IPC::Logging::GetInstance()->Enabled(); | 131 bool enabled = IPC::Logging::GetInstance()->Enabled(); |
| 132 Send(new PluginProcessMsg_SetIPCLoggingEnabled(enabled)); | 132 Send(new ChildProcessMsg_SetIPCLoggingEnabled(enabled)); |
| 133 #endif | 133 #endif |
| 134 | 134 |
| 135 Send(new PluginProcessMsg_AskBeforeShutdown()); | 135 Send(new ChildProcessMsg_AskBeforeShutdown()); |
| 136 | 136 |
| 137 opening_channel_ = true; | 137 opening_channel_ = true; |
| 138 | 138 |
| 139 return true; | 139 return true; |
| 140 } | 140 } |
| 141 | 141 |
| 142 void ChildProcessHost::InstanceCreated() { | 142 void ChildProcessHost::InstanceCreated() { |
| 143 Notify(NotificationType::CHILD_INSTANCE_CREATED); | 143 Notify(NotificationType::CHILD_INSTANCE_CREATED); |
| 144 } | 144 } |
| 145 | 145 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 #endif | 189 #endif |
| 190 | 190 |
| 191 bool handled = false; | 191 bool handled = false; |
| 192 for (size_t i = 0; i < host_->filters_.size(); ++i) { | 192 for (size_t i = 0; i < host_->filters_.size(); ++i) { |
| 193 if (host_->filters_[i]->OnMessageReceived(msg)) { | 193 if (host_->filters_[i]->OnMessageReceived(msg)) { |
| 194 handled = true; | 194 handled = true; |
| 195 break; | 195 break; |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 if (!handled && msg.type() == PluginProcessHostMsg_ShutdownRequest::ID) { | 199 if (!handled && msg.type() == ChildProcessHostMsg_ShutdownRequest::ID) { |
| 200 if (host_->CanShutdown()) | 200 if (host_->CanShutdown()) |
| 201 host_->Send(new PluginProcessMsg_Shutdown()); | 201 host_->Send(new ChildProcessMsg_Shutdown()); |
| 202 handled = true; | 202 handled = true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 if (!handled) | 205 if (!handled) |
| 206 handled = host_->OnMessageReceived(msg); | 206 handled = host_->OnMessageReceived(msg); |
| 207 | 207 |
| 208 #ifdef IPC_MESSAGE_LOG_ENABLED | 208 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 209 if (logger->Enabled()) | 209 if (logger->Enabled()) |
| 210 logger->OnPostDispatchMessage(msg, host_->channel_id_); | 210 logger->OnPostDispatchMessage(msg, host_->channel_id_); |
| 211 #endif | 211 #endif |
| (...skipping 15 matching lines...) Expand all Loading... |
| 227 host_->OnChannelError(); | 227 host_->OnChannelError(); |
| 228 | 228 |
| 229 for (size_t i = 0; i < host_->filters_.size(); ++i) | 229 for (size_t i = 0; i < host_->filters_.size(); ++i) |
| 230 host_->filters_[i]->OnChannelError(); | 230 host_->filters_[i]->OnChannelError(); |
| 231 | 231 |
| 232 // This will delete host_, which will also destroy this! | 232 // This will delete host_, which will also destroy this! |
| 233 host_->OnChildDied(); | 233 host_->OnChildDied(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void ChildProcessHost::ForceShutdown() { | 236 void ChildProcessHost::ForceShutdown() { |
| 237 Send(new PluginProcessMsg_Shutdown()); | 237 Send(new ChildProcessMsg_Shutdown()); |
| 238 } | 238 } |
| OLD | NEW |