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 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 return true; | 426 return true; |
427 } | 427 } |
428 DCHECK(false); | 428 DCHECK(false); |
429 return false; | 429 return false; |
430 } | 430 } |
431 | 431 |
432 static void GetStatsThunk(char* buffer, int buffer_length) { | 432 static void GetStatsThunk(char* buffer, int buffer_length) { |
433 MallocExtension::instance()->GetStats(buffer, buffer_length); | 433 MallocExtension::instance()->GetStats(buffer, buffer_length); |
434 } | 434 } |
435 | 435 |
| 436 static bool GetNumericPropertyThunk(const char* name, size_t* value) { |
| 437 return MallocExtension::instance()->GetNumericProperty(name, value); |
| 438 } |
| 439 |
436 static void ReleaseFreeMemoryThunk() { | 440 static void ReleaseFreeMemoryThunk() { |
437 MallocExtension::instance()->ReleaseFreeMemory(); | 441 MallocExtension::instance()->ReleaseFreeMemory(); |
438 } | 442 } |
439 #endif | 443 #endif |
440 | 444 |
441 int Initialize(const ContentMainParams& params) override { | 445 int Initialize(const ContentMainParams& params) override { |
442 ui_task_ = params.ui_task; | 446 ui_task_ = params.ui_task; |
443 | 447 |
444 base::EnableTerminationOnOutOfMemory(); | 448 base::EnableTerminationOnOutOfMemory(); |
445 #if defined(OS_WIN) | 449 #if defined(OS_WIN) |
(...skipping 17 matching lines...) Expand all Loading... |
463 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. | 467 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. |
464 // This works for now. | 468 // This works for now. |
465 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 469 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
466 // For tcmalloc, we need to tell it to behave like new. | 470 // For tcmalloc, we need to tell it to behave like new. |
467 tc_set_new_mode(1); | 471 tc_set_new_mode(1); |
468 | 472 |
469 // On windows, we've already set these thunks up in _heap_init() | 473 // On windows, we've already set these thunks up in _heap_init() |
470 base::allocator::SetGetAllocatorWasteSizeFunction( | 474 base::allocator::SetGetAllocatorWasteSizeFunction( |
471 GetAllocatorWasteSizeThunk); | 475 GetAllocatorWasteSizeThunk); |
472 base::allocator::SetGetStatsFunction(GetStatsThunk); | 476 base::allocator::SetGetStatsFunction(GetStatsThunk); |
| 477 base::allocator::SetGetNumericPropertyFunction(GetNumericPropertyThunk); |
473 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 478 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
474 | 479 |
475 // Provide optional hook for monitoring allocation quantities on a | 480 // Provide optional hook for monitoring allocation quantities on a |
476 // per-thread basis. Only set the hook if the environment indicates this | 481 // per-thread basis. Only set the hook if the environment indicates this |
477 // needs to be enabled. | 482 // needs to be enabled. |
478 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); | 483 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); |
479 if (profiling && | 484 if (profiling && |
480 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { | 485 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { |
481 tracked_objects::SetAlternateTimeSource( | 486 tracked_objects::SetAlternateTimeSource( |
482 MallocExtension::GetBytesAllocatedOnCurrentThread, | 487 MallocExtension::GetBytesAllocatedOnCurrentThread, |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 862 |
858 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 863 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
859 }; | 864 }; |
860 | 865 |
861 // static | 866 // static |
862 ContentMainRunner* ContentMainRunner::Create() { | 867 ContentMainRunner* ContentMainRunner::Create() { |
863 return new ContentMainRunnerImpl(); | 868 return new ContentMainRunnerImpl(); |
864 } | 869 } |
865 | 870 |
866 } // namespace content | 871 } // namespace content |
OLD | NEW |