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/file_system/file_system_dispatcher.h" | 13 #include "content/common/file_system/file_system_dispatcher.h" |
14 #include "content/common/notification_service.h" | |
15 #include "content/common/quota_dispatcher.h" | 14 #include "content/common/quota_dispatcher.h" |
16 #include "content/common/resource_dispatcher.h" | 15 #include "content/common/resource_dispatcher.h" |
17 #include "content/common/socket_stream_dispatcher.h" | 16 #include "content/common/socket_stream_dispatcher.h" |
18 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
19 #include "ipc/ipc_logging.h" | 18 #include "ipc/ipc_logging.h" |
20 #include "ipc/ipc_sync_channel.h" | 19 #include "ipc/ipc_sync_channel.h" |
21 #include "ipc/ipc_sync_message_filter.h" | 20 #include "ipc/ipc_sync_message_filter.h" |
22 #include "ipc/ipc_switches.h" | 21 #include "ipc/ipc_switches.h" |
23 #include "webkit/glue/webkit_glue.h" | 22 #include "webkit/glue/webkit_glue.h" |
24 | 23 |
(...skipping 26 matching lines...) Expand all Loading... |
51 | 50 |
52 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 51 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
53 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 52 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
54 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 53 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
55 quota_dispatcher_.reset(new QuotaDispatcher()); | 54 quota_dispatcher_.reset(new QuotaDispatcher()); |
56 | 55 |
57 sync_message_filter_ = | 56 sync_message_filter_ = |
58 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 57 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
59 channel_->AddFilter(sync_message_filter_.get()); | 58 channel_->AddFilter(sync_message_filter_.get()); |
60 channel_->AddFilter(new ChildTraceMessageFilter()); | 59 channel_->AddFilter(new ChildTraceMessageFilter()); |
61 | |
62 // When running in unit tests, there is already a NotificationService object. | |
63 // Since only one can exist at a time per thread, check first. | |
64 if (!NotificationService::current()) | |
65 notification_service_.reset(new NotificationService); | |
66 } | 60 } |
67 | 61 |
68 ChildThread::~ChildThread() { | 62 ChildThread::~ChildThread() { |
69 #ifdef IPC_MESSAGE_LOG_ENABLED | 63 #ifdef IPC_MESSAGE_LOG_ENABLED |
70 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 64 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
71 #endif | 65 #endif |
72 | 66 |
73 channel_->RemoveFilter(sync_message_filter_.get()); | 67 channel_->RemoveFilter(sync_message_filter_.get()); |
74 | 68 |
75 // Close this channel before resetting the message loop attached to it so | 69 // Close this channel before resetting the message loop attached to it so |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 MessageLoop::current()->Quit(); | 240 MessageLoop::current()->Quit(); |
247 return; | 241 return; |
248 } | 242 } |
249 | 243 |
250 // The child process shutdown sequence is a request response based mechanism, | 244 // The child process shutdown sequence is a request response based mechanism, |
251 // where we send out an initial feeler request to the child process host | 245 // where we send out an initial feeler request to the child process host |
252 // instance in the browser to verify if it's ok to shutdown the child process. | 246 // instance in the browser to verify if it's ok to shutdown the child process. |
253 // The browser then sends back a response if it's ok to shutdown. | 247 // The browser then sends back a response if it's ok to shutdown. |
254 Send(new ChildProcessHostMsg_ShutdownRequest); | 248 Send(new ChildProcessHostMsg_ShutdownRequest); |
255 } | 249 } |
OLD | NEW |