| 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 #include "content/common/child_process_host.h" | 5 #include "content/common/child_process_host.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 #endif | 126 #endif |
| 127 | 127 |
| 128 Send(new ChildProcessMsg_AskBeforeShutdown()); | 128 Send(new ChildProcessMsg_AskBeforeShutdown()); |
| 129 | 129 |
| 130 opening_channel_ = true; | 130 opening_channel_ = true; |
| 131 | 131 |
| 132 return true; | 132 return true; |
| 133 } | 133 } |
| 134 | 134 |
| 135 void ChildProcessHost::InstanceCreated() { | 135 void ChildProcessHost::InstanceCreated() { |
| 136 Notify(NotificationType::CHILD_INSTANCE_CREATED); | 136 Notify(content::NOTIFICATION_CHILD_INSTANCE_CREATED); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool ChildProcessHost::OnMessageReceived(const IPC::Message& msg) { | 139 bool ChildProcessHost::OnMessageReceived(const IPC::Message& msg) { |
| 140 return false; | 140 return false; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void ChildProcessHost::OnChannelConnected(int32 peer_pid) { | 143 void ChildProcessHost::OnChannelConnected(int32 peer_pid) { |
| 144 } | 144 } |
| 145 | 145 |
| 146 void ChildProcessHost::OnChannelError() { | 146 void ChildProcessHost::OnChannelError() { |
| 147 } | 147 } |
| 148 | 148 |
| 149 bool ChildProcessHost::Send(IPC::Message* message) { | 149 bool ChildProcessHost::Send(IPC::Message* message) { |
| 150 if (!channel_.get()) { | 150 if (!channel_.get()) { |
| 151 delete message; | 151 delete message; |
| 152 return false; | 152 return false; |
| 153 } | 153 } |
| 154 return channel_->Send(message); | 154 return channel_->Send(message); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void ChildProcessHost::OnChildDied() { | 157 void ChildProcessHost::OnChildDied() { |
| 158 delete this; | 158 delete this; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void ChildProcessHost::ShutdownStarted() { | 161 void ChildProcessHost::ShutdownStarted() { |
| 162 } | 162 } |
| 163 | 163 |
| 164 void ChildProcessHost::Notify(NotificationType type) { | 164 void ChildProcessHost::Notify(int type) { |
| 165 } | 165 } |
| 166 | 166 |
| 167 ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host) | 167 ChildProcessHost::ListenerHook::ListenerHook(ChildProcessHost* host) |
| 168 : host_(host) { | 168 : host_(host) { |
| 169 } | 169 } |
| 170 | 170 |
| 171 bool ChildProcessHost::ListenerHook::OnMessageReceived( | 171 bool ChildProcessHost::ListenerHook::OnMessageReceived( |
| 172 const IPC::Message& msg) { | 172 const IPC::Message& msg) { |
| 173 #ifdef IPC_MESSAGE_LOG_ENABLED | 173 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 174 IPC::Logging* logger = IPC::Logging::GetInstance(); | 174 IPC::Logging* logger = IPC::Logging::GetInstance(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 202 if (logger->Enabled()) | 202 if (logger->Enabled()) |
| 203 logger->OnPostDispatchMessage(msg, host_->channel_id_); | 203 logger->OnPostDispatchMessage(msg, host_->channel_id_); |
| 204 #endif | 204 #endif |
| 205 return handled; | 205 return handled; |
| 206 } | 206 } |
| 207 | 207 |
| 208 void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { | 208 void ChildProcessHost::ListenerHook::OnChannelConnected(int32 peer_pid) { |
| 209 host_->opening_channel_ = false; | 209 host_->opening_channel_ = false; |
| 210 host_->OnChannelConnected(peer_pid); | 210 host_->OnChannelConnected(peer_pid); |
| 211 // Notify in the main loop of the connection. | 211 // Notify in the main loop of the connection. |
| 212 host_->Notify(NotificationType::CHILD_PROCESS_HOST_CONNECTED); | 212 host_->Notify(content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED); |
| 213 | 213 |
| 214 for (size_t i = 0; i < host_->filters_.size(); ++i) | 214 for (size_t i = 0; i < host_->filters_.size(); ++i) |
| 215 host_->filters_[i]->OnChannelConnected(peer_pid); | 215 host_->filters_[i]->OnChannelConnected(peer_pid); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void ChildProcessHost::ListenerHook::OnChannelError() { | 218 void ChildProcessHost::ListenerHook::OnChannelError() { |
| 219 host_->opening_channel_ = false; | 219 host_->opening_channel_ = false; |
| 220 host_->OnChannelError(); | 220 host_->OnChannelError(); |
| 221 | 221 |
| 222 for (size_t i = 0; i < host_->filters_.size(); ++i) | 222 for (size_t i = 0; i < host_->filters_.size(); ++i) |
| 223 host_->filters_[i]->OnChannelError(); | 223 host_->filters_[i]->OnChannelError(); |
| 224 | 224 |
| 225 // This will delete host_, which will also destroy this! | 225 // This will delete host_, which will also destroy this! |
| 226 host_->OnChildDied(); | 226 host_->OnChildDied(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void ChildProcessHost::ForceShutdown() { | 229 void ChildProcessHost::ForceShutdown() { |
| 230 Send(new ChildProcessMsg_Shutdown()); | 230 Send(new ChildProcessMsg_Shutdown()); |
| 231 } | 231 } |
| OLD | NEW |