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

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: removed unnecessary friend 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "ipc/ipc_switches.h" 42 #include "ipc/ipc_switches.h"
43 #include "media/base/media.h" 43 #include "media/base/media.h"
44 #include "sandbox/win/src/sandbox_types.h" 44 #include "sandbox/win/src/sandbox_types.h"
45 #include "ui/base/ui_base_switches.h" 45 #include "ui/base/ui_base_switches.h"
46 #include "ui/base/ui_base_paths.h" 46 #include "ui/base/ui_base_paths.h"
47 #include "ui/base/win/dpi.h" 47 #include "ui/base/win/dpi.h"
48 #include "webkit/user_agent/user_agent.h" 48 #include "webkit/user_agent/user_agent.h"
49 49
50 #if defined(USE_TCMALLOC) 50 #if defined(USE_TCMALLOC)
51 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" 51 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h"
52 #if defined(TYPE_PROFILING)
53 #include "base/allocator/type_profiler.h"
54 #include "base/allocator/type_profiler_tcmalloc.h"
55 #endif
52 #endif 56 #endif
53 57
54 #if defined(OS_WIN) 58 #if defined(OS_WIN)
55 #include <cstring> 59 #include <cstring>
56 #include <atlbase.h> 60 #include <atlbase.h>
57 #include <atlapp.h> 61 #include <atlapp.h>
58 #include <malloc.h> 62 #include <malloc.h>
59 #elif defined(OS_MACOSX) 63 #elif defined(OS_MACOSX)
60 #include "base/mac/scoped_nsautorelease_pool.h" 64 #include "base/mac/scoped_nsautorelease_pool.h"
61 #include "base/mach_ipc_mac.h" 65 #include "base/mach_ipc_mac.h"
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 490
487 RegisterInvalidParamHandler(); 491 RegisterInvalidParamHandler();
488 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); 492 _Module.Init(NULL, static_cast<HINSTANCE>(instance));
489 493
490 sandbox_info_ = *sandbox_info; 494 sandbox_info_ = *sandbox_info;
491 #else // !OS_WIN 495 #else // !OS_WIN
492 virtual int Initialize(int argc, 496 virtual int Initialize(int argc,
493 const char** argv, 497 const char** argv,
494 ContentMainDelegate* delegate) OVERRIDE { 498 ContentMainDelegate* delegate) OVERRIDE {
495 499
496 // NOTE(willchan): One might ask why this call is done here rather than in 500 // NOTE(willchan): One might ask why these TCMalloc-related calls are done
497 // process_util_linux.cc with the definition of 501 // here rather than in process_util_linux.cc with the definition of
498 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a 502 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a
499 // dependency on TCMalloc. Really, we ought to have our allocator shim code 503 // dependency on TCMalloc. Really, we ought to have our allocator shim code
500 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. 504 // implement this EnableTerminationOnOutOfMemory() function. Whateverz.
501 // This works for now. 505 // This works for now.
502 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) 506 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC)
507
508 #if defined(TYPE_PROFILING)
509 base::type_profiler::InterceptFunctions::SetFunctions(
510 base::type_profiler::NewInterceptForTCMalloc,
511 base::type_profiler::DeleteInterceptForTCMalloc);
512 #endif
513
503 // For tcmalloc, we need to tell it to behave like new. 514 // For tcmalloc, we need to tell it to behave like new.
504 tc_set_new_mode(1); 515 tc_set_new_mode(1);
505 516
506 // On windows, we've already set these thunks up in _heap_init() 517 // On windows, we've already set these thunks up in _heap_init()
507 base::allocator::SetGetStatsFunction(GetStatsThunk); 518 base::allocator::SetGetStatsFunction(GetStatsThunk);
508 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); 519 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk);
509 520
510 // Provide optional hook for monitoring allocation quantities on a 521 // Provide optional hook for monitoring allocation quantities on a
511 // per-thread basis. Only set the hook if the environment indicates this 522 // per-thread basis. Only set the hook if the environment indicates this
512 // needs to be enabled. 523 // needs to be enabled.
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 776
766 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); 777 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl);
767 }; 778 };
768 779
769 // static 780 // static
770 ContentMainRunner* ContentMainRunner::Create() { 781 ContentMainRunner* ContentMainRunner::Create() {
771 return new ContentMainRunnerImpl(); 782 return new ContentMainRunnerImpl();
772 } 783 }
773 784
774 } // namespace content 785 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698