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 30 matching lines...) Expand all Loading... | |
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_ALLOCATED_TYPE) | |
52 #include "base/allocator/allocated_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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
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_ALLOCATED_TYPE) | |
455 base::allocated_type::SetNewInterceptFunction( | |
jar (doing other things)
2012/08/23 19:55:25
nit: Do you ever set these separately? IF you alwa
Dai Mikurube (NOT FULLTIME)
2012/08/24 02:47:27
Done. I kept individual functions since I often u
jar (doing other things)
2012/08/27 17:17:12
It was not clear which of these should be set firs
Dai Mikurube (NOT FULLTIME)
2012/08/27 23:52:56
Ok, I'll remove individual functions. When I need
Dai Mikurube (NOT FULLTIME)
2012/08/28 09:04:57
Done.
| |
456 base::allocated_type::NewInterceptForTCMalloc); | |
457 base::allocated_type::SetDeleteInterceptFunction( | |
458 base::allocated_type::DeleteInterceptForTCMalloc); | |
459 #endif | |
460 | |
450 // For tcmalloc, we need to tell it to behave like new. | 461 // For tcmalloc, we need to tell it to behave like new. |
451 tc_set_new_mode(1); | 462 tc_set_new_mode(1); |
452 | 463 |
453 // On windows, we've already set these thunks up in _heap_init() | 464 // On windows, we've already set these thunks up in _heap_init() |
454 base::allocator::SetGetStatsFunction(GetStatsThunk); | 465 base::allocator::SetGetStatsFunction(GetStatsThunk); |
455 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 466 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
456 | 467 |
457 // Provide optional hook for monitoring allocation quantities on a | 468 // Provide optional hook for monitoring allocation quantities on a |
458 // per-thread basis. Only set the hook if the environment indicates this | 469 // per-thread basis. Only set the hook if the environment indicates this |
459 // needs to be enabled. | 470 // needs to be enabled. |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 | 720 |
710 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 721 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
711 }; | 722 }; |
712 | 723 |
713 // static | 724 // static |
714 ContentMainRunner* ContentMainRunner::Create() { | 725 ContentMainRunner* ContentMainRunner::Create() { |
715 return new ContentMainRunnerImpl(); | 726 return new ContentMainRunnerImpl(); |
716 } | 727 } |
717 | 728 |
718 } // namespace content | 729 } // namespace content |
OLD | NEW |