| 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 <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 memset(&sandbox_info_, 0, sizeof(sandbox_info_)); | 407 memset(&sandbox_info_, 0, sizeof(sandbox_info_)); |
| 408 #endif | 408 #endif |
| 409 } | 409 } |
| 410 | 410 |
| 411 ~ContentMainRunnerImpl() override { | 411 ~ContentMainRunnerImpl() override { |
| 412 if (is_initialized_ && !is_shutdown_) | 412 if (is_initialized_ && !is_shutdown_) |
| 413 Shutdown(); | 413 Shutdown(); |
| 414 } | 414 } |
| 415 | 415 |
| 416 #if defined(USE_TCMALLOC) | 416 #if defined(USE_TCMALLOC) |
| 417 static void GetStatsThunk(char* buffer, int buffer_length) { | |
| 418 MallocExtension::instance()->GetStats(buffer, buffer_length); | |
| 419 } | |
| 420 | |
| 421 static bool GetNumericPropertyThunk(const char* name, size_t* value) { | 417 static bool GetNumericPropertyThunk(const char* name, size_t* value) { |
| 422 return MallocExtension::instance()->GetNumericProperty(name, value); | 418 return MallocExtension::instance()->GetNumericProperty(name, value); |
| 423 } | 419 } |
| 424 | 420 |
| 425 static void ReleaseFreeMemoryThunk() { | 421 static void ReleaseFreeMemoryThunk() { |
| 426 MallocExtension::instance()->ReleaseFreeMemory(); | 422 MallocExtension::instance()->ReleaseFreeMemory(); |
| 427 } | 423 } |
| 428 #endif | 424 #endif |
| 429 | 425 |
| 430 int Initialize(const ContentMainParams& params) override { | 426 int Initialize(const ContentMainParams& params) override { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 449 // here rather than in process_util_linux.cc with the definition of | 445 // here rather than in process_util_linux.cc with the definition of |
| 450 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a | 446 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a |
| 451 // dependency on TCMalloc. Really, we ought to have our allocator shim code | 447 // dependency on TCMalloc. Really, we ought to have our allocator shim code |
| 452 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. | 448 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. |
| 453 // This works for now. | 449 // This works for now. |
| 454 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 450 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
| 455 // For tcmalloc, we need to tell it to behave like new. | 451 // For tcmalloc, we need to tell it to behave like new. |
| 456 tc_set_new_mode(1); | 452 tc_set_new_mode(1); |
| 457 | 453 |
| 458 // On windows, we've already set these thunks up in _heap_init() | 454 // On windows, we've already set these thunks up in _heap_init() |
| 459 base::allocator::SetGetStatsFunction(GetStatsThunk); | |
| 460 base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk); | 455 base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk); |
| 461 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 456 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
| 462 | 457 |
| 463 // Provide optional hook for monitoring allocation quantities on a | 458 // Provide optional hook for monitoring allocation quantities on a |
| 464 // per-thread basis. Only set the hook if the environment indicates this | 459 // per-thread basis. Only set the hook if the environment indicates this |
| 465 // needs to be enabled. | 460 // needs to be enabled. |
| 466 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); | 461 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); |
| 467 if (profiling && | 462 if (profiling && |
| 468 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { | 463 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { |
| 469 tracked_objects::SetAlternateTimeSource( | 464 tracked_objects::SetAlternateTimeSource( |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 | 845 |
| 851 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 846 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 852 }; | 847 }; |
| 853 | 848 |
| 854 // static | 849 // static |
| 855 ContentMainRunner* ContentMainRunner::Create() { | 850 ContentMainRunner* ContentMainRunner::Create() { |
| 856 return new ContentMainRunnerImpl(); | 851 return new ContentMainRunnerImpl(); |
| 857 } | 852 } |
| 858 | 853 |
| 859 } // namespace content | 854 } // namespace content |
| OLD | NEW |