OLD | NEW |
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 Loading... |
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 #if !defined(OS_IOS) | 65 #if !defined(OS_IOS) |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 500 |
497 RegisterInvalidParamHandler(); | 501 RegisterInvalidParamHandler(); |
498 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); | 502 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); |
499 | 503 |
500 sandbox_info_ = *sandbox_info; | 504 sandbox_info_ = *sandbox_info; |
501 #else // !OS_WIN | 505 #else // !OS_WIN |
502 virtual int Initialize(int argc, | 506 virtual int Initialize(int argc, |
503 const char** argv, | 507 const char** argv, |
504 ContentMainDelegate* delegate) OVERRIDE { | 508 ContentMainDelegate* delegate) OVERRIDE { |
505 | 509 |
506 // NOTE(willchan): One might ask why this call is done here rather than in | 510 // NOTE(willchan): One might ask why these TCMalloc-related calls are done |
507 // process_util_linux.cc with the definition of | 511 // here rather than in process_util_linux.cc with the definition of |
508 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a | 512 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a |
509 // dependency on TCMalloc. Really, we ought to have our allocator shim code | 513 // dependency on TCMalloc. Really, we ought to have our allocator shim code |
510 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. | 514 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. |
511 // This works for now. | 515 // This works for now. |
512 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 516 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
| 517 |
| 518 #if defined(TYPE_PROFILING) |
| 519 base::type_profiler::InterceptFunctions::SetFunctions( |
| 520 base::type_profiler::NewInterceptForTCMalloc, |
| 521 base::type_profiler::DeleteInterceptForTCMalloc); |
| 522 #endif |
| 523 |
513 // For tcmalloc, we need to tell it to behave like new. | 524 // For tcmalloc, we need to tell it to behave like new. |
514 tc_set_new_mode(1); | 525 tc_set_new_mode(1); |
515 | 526 |
516 // On windows, we've already set these thunks up in _heap_init() | 527 // On windows, we've already set these thunks up in _heap_init() |
517 base::allocator::SetGetPropertyFunction(GetPropertyThunk); | 528 base::allocator::SetGetPropertyFunction(GetPropertyThunk); |
518 base::allocator::SetGetStatsFunction(GetStatsThunk); | 529 base::allocator::SetGetStatsFunction(GetStatsThunk); |
519 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 530 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
520 | 531 |
521 // Provide optional hook for monitoring allocation quantities on a | 532 // Provide optional hook for monitoring allocation quantities on a |
522 // per-thread basis. Only set the hook if the environment indicates this | 533 // per-thread basis. Only set the hook if the environment indicates this |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
781 | 792 |
782 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 793 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
783 }; | 794 }; |
784 | 795 |
785 // static | 796 // static |
786 ContentMainRunner* ContentMainRunner::Create() { | 797 ContentMainRunner* ContentMainRunner::Create() { |
787 return new ContentMainRunnerImpl(); | 798 return new ContentMainRunnerImpl(); |
788 } | 799 } |
789 | 800 |
790 } // namespace content | 801 } // namespace content |
OLD | NEW |