| 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/common/child_thread.h" | 5 #include "content/common/child_thread.h" |
| 6 | 6 |
| 7 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/process.h" | 10 #include "base/process.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/tracked_objects.h" | 12 #include "base/tracked_objects.h" |
| 13 #include "content/common/child_histogram_message_filter.h" |
| 13 #include "content/common/child_process.h" | 14 #include "content/common/child_process.h" |
| 14 #include "content/common/child_process_messages.h" | 15 #include "content/common/child_process_messages.h" |
| 15 #include "content/common/child_trace_message_filter.h" | 16 #include "content/common/child_trace_message_filter.h" |
| 16 #include "content/common/fileapi/file_system_dispatcher.h" | 17 #include "content/common/fileapi/file_system_dispatcher.h" |
| 17 #include "content/common/quota_dispatcher.h" | 18 #include "content/common/quota_dispatcher.h" |
| 18 #include "content/common/resource_dispatcher.h" | 19 #include "content/common/resource_dispatcher.h" |
| 19 #include "content/common/socket_stream_dispatcher.h" | 20 #include "content/common/socket_stream_dispatcher.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "ipc/ipc_logging.h" | 22 #include "ipc/ipc_logging.h" |
| 22 #include "ipc/ipc_switches.h" | 23 #include "ipc/ipc_switches.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 53 IPC::Logging::GetInstance()->SetIPCSender(this); | 54 IPC::Logging::GetInstance()->SetIPCSender(this); |
| 54 #endif | 55 #endif |
| 55 | 56 |
| 56 resource_dispatcher_.reset(new ResourceDispatcher(this)); | 57 resource_dispatcher_.reset(new ResourceDispatcher(this)); |
| 57 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); | 58 socket_stream_dispatcher_.reset(new SocketStreamDispatcher()); |
| 58 file_system_dispatcher_.reset(new FileSystemDispatcher()); | 59 file_system_dispatcher_.reset(new FileSystemDispatcher()); |
| 59 quota_dispatcher_.reset(new QuotaDispatcher()); | 60 quota_dispatcher_.reset(new QuotaDispatcher()); |
| 60 | 61 |
| 61 sync_message_filter_ = | 62 sync_message_filter_ = |
| 62 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); | 63 new IPC::SyncMessageFilter(ChildProcess::current()->GetShutDownEvent()); |
| 64 histogram_message_filter_ = new content::ChildHistogramMessageFilter(); |
| 65 |
| 66 channel_->AddFilter(histogram_message_filter_.get()); |
| 63 channel_->AddFilter(sync_message_filter_.get()); | 67 channel_->AddFilter(sync_message_filter_.get()); |
| 64 channel_->AddFilter(new ChildTraceMessageFilter()); | 68 channel_->AddFilter(new ChildTraceMessageFilter()); |
| 65 } | 69 } |
| 66 | 70 |
| 67 ChildThread::~ChildThread() { | 71 ChildThread::~ChildThread() { |
| 68 #ifdef IPC_MESSAGE_LOG_ENABLED | 72 #ifdef IPC_MESSAGE_LOG_ENABLED |
| 69 IPC::Logging::GetInstance()->SetIPCSender(NULL); | 73 IPC::Logging::GetInstance()->SetIPCSender(NULL); |
| 70 #endif | 74 #endif |
| 71 | 75 |
| 76 channel_->RemoveFilter(histogram_message_filter_.get()); |
| 72 channel_->RemoveFilter(sync_message_filter_.get()); | 77 channel_->RemoveFilter(sync_message_filter_.get()); |
| 73 | 78 |
| 74 // The ChannelProxy object caches a pointer to the IPC thread, so need to | 79 // The ChannelProxy object caches a pointer to the IPC thread, so need to |
| 75 // reset it as it's not guaranteed to outlive this object. | 80 // reset it as it's not guaranteed to outlive this object. |
| 76 // NOTE: this also has the side-effect of not closing the main IPC channel to | 81 // NOTE: this also has the side-effect of not closing the main IPC channel to |
| 77 // the browser process. This is needed because this is the signal that the | 82 // the browser process. This is needed because this is the signal that the |
| 78 // browser uses to know that this process has died, so we need it to be alive | 83 // browser uses to know that this process has died, so we need it to be alive |
| 79 // until this process is shut down, and the OS closes the handle | 84 // until this process is shut down, and the OS closes the handle |
| 80 // automatically. We used to watch the object handle on Windows to do this, | 85 // automatically. We used to watch the object handle on Windows to do this, |
| 81 // but it wasn't possible to do so on POSIX. | 86 // but it wasn't possible to do so on POSIX. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 } | 277 } |
| 273 | 278 |
| 274 // The child process shutdown sequence is a request response based mechanism, | 279 // The child process shutdown sequence is a request response based mechanism, |
| 275 // where we send out an initial feeler request to the child process host | 280 // where we send out an initial feeler request to the child process host |
| 276 // instance in the browser to verify if it's ok to shutdown the child process. | 281 // instance in the browser to verify if it's ok to shutdown the child process. |
| 277 // The browser then sends back a response if it's ok to shutdown. This avoids | 282 // The browser then sends back a response if it's ok to shutdown. This avoids |
| 278 // race conditions if the process refcount is 0 but there's an IPC message | 283 // race conditions if the process refcount is 0 but there's an IPC message |
| 279 // inflight that would addref it. | 284 // inflight that would addref it. |
| 280 Send(new ChildProcessHostMsg_ShutdownRequest); | 285 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 281 } | 286 } |
| OLD | NEW |