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 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 | 542 |
543 // For tcmalloc, we need to tell it to behave like new. | 543 // For tcmalloc, we need to tell it to behave like new. |
544 tc_set_new_mode(1); | 544 tc_set_new_mode(1); |
545 | 545 |
546 // On windows, we've already set these thunks up in _heap_init() | 546 // On windows, we've already set these thunks up in _heap_init() |
547 base::allocator::SetGetAllocatorWasteSizeFunction( | 547 base::allocator::SetGetAllocatorWasteSizeFunction( |
548 GetAllocatorWasteSizeThunk); | 548 GetAllocatorWasteSizeThunk); |
549 base::allocator::SetGetStatsFunction(GetStatsThunk); | 549 base::allocator::SetGetStatsFunction(GetStatsThunk); |
550 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 550 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
551 | 551 |
552 #if !defined(USE_SYSTEM_TCMALLOC) | |
553 // Provide optional hook for monitoring allocation quantities on a | 552 // Provide optional hook for monitoring allocation quantities on a |
554 // per-thread basis. Only set the hook if the environment indicates this | 553 // per-thread basis. Only set the hook if the environment indicates this |
555 // needs to be enabled. | 554 // needs to be enabled. |
556 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); | 555 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); |
557 if (profiling && | 556 if (profiling && |
558 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { | 557 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { |
559 tracked_objects::SetAlternateTimeSource( | 558 tracked_objects::SetAlternateTimeSource( |
560 MallocExtension::GetBytesAllocatedOnCurrentThread, | 559 MallocExtension::GetBytesAllocatedOnCurrentThread, |
561 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); | 560 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); |
562 } | 561 } |
563 #endif // !defined(USE_SYSTEM_TCMALLOC) | 562 #endif |
564 #endif // !defined(OS_MACOSX) && defined(USE_TCMALLOC) | |
565 | 563 |
566 // On Android, | 564 // On Android, |
567 // - setlocale() is not supported. | 565 // - setlocale() is not supported. |
568 // - We do not override the signal handlers so that we can get | 566 // - We do not override the signal handlers so that we can get |
569 // stack trace when crashing. | 567 // stack trace when crashing. |
570 // - The ipc_fd is passed through the Java service. | 568 // - The ipc_fd is passed through the Java service. |
571 // Thus, these are all disabled. | 569 // Thus, these are all disabled. |
572 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 570 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
573 // Set C library locale to make sure CommandLine can parse argument values | 571 // Set C library locale to make sure CommandLine can parse argument values |
574 // in correct encoding. | 572 // in correct encoding. |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 | 812 |
815 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 813 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
816 }; | 814 }; |
817 | 815 |
818 // static | 816 // static |
819 ContentMainRunner* ContentMainRunner::Create() { | 817 ContentMainRunner* ContentMainRunner::Create() { |
820 return new ContentMainRunnerImpl(); | 818 return new ContentMainRunnerImpl(); |
821 } | 819 } |
822 | 820 |
823 } // namespace content | 821 } // namespace content |
OLD | NEW |