| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/child/child_thread.h" | 5 #include "content/child/child_thread.h" |
| 6 | 6 |
| 7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
| 8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/process/kill.h" | 12 #include "base/process/kill.h" |
| 13 #include "base/process/process_handle.h" | 13 #include "base/process/process_handle.h" |
| 14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 15 #include "base/threading/thread_local.h" | 15 #include "base/threading/thread_local.h" |
| 16 #include "base/tracked_objects.h" | 16 #include "base/tracked_objects.h" |
| 17 #include "components/tracing/child_trace_message_filter.h" | 17 #include "components/tracing/child_trace_message_filter.h" |
| 18 #include "content/child/child_histogram_message_filter.h" | 18 #include "content/child/child_histogram_message_filter.h" |
| 19 #include "content/child/child_process.h" | 19 #include "content/child/child_process.h" |
| 20 #include "content/child/child_resource_message_filter.h" | 20 #include "content/child/child_resource_message_filter.h" |
| 21 #include "content/child/fileapi/file_system_dispatcher.h" | 21 #include "content/child/fileapi/file_system_dispatcher.h" |
| 22 #include "content/child/power_monitor_broadcast_source.h" | 22 #include "content/child/power_monitor_broadcast_source.h" |
| 23 #include "content/child/quota_dispatcher.h" | 23 #include "content/child/quota_dispatcher.h" |
| 24 #include "content/child/quota_message_filter.h" | 24 #include "content/child/quota_message_filter.h" |
| 25 #include "content/child/resource_dispatcher.h" | 25 #include "content/child/resource_dispatcher.h" |
| 26 #include "content/child/socket_stream_dispatcher.h" | 26 #include "content/child/socket_stream_dispatcher.h" |
| 27 #include "content/child/thread_safe_sender.h" | 27 #include "content/child/thread_safe_sender.h" |
| 28 #include "content/child/websocket_dispatcher.h" |
| 28 #include "content/common/child_process_messages.h" | 29 #include "content/common/child_process_messages.h" |
| 29 #include "content/public/common/content_switches.h" | 30 #include "content/public/common/content_switches.h" |
| 30 #include "ipc/ipc_logging.h" | 31 #include "ipc/ipc_logging.h" |
| 31 #include "ipc/ipc_switches.h" | 32 #include "ipc/ipc_switches.h" |
| 32 #include "ipc/ipc_sync_channel.h" | 33 #include "ipc/ipc_sync_channel.h" |
| 33 #include "ipc/ipc_sync_message_filter.h" | 34 #include "ipc/ipc_sync_message_filter.h" |
| 34 #include "webkit/glue/webkit_glue.h" | 35 #include "webkit/glue/webkit_glue.h" |
| 35 | 36 |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 #include "content/common/handle_enumerator_win.h" | 38 #include "content/common/handle_enumerator_win.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 IPC::Logging::GetInstance()->SetIPCSender(this); | 140 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 140 #endif | 141 #endif |
| 141 | 142 |
| 142 sync_message_filter_ = | 143 sync_message_filter_ = |
| 143 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 144 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
| 144 thread_safe_sender_ = new ThreadSafeSender( | 145 thread_safe_sender_ = new ThreadSafeSender( |
| 145 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); | 146 base::MessageLoopProxy::current().get(), sync_message_filter_.get()); |
| 146 | 147 |
| 147 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 148 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
| 148 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 149 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
| 150 websocket_dispatcher_.reset(new WebSocketDispatcher); |
| 149 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 151 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
| 150 | 152 |
| 151 histogram_message_filter_ = new ChildHistogramMessageFilter(); | 153 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
| 152 resource_message_filter_ = | 154 resource_message_filter_ = |
| 153 new ChildResourceMessageFilter(resource_dispatcher()); | 155 new ChildResourceMessageFilter(resource_dispatcher()); |
| 154 | 156 |
| 155 quota_message_filter_ = | 157 quota_message_filter_ = |
| 156 new QuotaMessageFilter(thread_safe_sender_.get()); | 158 new QuotaMessageFilter(thread_safe_sender_.get()); |
| 157 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), | 159 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), |
| 158 quota_message_filter_.get())); | 160 quota_message_filter_.get())); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 #endif | 316 #endif |
| 315 return shared_buf.release(); | 317 return shared_buf.release(); |
| 316 } | 318 } |
| 317 | 319 |
| 318 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { | 320 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { |
| 319 // Resource responses are sent to the resource dispatcher. | 321 // Resource responses are sent to the resource dispatcher. |
| 320 if (resource_dispatcher_->OnMessageReceived(msg)) | 322 if (resource_dispatcher_->OnMessageReceived(msg)) |
| 321 return true; | 323 return true; |
| 322 if (socket_stream_dispatcher_->OnMessageReceived(msg)) | 324 if (socket_stream_dispatcher_->OnMessageReceived(msg)) |
| 323 return true; | 325 return true; |
| 326 if (websocket_dispatcher_->OnMessageReceived(msg)) |
| 327 return true; |
| 324 if (file_system_dispatcher_->OnMessageReceived(msg)) | 328 if (file_system_dispatcher_->OnMessageReceived(msg)) |
| 325 return true; | 329 return true; |
| 326 | 330 |
| 327 bool handled = true; | 331 bool handled = true; |
| 328 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) | 332 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) |
| 329 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) | 333 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) |
| 330 #if defined(IPC_MESSAGE_LOG_ENABLED) | 334 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 331 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, | 335 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, |
| 332 OnSetIPCLoggingEnabled) | 336 OnSetIPCLoggingEnabled) |
| 333 #endif | 337 #endif |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 // inflight that would addref it. | 435 // inflight that would addref it. |
| 432 Send(new ChildProcessHostMsg_ShutdownRequest); | 436 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 433 } | 437 } |
| 434 | 438 |
| 435 void ChildThread::EnsureConnected() { | 439 void ChildThread::EnsureConnected() { |
| 436 LOG(INFO) << "ChildThread::EnsureConnected()"; | 440 LOG(INFO) << "ChildThread::EnsureConnected()"; |
| 437 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 441 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
| 438 } | 442 } |
| 439 | 443 |
| 440 } // namespace content | 444 } // namespace content |
| OLD | NEW |