| 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_thread.h" | 5 #include "content/common/child_thread.h" |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "content/common/child_process.h" | 10 #include "content/common/child_process.h" |
| 11 #include "content/common/child_process_messages.h" | 11 #include "content/common/child_process_messages.h" |
| 12 #include "content/common/child_trace_message_filter.h" | 12 #include "content/common/child_trace_message_filter.h" |
| 13 #include "content/common/content_switches.h" | 13 #include "content/common/content_switches.h" |
| 14 #include "content/common/file_system/file_system_dispatcher.h" | 14 #include "content/common/file_system/file_system_dispatcher.h" |
| 15 #include "content/common/notification_service.h" | 15 #include "content/common/notification_service.h" |
| 16 #include "content/common/quota_dispatcher.h" | 16 #include "content/common/quota_dispatcher.h" |
| 17 #include "content/common/resource_dispatcher.h" | 17 #include "content/common/resource_dispatcher.h" |
| 18 #include "content/common/socket_stream_dispatcher.h" | 18 #include "content/common/socket_stream_dispatcher.h" |
| 19 #include "ipc/ipc_logging.h" | 19 #include "ipc/ipc_logging.h" |
| 20 #include "ipc/ipc_sync_channel.h" | 20 #include "ipc/ipc_sync_channel.h" |
| 21 #include "ipc/ipc_sync_message_filter.h" | 21 #include "ipc/ipc_sync_message_filter.h" |
| 22 #include "ipc/ipc_switches.h" | 22 #include "ipc/ipc_switches.h" |
| 23 #include "webkit/glue/webkit_glue.h" | 23 #include "webkit/glue/webkit_glue.h" |
| 24 | 24 |
| 25 #if defined(OS_WIN) |
| 26 #include "content/common/handle_enumerator_win.h" |
| 27 #endif |
| 28 |
| 25 ChildThread::ChildThread() { | 29 ChildThread::ChildThread() { |
| 26 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 30 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 27 switches::kProcessChannelID); | 31 switches::kProcessChannelID); |
| 28 Init(); | 32 Init(); |
| 29 } | 33 } |
| 30 | 34 |
| 31 ChildThread::ChildThread(const std::string& channel_name) | 35 ChildThread::ChildThread(const std::string& channel_name) |
| 32 : channel_name_(channel_name) { | 36 : channel_name_(channel_name) { |
| 33 Init(); | 37 Init(); |
| 34 } | 38 } |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return true; | 155 return true; |
| 152 | 156 |
| 153 bool handled = true; | 157 bool handled = true; |
| 154 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) | 158 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) |
| 155 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown) | 159 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown) |
| 156 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) | 160 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) |
| 157 #if defined(IPC_MESSAGE_LOG_ENABLED) | 161 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 158 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, | 162 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, |
| 159 OnSetIPCLoggingEnabled) | 163 OnSetIPCLoggingEnabled) |
| 160 #endif | 164 #endif |
| 165 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) |
| 161 IPC_MESSAGE_UNHANDLED(handled = false) | 166 IPC_MESSAGE_UNHANDLED(handled = false) |
| 162 IPC_END_MESSAGE_MAP() | 167 IPC_END_MESSAGE_MAP() |
| 163 | 168 |
| 164 if (handled) | 169 if (handled) |
| 165 return true; | 170 return true; |
| 166 | 171 |
| 167 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 172 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
| 168 return OnControlMessageReceived(msg); | 173 return OnControlMessageReceived(msg); |
| 169 | 174 |
| 170 return router_.OnMessageReceived(msg); | 175 return router_.OnMessageReceived(msg); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 184 | 189 |
| 185 #if defined(IPC_MESSAGE_LOG_ENABLED) | 190 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 186 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { | 191 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { |
| 187 if (enable) | 192 if (enable) |
| 188 IPC::Logging::GetInstance()->Enable(); | 193 IPC::Logging::GetInstance()->Enable(); |
| 189 else | 194 else |
| 190 IPC::Logging::GetInstance()->Disable(); | 195 IPC::Logging::GetInstance()->Disable(); |
| 191 } | 196 } |
| 192 #endif // IPC_MESSAGE_LOG_ENABLED | 197 #endif // IPC_MESSAGE_LOG_ENABLED |
| 193 | 198 |
| 199 void ChildThread::OnDumpHandles() { |
| 200 #if defined(OS_WIN) |
| 201 scoped_refptr<content::HandleEnumerator> handle_enum( |
| 202 new content::HandleEnumerator( |
| 203 CommandLine::ForCurrentProcess()->HasSwitch( |
| 204 switches::kAuditAllHandles))); |
| 205 handle_enum->EnumerateHandles(); |
| 206 Send(new ChildProcessHostMsg_DumpHandlesDone); |
| 207 return; |
| 208 #endif |
| 209 |
| 210 NOTIMPLEMENTED(); |
| 211 } |
| 212 |
| 194 ChildThread* ChildThread::current() { | 213 ChildThread* ChildThread::current() { |
| 195 return ChildProcess::current()->main_thread(); | 214 return ChildProcess::current()->main_thread(); |
| 196 } | 215 } |
| 197 | 216 |
| 198 void ChildThread::OnProcessFinalRelease() { | 217 void ChildThread::OnProcessFinalRelease() { |
| 199 if (on_channel_error_called_ || !check_with_browser_before_shutdown_) { | 218 if (on_channel_error_called_ || !check_with_browser_before_shutdown_) { |
| 200 MessageLoop::current()->Quit(); | 219 MessageLoop::current()->Quit(); |
| 201 return; | 220 return; |
| 202 } | 221 } |
| 203 | 222 |
| 204 // The child process shutdown sequence is a request response based mechanism, | 223 // The child process shutdown sequence is a request response based mechanism, |
| 205 // where we send out an initial feeler request to the child process host | 224 // where we send out an initial feeler request to the child process host |
| 206 // instance in the browser to verify if it's ok to shutdown the child process. | 225 // instance in the browser to verify if it's ok to shutdown the child process. |
| 207 // The browser then sends back a response if it's ok to shutdown. | 226 // The browser then sends back a response if it's ok to shutdown. |
| 208 Send(new ChildProcessHostMsg_ShutdownRequest); | 227 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 209 } | 228 } |
| OLD | NEW |