| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process.h" | 9 #include "base/process.h" |
| 10 #include "base/process_util.h" | |
| 11 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 12 #include "base/tracked_objects.h" | 11 #include "base/tracked_objects.h" |
| 13 #include "content/common/child_process.h" | 12 #include "content/common/child_process.h" |
| 14 #include "content/common/child_process_messages.h" | 13 #include "content/common/child_process_messages.h" |
| 15 #include "content/common/child_trace_message_filter.h" | 14 #include "content/common/child_trace_message_filter.h" |
| 16 #include "content/common/fileapi/file_system_dispatcher.h" | 15 #include "content/common/fileapi/file_system_dispatcher.h" |
| 17 #include "content/common/quota_dispatcher.h" | 16 #include "content/common/quota_dispatcher.h" |
| 18 #include "content/common/resource_dispatcher.h" | 17 #include "content/common/resource_dispatcher.h" |
| 19 #include "content/common/socket_stream_dispatcher.h" | 18 #include "content/common/socket_stream_dispatcher.h" |
| 20 #include "content/public/common/content_switches.h" | 19 #include "content/public/common/content_switches.h" |
| 21 #include "ipc/ipc_logging.h" | 20 #include "ipc/ipc_logging.h" |
| 22 #include "ipc/ipc_switches.h" | 21 #include "ipc/ipc_switches.h" |
| 23 #include "ipc/ipc_sync_channel.h" | 22 #include "ipc/ipc_sync_channel.h" |
| 24 #include "ipc/ipc_sync_message_filter.h" | 23 #include "ipc/ipc_sync_message_filter.h" |
| 25 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
| 26 | 25 |
| 27 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 28 #include "content/common/handle_enumerator_win.h" | 27 #include "content/common/handle_enumerator_win.h" |
| 29 #endif | 28 #endif |
| 30 | 29 |
| 30 using tracked_objects::ThreadData; |
| 31 |
| 31 ChildThread::ChildThread() { | 32 ChildThread::ChildThread() { |
| 32 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 33 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 33 switches::kProcessChannelID); | 34 switches::kProcessChannelID); |
| 34 Init(); | 35 Init(); |
| 35 } | 36 } |
| 36 | 37 |
| 37 ChildThread::ChildThread(const std::string& channel_name) | 38 ChildThread::ChildThread(const std::string& channel_name) |
| 38 : channel_name_(channel_name) { | 39 : channel_name_(channel_name) { |
| 39 Init(); | 40 Init(); |
| 40 } | 41 } |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 213 |
| 213 #if defined(IPC_MESSAGE_LOG_ENABLED) | 214 #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 214 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { | 215 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { |
| 215 if (enable) | 216 if (enable) |
| 216 IPC::Logging::GetInstance()->Enable(); | 217 IPC::Logging::GetInstance()->Enable(); |
| 217 else | 218 else |
| 218 IPC::Logging::GetInstance()->Disable(); | 219 IPC::Logging::GetInstance()->Disable(); |
| 219 } | 220 } |
| 220 #endif // IPC_MESSAGE_LOG_ENABLED | 221 #endif // IPC_MESSAGE_LOG_ENABLED |
| 221 | 222 |
| 222 void ChildThread::OnSetProfilerStatus( | 223 void ChildThread::OnSetProfilerStatus(ThreadData::Status status) { |
| 223 tracked_objects::ThreadData::Status status) { | 224 ThreadData::InitializeAndSetTrackingStatus(status); |
| 224 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(status); | |
| 225 } | 225 } |
| 226 | 226 |
| 227 void ChildThread::OnGetChildProfilerData( | 227 void ChildThread::OnGetChildProfilerData(int sequence_number) { |
| 228 int sequence_number, | 228 tracked_objects::ProcessDataSnapshot process_data; |
| 229 const std::string& process_type) { | 229 ThreadData::Snapshot(false, &process_data); |
| 230 scoped_ptr<base::DictionaryValue> value( | |
| 231 tracked_objects::ThreadData::ToValue(false)); | |
| 232 value->SetString("process_type", process_type); | |
| 233 value->SetInteger("process_id", base::GetCurrentProcId()); | |
| 234 | 230 |
| 235 Send(new ChildProcessHostMsg_ChildProfilerData( | 231 Send(new ChildProcessHostMsg_ChildProfilerData(sequence_number, |
| 236 sequence_number, *value.get())); | 232 process_data)); |
| 237 } | 233 } |
| 238 | 234 |
| 239 void ChildThread::OnDumpHandles() { | 235 void ChildThread::OnDumpHandles() { |
| 240 #if defined(OS_WIN) | 236 #if defined(OS_WIN) |
| 241 scoped_refptr<content::HandleEnumerator> handle_enum( | 237 scoped_refptr<content::HandleEnumerator> handle_enum( |
| 242 new content::HandleEnumerator( | 238 new content::HandleEnumerator( |
| 243 CommandLine::ForCurrentProcess()->HasSwitch( | 239 CommandLine::ForCurrentProcess()->HasSwitch( |
| 244 switches::kAuditAllHandles))); | 240 switches::kAuditAllHandles))); |
| 245 handle_enum->EnumerateHandles(); | 241 handle_enum->EnumerateHandles(); |
| 246 Send(new ChildProcessHostMsg_DumpHandlesDone); | 242 Send(new ChildProcessHostMsg_DumpHandlesDone); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 266 } | 262 } |
| 267 | 263 |
| 268 // The child process shutdown sequence is a request response based mechanism, | 264 // The child process shutdown sequence is a request response based mechanism, |
| 269 // where we send out an initial feeler request to the child process host | 265 // where we send out an initial feeler request to the child process host |
| 270 // instance in the browser to verify if it's ok to shutdown the child process. | 266 // instance in the browser to verify if it's ok to shutdown the child process. |
| 271 // The browser then sends back a response if it's ok to shutdown. This avoids | 267 // The browser then sends back a response if it's ok to shutdown. This avoids |
| 272 // race conditions if the process refcount is 0 but there's an IPC message | 268 // race conditions if the process refcount is 0 but there's an IPC message |
| 273 // inflight that would addref it. | 269 // inflight that would addref it. |
| 274 Send(new ChildProcessHostMsg_ShutdownRequest); | 270 Send(new ChildProcessHostMsg_ShutdownRequest); |
| 275 } | 271 } |
| OLD | NEW |