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