Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(838)

Side by Side Diff: content/common/child_thread.cc

Issue 8588023: Collect profiler stats from browser child processes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/common/child_thread.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h"
7 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/process.h"
10 #include "base/process_util.h"
8 #include "base/string_util.h" 11 #include "base/string_util.h"
9 #include "base/command_line.h" 12 #include "base/tracked_objects.h"
10 #include "content/common/child_process.h" 13 #include "content/common/child_process.h"
11 #include "content/common/child_process_messages.h" 14 #include "content/common/child_process_messages.h"
12 #include "content/common/child_trace_message_filter.h" 15 #include "content/common/child_trace_message_filter.h"
13 #include "content/common/file_system/file_system_dispatcher.h" 16 #include "content/common/file_system/file_system_dispatcher.h"
14 #include "content/common/quota_dispatcher.h" 17 #include "content/common/quota_dispatcher.h"
15 #include "content/common/resource_dispatcher.h" 18 #include "content/common/resource_dispatcher.h"
16 #include "content/common/socket_stream_dispatcher.h" 19 #include "content/common/socket_stream_dispatcher.h"
17 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
18 #include "ipc/ipc_logging.h" 21 #include "ipc/ipc_logging.h"
19 #include "ipc/ipc_sync_channel.h" 22 #include "ipc/ipc_sync_channel.h"
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 return true; 179 return true;
177 180
178 bool handled = true; 181 bool handled = true;
179 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg) 182 IPC_BEGIN_MESSAGE_MAP(ChildThread, msg)
180 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown) 183 IPC_MESSAGE_HANDLER(ChildProcessMsg_AskBeforeShutdown, OnAskBeforeShutdown)
181 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 184 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
182 #if defined(IPC_MESSAGE_LOG_ENABLED) 185 #if defined(IPC_MESSAGE_LOG_ENABLED)
183 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 186 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
184 OnSetIPCLoggingEnabled) 187 OnSetIPCLoggingEnabled)
185 #endif 188 #endif
189 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus,
190 OnSetProfilerStatus)
191 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
192 OnGetChildProfilerData)
186 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) 193 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles)
187 IPC_MESSAGE_UNHANDLED(handled = false) 194 IPC_MESSAGE_UNHANDLED(handled = false)
188 IPC_END_MESSAGE_MAP() 195 IPC_END_MESSAGE_MAP()
189 196
190 if (handled) 197 if (handled)
191 return true; 198 return true;
192 199
193 if (msg.routing_id() == MSG_ROUTING_CONTROL) 200 if (msg.routing_id() == MSG_ROUTING_CONTROL)
194 return OnControlMessageReceived(msg); 201 return OnControlMessageReceived(msg);
195 202
(...skipping 14 matching lines...) Expand all
210 217
211 #if defined(IPC_MESSAGE_LOG_ENABLED) 218 #if defined(IPC_MESSAGE_LOG_ENABLED)
212 void ChildThread::OnSetIPCLoggingEnabled(bool enable) { 219 void ChildThread::OnSetIPCLoggingEnabled(bool enable) {
213 if (enable) 220 if (enable)
214 IPC::Logging::GetInstance()->Enable(); 221 IPC::Logging::GetInstance()->Enable();
215 else 222 else
216 IPC::Logging::GetInstance()->Disable(); 223 IPC::Logging::GetInstance()->Disable();
217 } 224 }
218 #endif // IPC_MESSAGE_LOG_ENABLED 225 #endif // IPC_MESSAGE_LOG_ENABLED
219 226
227 void ChildThread::OnSetProfilerStatus(bool enable) {
228 tracked_objects::ThreadData::InitializeAndSetTrackingStatus(enable);
229 }
230
231 void ChildThread::OnGetChildProfilerData(
232 int sequence_number,
233 const std::string& process_type) {
234 scoped_ptr<base::DictionaryValue> value(
235 tracked_objects::ThreadData::ToValue());
236 value->SetString("process_type", process_type);
237 value->SetInteger("process_id", base::GetCurrentProcId());
238
239 Send(new ChildProcessHostMsg_ChildProfilerData(
240 sequence_number, *value.get()));
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
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 }
OLDNEW
« no previous file with comments | « content/common/child_thread.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698