Chromium Code Reviews| 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 <string> | |
|
kinuko
2013/09/30 12:41:17
is this needed?
alecflett
2013/10/01 00:17:04
Yes, IWYU (Include What You Use) says you should #
kinuko
2013/10/01 07:48:11
Oh, ok so this is not really for this change but t
| |
| 8 | |
| 7 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 8 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 12 #include "base/process/kill.h" | 14 #include "base/process/kill.h" |
| 13 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
| 14 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 15 #include "base/threading/thread_local.h" | 17 #include "base/threading/thread_local.h" |
| 16 #include "base/tracked_objects.h" | 18 #include "base/tracked_objects.h" |
| 17 #include "components/tracing/child_trace_message_filter.h" | 19 #include "components/tracing/child_trace_message_filter.h" |
| 18 #include "content/child/child_histogram_message_filter.h" | 20 #include "content/child/child_histogram_message_filter.h" |
| 19 #include "content/child/child_process.h" | 21 #include "content/child/child_process.h" |
| 20 #include "content/child/child_resource_message_filter.h" | 22 #include "content/child/child_resource_message_filter.h" |
| 21 #include "content/child/fileapi/file_system_dispatcher.h" | 23 #include "content/child/fileapi/file_system_dispatcher.h" |
| 22 #include "content/child/power_monitor_broadcast_source.h" | 24 #include "content/child/power_monitor_broadcast_source.h" |
| 23 #include "content/child/quota_dispatcher.h" | 25 #include "content/child/quota_dispatcher.h" |
| 24 #include "content/child/quota_message_filter.h" | 26 #include "content/child/quota_message_filter.h" |
| 25 #include "content/child/resource_dispatcher.h" | 27 #include "content/child/resource_dispatcher.h" |
| 28 #include "content/child/service_worker/service_worker_dispatcher.h" | |
| 29 #include "content/child/service_worker/service_worker_message_filter.h" | |
| 26 #include "content/child/socket_stream_dispatcher.h" | 30 #include "content/child/socket_stream_dispatcher.h" |
| 27 #include "content/child/thread_safe_sender.h" | 31 #include "content/child/thread_safe_sender.h" |
| 28 #include "content/child/websocket_dispatcher.h" | 32 #include "content/child/websocket_dispatcher.h" |
| 29 #include "content/common/child_process_messages.h" | 33 #include "content/common/child_process_messages.h" |
| 30 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
| 31 #include "ipc/ipc_logging.h" | 35 #include "ipc/ipc_logging.h" |
| 32 #include "ipc/ipc_switches.h" | 36 #include "ipc/ipc_switches.h" |
| 33 #include "ipc/ipc_sync_channel.h" | 37 #include "ipc/ipc_sync_channel.h" |
| 34 #include "ipc/ipc_sync_message_filter.h" | 38 #include "ipc/ipc_sync_message_filter.h" |
| 35 #include "webkit/glue/webkit_glue.h" | 39 #include "webkit/glue/webkit_glue.h" |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 | 151 |
| 148 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 152 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
| 149 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 153 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
| 150 websocket_dispatcher_.reset(new WebSocketDispatcher); | 154 websocket_dispatcher_.reset(new WebSocketDispatcher); |
| 151 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 155 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
| 152 | 156 |
| 153 histogram_message_filter_ = new ChildHistogramMessageFilter(); | 157 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
| 154 resource_message_filter_ = | 158 resource_message_filter_ = |
| 155 new ChildResourceMessageFilter(resource_dispatcher()); | 159 new ChildResourceMessageFilter(resource_dispatcher()); |
| 156 | 160 |
| 161 service_worker_message_filter_ = | |
| 162 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); | |
| 163 service_worker_dispatcher_.reset(new ServiceWorkerDispatcher( | |
| 164 thread_safe_sender_.get(), service_worker_message_filter_)); | |
| 165 | |
| 157 quota_message_filter_ = | 166 quota_message_filter_ = |
| 158 new QuotaMessageFilter(thread_safe_sender_.get()); | 167 new QuotaMessageFilter(thread_safe_sender_.get()); |
| 159 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), | 168 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), |
| 160 quota_message_filter_.get())); | 169 quota_message_filter_.get())); |
| 161 | 170 |
| 162 channel_->AddFilter(histogram_message_filter_.get()); | 171 channel_->AddFilter(histogram_message_filter_.get()); |
| 163 channel_->AddFilter(sync_message_filter_.get()); | 172 channel_->AddFilter(sync_message_filter_.get()); |
| 164 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 173 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
| 165 ChildProcess::current()->io_message_loop_proxy())); | 174 ChildProcess::current()->io_message_loop_proxy())); |
| 166 channel_->AddFilter(resource_message_filter_.get()); | 175 channel_->AddFilter(resource_message_filter_.get()); |
| 167 channel_->AddFilter(quota_message_filter_.get()); | 176 channel_->AddFilter(quota_message_filter_.get()); |
| 177 channel_->AddFilter(service_worker_message_filter_.get()); | |
| 168 | 178 |
| 169 // In single process mode we may already have a power monitor | 179 // In single process mode we may already have a power monitor |
| 170 if (!base::PowerMonitor::Get()) { | 180 if (!base::PowerMonitor::Get()) { |
| 171 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( | 181 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( |
| 172 new PowerMonitorBroadcastSource()); | 182 new PowerMonitorBroadcastSource()); |
| 173 channel_->AddFilter(power_monitor_source->GetMessageFilter()); | 183 channel_->AddFilter(power_monitor_source->GetMessageFilter()); |
| 174 | 184 |
| 175 power_monitor_.reset(new base::PowerMonitor( | 185 power_monitor_.reset(new base::PowerMonitor( |
| 176 power_monitor_source.PassAs<base::PowerMonitorSource>())); | 186 power_monitor_source.PassAs<base::PowerMonitorSource>())); |
| 177 } | 187 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 214 ::GetHeapProfile)); | 224 ::GetHeapProfile)); |
| 215 #endif | 225 #endif |
| 216 } | 226 } |
| 217 | 227 |
| 218 ChildThread::~ChildThread() { | 228 ChildThread::~ChildThread() { |
| 219 #ifdef IPC_MESSAGE_LOG_ENABLED | 229 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 220 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 230 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
| 221 #endif | 231 #endif |
| 222 | 232 |
| 223 channel_->RemoveFilter(quota_message_filter_.get()); | 233 channel_->RemoveFilter(quota_message_filter_.get()); |
| 234 channel_->RemoveFilter(service_worker_message_filter_.get()); | |
| 224 channel_->RemoveFilter(histogram_message_filter_.get()); | 235 channel_->RemoveFilter(histogram_message_filter_.get()); |
| 225 channel_->RemoveFilter(sync_message_filter_.get()); | 236 channel_->RemoveFilter(sync_message_filter_.get()); |
| 226 | 237 |
| 227 // The ChannelProxy object caches a pointer to the IPC thread, so need to | 238 // The ChannelProxy object caches a pointer to the IPC thread, so need to |
| 228 // reset it as it's not guaranteed to outlive this object. | 239 // reset it as it's not guaranteed to outlive this object. |
| 229 // NOTE: this also has the side-effect of not closing the main IPC channel to | 240 // NOTE: this also has the side-effect of not closing the main IPC channel to |
| 230 // the browser process. This is needed because this is the signal that the | 241 // the browser process. This is needed because this is the signal that the |
| 231 // browser uses to know that this process has died, so we need it to be alive | 242 // browser uses to know that this process has died, so we need it to be alive |
| 232 // until this process is shut down, and the OS closes the handle | 243 // until this process is shut down, and the OS closes the handle |
| 233 // automatically. We used to watch the object handle on Windows to do this, | 244 // automatically. We used to watch the object handle on Windows to do this, |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 435 // inflight that would addref it. | 446 // inflight that would addref it. |
| 436 Send(new ChildProcessHostMsg_ShutdownRequest); | 447 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 437 } | 448 } |
| 438 | 449 |
| 439 void ChildThread::EnsureConnected() { | 450 void ChildThread::EnsureConnected() { |
| 440 LOG(INFO) << "ChildThread::EnsureConnected()"; | 451 LOG(INFO) << "ChildThread::EnsureConnected()"; |
| 441 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 452 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
| 442 } | 453 } |
| 443 | 454 |
| 444 } // namespace content | 455 } // namespace content |
| OLD | NEW |