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

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

Issue 10239012: Route calls to tcmalloc MallocExtension through allocator agnostic interface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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
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/allocator/allocator_extension.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/message_loop.h" 9 #include "base/message_loop.h"
9 #include "base/process.h" 10 #include "base/process.h"
10 #include "base/string_util.h" 11 #include "base/string_util.h"
11 #include "base/tracked_objects.h" 12 #include "base/tracked_objects.h"
12 #include "content/common/child_process.h" 13 #include "content/common/child_process.h"
13 #include "content/common/child_process_messages.h" 14 #include "content/common/child_process_messages.h"
14 #include "content/common/child_trace_message_filter.h" 15 #include "content/common/child_trace_message_filter.h"
15 #include "content/common/fileapi/file_system_dispatcher.h" 16 #include "content/common/fileapi/file_system_dispatcher.h"
16 #include "content/common/quota_dispatcher.h" 17 #include "content/common/quota_dispatcher.h"
17 #include "content/common/resource_dispatcher.h" 18 #include "content/common/resource_dispatcher.h"
18 #include "content/common/socket_stream_dispatcher.h" 19 #include "content/common/socket_stream_dispatcher.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "ipc/ipc_logging.h" 21 #include "ipc/ipc_logging.h"
21 #include "ipc/ipc_switches.h" 22 #include "ipc/ipc_switches.h"
22 #include "ipc/ipc_sync_channel.h" 23 #include "ipc/ipc_sync_channel.h"
23 #include "ipc/ipc_sync_message_filter.h" 24 #include "ipc/ipc_sync_message_filter.h"
24 #include "webkit/glue/webkit_glue.h" 25 #include "webkit/glue/webkit_glue.h"
25 26
26 #if defined(OS_WIN) 27 #if defined(OS_WIN)
27 #include "content/common/handle_enumerator_win.h" 28 #include "content/common/handle_enumerator_win.h"
28 #endif 29 #endif
29 30
30 #if defined(USE_TCMALLOC)
31 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
32 #endif
33
34 using tracked_objects::ThreadData; 31 using tracked_objects::ThreadData;
35 32
36 ChildThread::ChildThread() { 33 ChildThread::ChildThread() {
37 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 34 channel_name_ = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
38 switches::kProcessChannelID); 35 switches::kProcessChannelID);
39 Init(); 36 Init();
40 } 37 }
41 38
42 ChildThread::ChildThread(const std::string& channel_name) 39 ChildThread::ChildThread(const std::string& channel_name)
43 : channel_name_(channel_name) { 40 : channel_name_(channel_name) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return; 247 return;
251 #endif 248 #endif
252 249
253 NOTIMPLEMENTED(); 250 NOTIMPLEMENTED();
254 } 251 }
255 252
256 #if defined(USE_TCMALLOC) 253 #if defined(USE_TCMALLOC)
257 void ChildThread::OnGetTcmallocStats() { 254 void ChildThread::OnGetTcmallocStats() {
258 std::string result; 255 std::string result;
259 char buffer[1024 * 32]; 256 char buffer[1024 * 32];
260 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); 257 base::allocator::GetStats(buffer, sizeof(buffer));
261 result.append(buffer); 258 result.append(buffer);
262 Send(new ChildProcessHostMsg_TcmallocStats(result)); 259 Send(new ChildProcessHostMsg_TcmallocStats(result));
263 } 260 }
264 #endif 261 #endif
265 262
266 ChildThread* ChildThread::current() { 263 ChildThread* ChildThread::current() {
267 return ChildProcess::current()->main_thread(); 264 return ChildProcess::current()->main_thread();
268 } 265 }
269 266
270 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) { 267 bool ChildThread::IsWebFrameValid(WebKit::WebFrame* frame) {
271 // Return false so that it is overridden in any process in which it is used. 268 // Return false so that it is overridden in any process in which it is used.
272 return false; 269 return false;
273 } 270 }
274 271
275 void ChildThread::OnProcessFinalRelease() { 272 void ChildThread::OnProcessFinalRelease() {
276 if (on_channel_error_called_) { 273 if (on_channel_error_called_) {
277 MessageLoop::current()->Quit(); 274 MessageLoop::current()->Quit();
278 return; 275 return;
279 } 276 }
280 277
281 // The child process shutdown sequence is a request response based mechanism, 278 // The child process shutdown sequence is a request response based mechanism,
282 // where we send out an initial feeler request to the child process host 279 // where we send out an initial feeler request to the child process host
283 // instance in the browser to verify if it's ok to shutdown the child process. 280 // instance in the browser to verify if it's ok to shutdown the child process.
284 // The browser then sends back a response if it's ok to shutdown. This avoids 281 // The browser then sends back a response if it's ok to shutdown. This avoids
285 // race conditions if the process refcount is 0 but there's an IPC message 282 // race conditions if the process refcount is 0 but there's an IPC message
286 // inflight that would addref it. 283 // inflight that would addref it.
287 Send(new ChildProcessHostMsg_ShutdownRequest); 284 Send(new ChildProcessHostMsg_ShutdownRequest);
288 } 285 }
OLDNEW
« no previous file with comments | « content/browser/tcmalloc_internals_request_job.cc ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698