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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 177 |
174 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 178 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
175 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 179 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
176 websocket_dispatcher_.reset(new WebSocketDispatcher); | 180 websocket_dispatcher_.reset(new WebSocketDispatcher); |
177 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 181 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
178 | 182 |
179 histogram_message_filter_ = new ChildHistogramMessageFilter(); | 183 histogram_message_filter_ = new ChildHistogramMessageFilter(); |
180 resource_message_filter_ = | 184 resource_message_filter_ = |
181 new ChildResourceMessageFilter(resource_dispatcher()); | 185 new ChildResourceMessageFilter(resource_dispatcher()); |
182 | 186 |
| 187 service_worker_message_filter_ = |
| 188 new ServiceWorkerMessageFilter(thread_safe_sender_.get()); |
| 189 service_worker_dispatcher_.reset(new ServiceWorkerDispatcher( |
| 190 thread_safe_sender_.get(), service_worker_message_filter_)); |
| 191 |
183 quota_message_filter_ = | 192 quota_message_filter_ = |
184 new QuotaMessageFilter(thread_safe_sender_.get()); | 193 new QuotaMessageFilter(thread_safe_sender_.get()); |
185 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), | 194 quota_dispatcher_.reset(new QuotaDispatcher(thread_safe_sender_.get(), |
186 quota_message_filter_.get())); | 195 quota_message_filter_.get())); |
187 | 196 |
188 channel_->AddFilter(histogram_message_filter_.get()); | 197 channel_->AddFilter(histogram_message_filter_.get()); |
189 channel_->AddFilter(sync_message_filter_.get()); | 198 channel_->AddFilter(sync_message_filter_.get()); |
190 channel_->AddFilter(new tracing::ChildTraceMessageFilter( | 199 channel_->AddFilter(new tracing::ChildTraceMessageFilter( |
191 ChildProcess::current()->io_message_loop_proxy())); | 200 ChildProcess::current()->io_message_loop_proxy())); |
192 channel_->AddFilter(resource_message_filter_.get()); | 201 channel_->AddFilter(resource_message_filter_.get()); |
193 channel_->AddFilter(quota_message_filter_.get()); | 202 channel_->AddFilter(quota_message_filter_.get()); |
| 203 channel_->AddFilter(service_worker_message_filter_.get()); |
194 | 204 |
195 // In single process mode we may already have a power monitor | 205 // In single process mode we may already have a power monitor |
196 if (!base::PowerMonitor::Get()) { | 206 if (!base::PowerMonitor::Get()) { |
197 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( | 207 scoped_ptr<PowerMonitorBroadcastSource> power_monitor_source( |
198 new PowerMonitorBroadcastSource()); | 208 new PowerMonitorBroadcastSource()); |
199 channel_->AddFilter(power_monitor_source->GetMessageFilter()); | 209 channel_->AddFilter(power_monitor_source->GetMessageFilter()); |
200 | 210 |
201 power_monitor_.reset(new base::PowerMonitor( | 211 power_monitor_.reset(new base::PowerMonitor( |
202 power_monitor_source.PassAs<base::PowerMonitorSource>())); | 212 power_monitor_source.PassAs<base::PowerMonitorSource>())); |
203 } | 213 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 ::GetHeapProfile)); | 256 ::GetHeapProfile)); |
247 #endif | 257 #endif |
248 } | 258 } |
249 | 259 |
250 ChildThread::~ChildThread() { | 260 ChildThread::~ChildThread() { |
251 #ifdef IPC_MESSAGE_LOG_ENABLED | 261 #ifdef IPC_MESSAGE_LOG_ENABLED |
252 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 262 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
253 #endif | 263 #endif |
254 | 264 |
255 channel_->RemoveFilter(quota_message_filter_.get()); | 265 channel_->RemoveFilter(quota_message_filter_.get()); |
| 266 channel_->RemoveFilter(service_worker_message_filter_.get()); |
256 channel_->RemoveFilter(histogram_message_filter_.get()); | 267 channel_->RemoveFilter(histogram_message_filter_.get()); |
257 channel_->RemoveFilter(sync_message_filter_.get()); | 268 channel_->RemoveFilter(sync_message_filter_.get()); |
258 | 269 |
259 // The ChannelProxy object caches a pointer to the IPC thread, so need to | 270 // The ChannelProxy object caches a pointer to the IPC thread, so need to |
260 // reset it as it's not guaranteed to outlive this object. | 271 // reset it as it's not guaranteed to outlive this object. |
261 // NOTE: this also has the side-effect of not closing the main IPC channel to | 272 // NOTE: this also has the side-effect of not closing the main IPC channel to |
262 // the browser process. This is needed because this is the signal that the | 273 // the browser process. This is needed because this is the signal that the |
263 // browser uses to know that this process has died, so we need it to be alive | 274 // browser uses to know that this process has died, so we need it to be alive |
264 // until this process is shut down, and the OS closes the handle | 275 // until this process is shut down, and the OS closes the handle |
265 // automatically. We used to watch the object handle on Windows to do this, | 276 // automatically. We used to watch the object handle on Windows to do this, |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 // inflight that would addref it. | 487 // inflight that would addref it. |
477 Send(new ChildProcessHostMsg_ShutdownRequest); | 488 Send(new ChildProcessHostMsg_ShutdownRequest); |
478 } | 489 } |
479 | 490 |
480 void ChildThread::EnsureConnected() { | 491 void ChildThread::EnsureConnected() { |
481 LOG(INFO) << "ChildThread::EnsureConnected()"; | 492 LOG(INFO) << "ChildThread::EnsureConnected()"; |
482 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 493 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
483 } | 494 } |
484 | 495 |
485 } // namespace content | 496 } // namespace content |
OLD | NEW |