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> |
| 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/synchronization/condition_variable.h" | 17 #include "base/synchronization/condition_variable.h" |
16 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
17 #include "base/threading/thread_local.h" | 19 #include "base/threading/thread_local.h" |
18 #include "base/tracked_objects.h" | 20 #include "base/tracked_objects.h" |
19 #include "components/tracing/child_trace_message_filter.h" | 21 #include "components/tracing/child_trace_message_filter.h" |
20 #include "content/child/child_histogram_message_filter.h" | 22 #include "content/child/child_histogram_message_filter.h" |
21 #include "content/child/child_process.h" | 23 #include "content/child/child_process.h" |
22 #include "content/child/child_resource_message_filter.h" | 24 #include "content/child/child_resource_message_filter.h" |
23 #include "content/child/fileapi/file_system_dispatcher.h" | 25 #include "content/child/fileapi/file_system_dispatcher.h" |
24 #include "content/child/power_monitor_broadcast_source.h" | 26 #include "content/child/power_monitor_broadcast_source.h" |
25 #include "content/child/quota_dispatcher.h" | 27 #include "content/child/quota_dispatcher.h" |
26 #include "content/child/quota_message_filter.h" | 28 #include "content/child/quota_message_filter.h" |
27 #include "content/child/resource_dispatcher.h" | 29 #include "content/child/resource_dispatcher.h" |
| 30 #include "content/child/service_worker/service_worker_dispatcher.h" |
| 31 #include "content/child/service_worker/service_worker_message_filter.h" |
28 #include "content/child/socket_stream_dispatcher.h" | 32 #include "content/child/socket_stream_dispatcher.h" |
29 #include "content/child/thread_safe_sender.h" | 33 #include "content/child/thread_safe_sender.h" |
30 #include "content/child/websocket_dispatcher.h" | 34 #include "content/child/websocket_dispatcher.h" |
31 #include "content/common/child_process_messages.h" | 35 #include "content/common/child_process_messages.h" |
32 #include "content/public/common/content_switches.h" | 36 #include "content/public/common/content_switches.h" |
33 #include "ipc/ipc_logging.h" | 37 #include "ipc/ipc_logging.h" |
34 #include "ipc/ipc_switches.h" | 38 #include "ipc/ipc_switches.h" |
35 #include "ipc/ipc_sync_channel.h" | 39 #include "ipc/ipc_sync_channel.h" |
36 #include "ipc/ipc_sync_message_filter.h" | 40 #include "ipc/ipc_sync_message_filter.h" |
37 #include "webkit/glue/webkit_glue.h" | 41 #include "webkit/glue/webkit_glue.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 180 |
177 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 181 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
178 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 182 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
179 websocket_dispatcher_.reset(new WebSocketDispatcher); | 183 websocket_dispatcher_.reset(new WebSocketDispatcher); |
180 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 184 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
181 | 185 |
182 histogram_message_filter_ = new ChildHistogramMessageFilter(); | 186 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
183 resource_message_filter_ = | 187 resource_message_filter_ = |
184 new ChildResourceMessageFilter(resource_dispatcher()); | 188 new ChildResourceMessageFilter(resource_dispatcher()); |
185 | 189 |
| 190 service_worker_message_filter_ = |
| 191 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); |
| 192 service_worker_dispatcher_.reset( |
| 193 new ServiceWorkerDispatcher(thread_safe_sender_.get())); |
| 194 |
186 quota_message_filter_ = | 195 quota_message_filter_ = |
187 new QuotaMessageFilter(thread_safe_sender_.get()); | 196 new QuotaMessageFilter(thread_safe_sender_.get()); |
188 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), | 197 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), |
189 quota_message_filter_.get())); | 198 quota_message_filter_.get())); |
190 | 199 |
191 channel_->AddFilter(histogram_message_filter_.get()); | 200 channel_->AddFilter(histogram_message_filter_.get()); |
192 channel_->AddFilter(sync_message_filter_.get()); | 201 channel_->AddFilter(sync_message_filter_.get()); |
193 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 202 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
194 ChildProcess::current()->io_message_loop_proxy())); | 203 ChildProcess::current()->io_message_loop_proxy())); |
195 channel_->AddFilter(resource_message_filter_.get()); | 204 channel_->AddFilter(resource_message_filter_.get()); |
196 channel_->AddFilter(quota_message_filter_.get()); | 205 channel_->AddFilter(quota_message_filter_.get()); |
| 206 channel_->AddFilter(service_worker_message_filter_.get()); |
197 | 207 |
198 // In single process mode we may already have a power monitor | 208 // In single process mode we may already have a power monitor |
199 if (!base::PowerMonitor::Get()) { | 209 if (!base::PowerMonitor::Get()) { |
200 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( | 210 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( |
201 new PowerMonitorBroadcastSource()); | 211 new PowerMonitorBroadcastSource()); |
202 channel_->AddFilter(power_monitor_source->GetMessageFilter()); | 212 channel_->AddFilter(power_monitor_source->GetMessageFilter()); |
203 | 213 |
204 power_monitor_.reset(new base::PowerMonitor( | 214 power_monitor_.reset(new base::PowerMonitor( |
205 power_monitor_source.PassAs<base::PowerMonitorSource>())); | 215 power_monitor_source.PassAs<base::PowerMonitorSource>())); |
206 } | 216 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 ::HeapProfilerStop, | 258 ::HeapProfilerStop, |
249 ::GetHeapProfile)); | 259 ::GetHeapProfile)); |
250 #endif | 260 #endif |
251 } | 261 } |
252 | 262 |
253 ChildThread::~ChildThread() { | 263 ChildThread::~ChildThread() { |
254 #ifdef IPC_MESSAGE_LOG_ENABLED | 264 #ifdef IPC_MESSAGE_LOG_ENABLED |
255 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 265 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
256 #endif | 266 #endif |
257 | 267 |
| 268 channel_->RemoveFilter(service_worker_message_filter_.get()); |
258 channel_->RemoveFilter(quota_message_filter_.get()); | 269 channel_->RemoveFilter(quota_message_filter_.get()); |
259 channel_->RemoveFilter(histogram_message_filter_.get()); | 270 channel_->RemoveFilter(histogram_message_filter_.get()); |
260 channel_->RemoveFilter(sync_message_filter_.get()); | 271 channel_->RemoveFilter(sync_message_filter_.get()); |
261 | 272 |
262 // The ChannelProxy object caches a pointer to the IPC thread, so need to | 273 // The ChannelProxy object caches a pointer to the IPC thread, so need to |
263 // reset it as it's not guaranteed to outlive this object. | 274 // reset it as it's not guaranteed to outlive this object. |
264 // NOTE: this also has the side-effect of not closing the main IPC channel to | 275 // NOTE: this also has the side-effect of not closing the main IPC channel to |
265 // the browser process. This is needed because this is the signal that the | 276 // the browser process. This is needed because this is the signal that the |
266 // browser uses to know that this process has died, so we need it to be alive | 277 // browser uses to know that this process has died, so we need it to be alive |
267 // until this process is shut down, and the OS closes the handle | 278 // until this process is shut down, and the OS closes the handle |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // inflight that would addref it. | 490 // inflight that would addref it. |
480 Send(new ChildProcessHostMsg_ShutdownRequest); | 491 Send(new ChildProcessHostMsg_ShutdownRequest); |
481 } | 492 } |
482 | 493 |
483 void ChildThread::EnsureConnected() { | 494 void ChildThread::EnsureConnected() { |
484 LOG(INFO) << "ChildThread::EnsureConnected()"; | 495 LOG(INFO) << "ChildThread::EnsureConnected()"; |
485 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 496 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
486 } | 497 } |
487 | 498 |
488 } // namespace content | 499 } // namespace content |
OLD | NEW |