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

Side by Side Diff: content/app/content_main_runner.cc

Issue 10411047: Type profiler by intercepting 'new' and 'delete' expressions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed comments. Created 8 years, 3 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/public/app/content_main_runner.h" 5 #include "content/public/app/content_main_runner.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/at_exit.h" 10 #include "base/at_exit.h"
(...skipping 30 matching lines...) Expand all
41 #include "ipc/ipc_switches.h" 41 #include "ipc/ipc_switches.h"
42 #include "media/base/media.h" 42 #include "media/base/media.h"
43 #include "sandbox/win/src/sandbox_types.h" 43 #include "sandbox/win/src/sandbox_types.h"
44 #include "ui/base/ui_base_switches.h" 44 #include "ui/base/ui_base_switches.h"
45 #include "ui/base/ui_base_paths.h" 45 #include "ui/base/ui_base_paths.h"
46 #include "ui/base/win/dpi.h" 46 #include "ui/base/win/dpi.h"
47 #include "webkit/glue/webkit_glue.h" 47 #include "webkit/glue/webkit_glue.h"
48 48
49 #if defined(USE_TCMALLOC) 49 #if defined(USE_TCMALLOC)
50 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" 50 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
51 #if defined(PROFILING_TYPE)
52 #include "base/allocator/type_profiler_tcmalloc.h"
53 #endif
51 #endif 54 #endif
52 55
53 #if defined(OS_WIN) 56 #if defined(OS_WIN)
54 #include <cstring> 57 #include <cstring>
55 #include <atlbase.h> 58 #include <atlbase.h>
56 #include <atlapp.h> 59 #include <atlapp.h>
57 #include <malloc.h> 60 #include <malloc.h>
58 #elif defined(OS_MACOSX) 61 #elif defined(OS_MACOSX)
59 #include "base/mac/scoped_nsautorelease_pool.h" 62 #include "base/mac/scoped_nsautorelease_pool.h"
60 #include "base/mach_ipc_mac.h" 63 #include "base/mach_ipc_mac.h"
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 436
434 RegisterInvalidParamHandler(); 437 RegisterInvalidParamHandler();
435 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); 438 _Module.Init(NULL, static_cast<HINSTANCE>(instance));
436 439
437 sandbox_info_ = *sandbox_info; 440 sandbox_info_ = *sandbox_info;
438 #else // !OS_WIN 441 #else // !OS_WIN
439 virtual int Initialize(int argc, 442 virtual int Initialize(int argc,
440 const char** argv, 443 const char** argv,
441 ContentMainDelegate* delegate) OVERRIDE { 444 ContentMainDelegate* delegate) OVERRIDE {
442 445
443 // NOTE(willchan): One might ask why this call is done here rather than in 446 // NOTE(willchan): One might ask why this call is done here rather than in
jar (doing other things) 2012/08/30 16:02:10 Please either edit this comment so that "this" is
Dai Mikurube (NOT FULLTIME) 2012/08/31 06:10:30 Changed it to : // ... One might ask why these TCM
444 // process_util_linux.cc with the definition of 447 // process_util_linux.cc with the definition of
445 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a 448 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a
446 // dependency on TCMalloc. Really, we ought to have our allocator shim code 449 // dependency on TCMalloc. Really, we ought to have our allocator shim code
447 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. 450 // implement this EnableTerminationOnOutOfMemory() function. Whateverz.
448 // This works for now. 451 // This works for now.
449 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 452 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
453
454 #if defined(PROFILING_TYPE)
455 base::type_profiler::SetInterceptFunctions(
456 base::type_profiler::NewInterceptForTCMalloc,
457 base::type_profiler::DeleteInterceptForTCMalloc);
458 #endif
459
450 // For tcmalloc, we need to tell it to behave like new. 460 // For tcmalloc, we need to tell it to behave like new.
451 tc_set_new_mode(1); 461 tc_set_new_mode(1);
452 462
453 // On windows, we've already set these thunks up in _heap_init() 463 // On windows, we've already set these thunks up in _heap_init()
454 base::allocator::SetGetStatsFunction(GetStatsThunk); 464 base::allocator::SetGetStatsFunction(GetStatsThunk);
455 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); 465 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
456 466
457 // Provide optional hook for monitoring allocation quantities on a 467 // Provide optional hook for monitoring allocation quantities on a
458 // per-thread basis. Only set the hook if the environment indicates this 468 // per-thread basis. Only set the hook if the environment indicates this
459 // needs to be enabled. 469 // needs to be enabled.
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
709 719
710 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 720 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
711 }; 721 };
712 722
713 // static 723 // static
714 ContentMainRunner* ContentMainRunner::Create() { 724 ContentMainRunner* ContentMainRunner::Create() {
715 return new ContentMainRunnerImpl(); 725 return new ContentMainRunnerImpl();
716 } 726 }
717 727
718 } // namespace content 728 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698