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

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

Issue 10041017: Show gpu process stats in about:tcmalloc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address nits, call OnStatsForChildProcess directly from IO thread instead of posting to UI Created 8 years, 8 months 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) 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/string_util.h" 10 #include "base/string_util.h"
11 #include "base/tracked_objects.h" 11 #include "base/tracked_objects.h"
12 #include "content/common/child_process.h" 12 #include "content/common/child_process.h"
13 #include "content/common/child_process_messages.h" 13 #include "content/common/child_process_messages.h"
14 #include "content/common/child_trace_message_filter.h" 14 #include "content/common/child_trace_message_filter.h"
15 #include "content/common/fileapi/file_system_dispatcher.h" 15 #include "content/common/fileapi/file_system_dispatcher.h"
16 #include "content/common/quota_dispatcher.h" 16 #include "content/common/quota_dispatcher.h"
17 #include "content/common/resource_dispatcher.h" 17 #include "content/common/resource_dispatcher.h"
18 #include "content/common/socket_stream_dispatcher.h" 18 #include "content/common/socket_stream_dispatcher.h"
19 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
20 #include "ipc/ipc_logging.h" 20 #include "ipc/ipc_logging.h"
21 #include "ipc/ipc_switches.h" 21 #include "ipc/ipc_switches.h"
22 #include "ipc/ipc_sync_channel.h" 22 #include "ipc/ipc_sync_channel.h"
23 #include "ipc/ipc_sync_message_filter.h" 23 #include "ipc/ipc_sync_message_filter.h"
24 #include "webkit/glue/webkit_glue.h" 24 #include "webkit/glue/webkit_glue.h"
25 25
26 #if defined(OS_WIN) 26 #if defined(OS_WIN)
27 #include "content/common/handle_enumerator_win.h" 27 #include "content/common/handle_enumerator_win.h"
28 #endif 28 #endif
29 29
30 #if defined(USE_TCMALLOC)
31 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
32 #endif
33
30 using tracked_objects::ThreadData; 34 using tracked_objects::ThreadData;
31 35
32 ChildThread::ChildThread() { 36 ChildThread::ChildThread() {
33 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 37 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
34 switches::kProcessChannelID); 38 switches::kProcessChannelID);
35 Init(); 39 Init();
36 } 40 }
37 41
38 ChildThread::ChildThread(const std::string& channel_name) 42 ChildThread::ChildThread(const std::string& channel_name)
39 : channel_name_(channel_name) { 43 : channel_name_(channel_name) {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown) 188 IPC_MESSAGE_HANDLER(ChildProcessMsg_Shutdown, OnShutdown)
185 #if defined(IPC_MESSAGE_LOG_ENABLED) 189 #if defined(IPC_MESSAGE_LOG_ENABLED)
186 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled, 190 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetIPCLoggingEnabled,
187 OnSetIPCLoggingEnabled) 191 OnSetIPCLoggingEnabled)
188 #endif 192 #endif
189 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus, 193 IPC_MESSAGE_HANDLER(ChildProcessMsg_SetProfilerStatus,
190 OnSetProfilerStatus) 194 OnSetProfilerStatus)
191 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData, 195 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetChildProfilerData,
192 OnGetChildProfilerData) 196 OnGetChildProfilerData)
193 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles) 197 IPC_MESSAGE_HANDLER(ChildProcessMsg_DumpHandles, OnDumpHandles)
198 #if defined(USE_TCMALLOC)
199 IPC_MESSAGE_HANDLER(ChildProcessMsg_GetTcmallocStats, OnGetTcmallocStats)
200 #endif
194 IPC_MESSAGE_UNHANDLED(handled = false) 201 IPC_MESSAGE_UNHANDLED(handled = false)
195 IPC_END_MESSAGE_MAP() 202 IPC_END_MESSAGE_MAP()
196 203
197 if (handled) 204 if (handled)
198 return true; 205 return true;
199 206
200 if (msg.routing_id() == MSG_ROUTING_CONTROL) 207 if (msg.routing_id() == MSG_ROUTING_CONTROL)
201 return OnControlMessageReceived(msg); 208 return OnControlMessageReceived(msg);
202 209
203 return router_.OnMessageReceived(msg); 210 return router_.OnMessageReceived(msg);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 CommandLine::ForCurrentProcess()->HasSwitch( 246 CommandLine::ForCurrentProcess()->HasSwitch(
240 switches::kAuditAllHandles))); 247 switches::kAuditAllHandles)));
241 handle_enum->EnumerateHandles(); 248 handle_enum->EnumerateHandles();
242 Send(new ChildProcessHostMsg_DumpHandlesDone); 249 Send(new ChildProcessHostMsg_DumpHandlesDone);
243 return; 250 return;
244 #endif 251 #endif
245 252
246 NOTIMPLEMENTED(); 253 NOTIMPLEMENTED();
247 } 254 }
248 255
256 #if defined(USE_TCMALLOC)
257 void ChildThread::OnGetTcmallocStats() {
258 std::string result;
259 char buffer[1024 * 32];
260 MallocExtension::instance()->GetStats(buffer, sizeof(buffer));
261 result.append(buffer);
262 Send(new ChildProcessHostMsg_TcmallocStats(result));
263 }
264 #endif
265
249 ChildThread* ChildThread::current() { 266 ChildThread* ChildThread::current() {
250 return ChildProcess::current()->main_thread(); 267 return ChildProcess::current()->main_thread();
251 } 268 }
252 269
253 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) { 270 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) {
254 // Return false so that it is overridden in any process in which it is used. 271 // Return false so that it is overridden in any process in which it is used.
255 return false; 272 return false;
256 } 273 }
257 274
258 void ChildThread::OnProcessFinalRelease() { 275 void ChildThread::OnProcessFinalRelease() {
259 if (on_channel_error_called_) { 276 if (on_channel_error_called_) {
260 MessageLoop::current()->Quit(); 277 MessageLoop::current()->Quit();
261 return; 278 return;
262 } 279 }
263 280
264 // The child process shutdown sequence is a request response based mechanism, 281 // The child process shutdown sequence is a request response based mechanism,
265 // where we send out an initial feeler request to the child process host 282 // where we send out an initial feeler request to the child process host
266 // instance in the browser to verify if it's ok to shutdown the child process. 283 // instance in the browser to verify if it's ok to shutdown the child process.
267 // The browser then sends back a response if it's ok to shutdown. This avoids 284 // The browser then sends back a response if it's ok to shutdown. This avoids
268 // race conditions if the process refcount is 0 but there's an IPC message 285 // race conditions if the process refcount is 0 but there's an IPC message
269 // inflight that would addref it. 286 // inflight that would addref it.
270 Send(new ChildProcessHostMsg_ShutdownRequest); 287 Send(new ChildProcessHostMsg_ShutdownRequest);
271 } 288 }
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