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/bind.h" | |
jam
2011/11/28 15:17:34
nit: not needed?
ramant (doing other things)
2011/11/29 01:32:20
Done.
| |
8 #include "base/command_line.h" | |
9 #include "base/json/json_writer.h" | |
jam
2011/11/28 15:17:34
nit: not needed
ramant (doing other things)
2011/11/29 01:32:20
Done.
| |
7 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/process.h" | |
12 #include "base/process_util.h" | |
8 #include "base/string_util.h" | 13 #include "base/string_util.h" |
9 #include "base/command_line.h" | 14 #include "base/tracked_objects.h" |
10 #include "content/common/child_process.h" | 15 #include "content/common/child_process.h" |
11 #include "content/common/child_process_messages.h" | 16 #include "content/common/child_process_messages.h" |
12 #include "content/common/child_trace_message_filter.h" | 17 #include "content/common/child_trace_message_filter.h" |
13 #include "content/common/file_system/file_system_dispatcher.h" | 18 #include "content/common/file_system/file_system_dispatcher.h" |
14 #include "content/common/quota_dispatcher.h" | 19 #include "content/common/quota_dispatcher.h" |
15 #include "content/common/resource_dispatcher.h" | 20 #include "content/common/resource_dispatcher.h" |
16 #include "content/common/socket_stream_dispatcher.h" | 21 #include "content/common/socket_stream_dispatcher.h" |
17 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
18 #include "ipc/ipc_logging.h" | 23 #include "ipc/ipc_logging.h" |
19 #include "ipc/ipc_sync_channel.h" | 24 #include "ipc/ipc_sync_channel.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 return true; | 181 return true; |
177 | 182 |
178 bool handled = true; | 183 bool handled = true; |
179 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) | 184 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) |
180 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown) | 185 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown) |
181 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) | 186 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) |
182 #if defined(IPC_MESSAGE_LOG_ENABLED) | 187 #if defined(IPC_MESSAGE_LOG_ENABLED) |
183 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, | 188 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, |
184 OnSetIPCLoggingEnabled) | 189 OnSetIPCLoggingEnabled) |
185 #endif | 190 #endif |
191 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, | |
192 OnSetProfilerStatus) | |
193 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, | |
194 OnGetChildProfilerData) | |
186 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) | 195 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) |
187 IPC_MESSAGE_UNHANDLED(handled = false) | 196 IPC_MESSAGE_UNHANDLED(handled = false) |
188 IPC_END_MESSAGE_MAP() | 197 IPC_END_MESSAGE_MAP() |
189 | 198 |
190 if (handled) | 199 if (handled) |
191 return true; | 200 return true; |
192 | 201 |
193 if (msg.routing_id() == MSG_ROUTING_CONTROL) | 202 if (msg.routing_id() == MSG_ROUTING_CONTROL) |
194 return OnControlMessageReceived(msg); | 203 return OnControlMessageReceived(msg); |
195 | 204 |
(...skipping 14 matching lines...) Expand all Loading... | |
210 | 219 |
211 #if defined(IPC_MESSAGE_LOG_ENABLED) | 220 #if defined(IPC_MESSAGE_LOG_ENABLED) |
212 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { | 221 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { |
213 if (enable) | 222 if (enable) |
214 IPC::Logging::GetInstance()->Enable(); | 223 IPC::Logging::GetInstance()->Enable(); |
215 else | 224 else |
216 IPC::Logging::GetInstance()->Disable(); | 225 IPC::Logging::GetInstance()->Disable(); |
217 } | 226 } |
218 #endif // IPC_MESSAGE_LOG_ENABLED | 227 #endif // IPC_MESSAGE_LOG_ENABLED |
219 | 228 |
229 void ChildThread::OnSetProfilerStatus(bool enable) { | |
230 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enable); | |
231 } | |
232 | |
233 void ChildThread::OnGetChildProfilerData( | |
234 int sequence_number, | |
235 const std::string& process_type) { | |
236 base::DictionaryValue* value = tracked_objects::ThreadData::ToValue(); | |
jam
2011/11/28 15:17:34
memory leak of value here
ramant (doing other things)
2011/11/29 01:32:20
many many thanks for catching this (made the mista
| |
237 value->SetString("process_type", process_type); | |
238 value->SetInteger("process_id", base::GetCurrentProcId()); | |
239 | |
240 Send(new ChildProcessHostMsg_ChildProfilerData(sequence_number, *value)); | |
241 } | |
242 | |
220 void ChildThread::OnDumpHandles() { | 243 void ChildThread::OnDumpHandles() { |
221 #if defined(OS_WIN) | 244 #if defined(OS_WIN) |
222 scoped_refptr<content::HandleEnumerator> handle_enum( | 245 scoped_refptr<content::HandleEnumerator> handle_enum( |
223 new content::HandleEnumerator( | 246 new content::HandleEnumerator( |
224 CommandLine::ForCurrentProcess()->HasSwitch( | 247 CommandLine::ForCurrentProcess()->HasSwitch( |
225 switches::kAuditAllHandles))); | 248 switches::kAuditAllHandles))); |
226 handle_enum->EnumerateHandles(); | 249 handle_enum->EnumerateHandles(); |
227 Send(new ChildProcessHostMsg_DumpHandlesDone); | 250 Send(new ChildProcessHostMsg_DumpHandlesDone); |
228 return; | 251 return; |
229 #endif | 252 #endif |
(...skipping 10 matching lines...) Expand all Loading... | |
240 MessageLoop::current()->Quit(); | 263 MessageLoop::current()->Quit(); |
241 return; | 264 return; |
242 } | 265 } |
243 | 266 |
244 // The child process shutdown sequence is a request response based mechanism, | 267 // The child process shutdown sequence is a request response based mechanism, |
245 // where we send out an initial feeler request to the child process host | 268 // where we send out an initial feeler request to the child process host |
246 // instance in the browser to verify if it's ok to shutdown the child process. | 269 // instance in the browser to verify if it's ok to shutdown the child process. |
247 // The browser then sends back a response if it's ok to shutdown. | 270 // The browser then sends back a response if it's ok to shutdown. |
248 Send(new ChildProcessHostMsg_ShutdownRequest); | 271 Send(new ChildProcessHostMsg_ShutdownRequest); |
249 } | 272 } |
OLD | NEW |