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" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 // NOTE: this also has the side-effect of not closing the main IPC channel to | 188 // NOTE: this also has the side-effect of not closing the main IPC channel to |
189 // the browser process. This is needed because this is the signal that the | 189 // the browser process. This is needed because this is the signal that the |
190 // browser uses to know that this process has died, so we need it to be alive | 190 // browser uses to know that this process has died, so we need it to be alive |
191 // until this process is shut down, and the OS closes the handle | 191 // until this process is shut down, and the OS closes the handle |
192 // automatically. We used to watch the object handle on Windows to do this, | 192 // automatically. We used to watch the object handle on Windows to do this, |
193 // but it wasn't possible to do so on POSIX. | 193 // but it wasn't possible to do so on POSIX. |
194 channel_->ClearIPCTaskRunner(); | 194 channel_->ClearIPCTaskRunner(); |
195 g_lazy_tls.Pointer()->Set(NULL); | 195 g_lazy_tls.Pointer()->Set(NULL); |
196 } | 196 } |
197 | 197 |
198 void ChildThread::Shutdown() { | |
199 // Delete objects that hold references to blink so derived classes can | |
200 // safely shutdown blink in their Shutdown implementation. | |
201 file_system_dispatcher_.reset(); | |
202 } | |
203 | |
198 void ChildThread::OnChannelConnected(int32 peer_pid) { | 204 void ChildThread::OnChannelConnected(int32 peer_pid) { |
199 channel_connected_factory_.InvalidateWeakPtrs(); | 205 channel_connected_factory_.InvalidateWeakPtrs(); |
200 } | 206 } |
201 | 207 |
202 void ChildThread::OnChannelError() { | 208 void ChildThread::OnChannelError() { |
203 set_on_channel_error_called(true); | 209 set_on_channel_error_called(true); |
204 base::MessageLoop::current()->Quit(); | 210 base::MessageLoop::current()->Quit(); |
205 } | 211 } |
206 | 212 |
207 bool ChildThread::Send(IPC::Message* msg) { | 213 bool ChildThread::Send(IPC::Message* msg) { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 #endif | 275 #endif |
270 return shared_buf.release(); | 276 return shared_buf.release(); |
271 } | 277 } |
272 | 278 |
273 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { | 279 bool ChildThread::OnMessageReceived(const IPC::Message& msg) { |
274 // Resource responses are sent to the resource dispatcher. | 280 // Resource responses are sent to the resource dispatcher. |
275 if (resource_dispatcher_->OnMessageReceived(msg)) | 281 if (resource_dispatcher_->OnMessageReceived(msg)) |
276 return true; | 282 return true; |
277 if (socket_stream_dispatcher_->OnMessageReceived(msg)) | 283 if (socket_stream_dispatcher_->OnMessageReceived(msg)) |
278 return true; | 284 return true; |
279 if (file_system_dispatcher_->OnMessageReceived(msg)) | 285 if (file_system_dispatcher_ && |
jam
2013/07/23 16:44:23
are you sure this can be called after shutdown?
| |
286 file_system_dispatcher_->OnMessageReceived(msg)) | |
280 return true; | 287 return true; |
281 if (quota_dispatcher_->OnMessageReceived(msg)) | 288 if (quota_dispatcher_->OnMessageReceived(msg)) |
282 return true; | 289 return true; |
283 | 290 |
284 bool handled = true; | 291 bool handled = true; |
285 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) | 292 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) |
286 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) | 293 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) |
287 #if defined(IPC_MESSAGE_LOG_ENABLED) | 294 #if defined(IPC_MESSAGE_LOG_ENABLED) |
288 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, | 295 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, |
289 OnSetIPCLoggingEnabled) | 296 OnSetIPCLoggingEnabled) |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
388 // inflight that would addref it. | 395 // inflight that would addref it. |
389 Send(new ChildProcessHostMsg_ShutdownRequest); | 396 Send(new ChildProcessHostMsg_ShutdownRequest); |
390 } | 397 } |
391 | 398 |
392 void ChildThread::EnsureConnected() { | 399 void ChildThread::EnsureConnected() { |
393 LOG(INFO) << "ChildThread::EnsureConnected()"; | 400 LOG(INFO) << "ChildThread::EnsureConnected()"; |
394 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); | 401 base::KillProcess(base::GetCurrentProcessHandle(), 0, false); |
395 } | 402 } |
396 | 403 |
397 } // namespace content | 404 } // namespace content |
OLD | NEW |