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> | |
8 | |
9 #include "base/allocator/allocator_extension.h" | 7 #include "base/allocator/allocator_extension.h" |
10 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
11 #include "base/command_line.h" | 9 #include "base/command_line.h" |
12 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
13 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
14 #include "base/file_path.h" | 12 #include "base/file_path.h" |
15 #include "base/i18n/icu_util.h" | 13 #include "base/i18n/icu_util.h" |
16 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 15 #include "base/logging.h" |
18 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
19 #include "base/metrics/stats_table.h" | 17 #include "base/metrics/stats_table.h" |
20 #include "base/path_service.h" | 18 #include "base/path_service.h" |
21 #include "base/process_util.h" | 19 #include "base/process_util.h" |
22 #include "base/profiler/alternate_timer.h" | |
23 #include "base/stringprintf.h" | 20 #include "base/stringprintf.h" |
24 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
25 #include "content/browser/browser_main.h" | 22 #include "content/browser/browser_main.h" |
26 #include "content/common/set_process_title.h" | 23 #include "content/common/set_process_title.h" |
27 #include "content/common/url_schemes.h" | 24 #include "content/common/url_schemes.h" |
28 #include "content/public/app/content_main_delegate.h" | 25 #include "content/public/app/content_main_delegate.h" |
29 #include "content/public/app/startup_helper_win.h" | 26 #include "content/public/app/startup_helper_win.h" |
30 #include "content/public/browser/content_browser_client.h" | 27 #include "content/public/browser/content_browser_client.h" |
31 #include "content/public/common/content_client.h" | 28 #include "content/public/common/content_client.h" |
32 #include "content/public/common/content_constants.h" | 29 #include "content/public/common/content_constants.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 // dependency on TCMalloc. Really, we ought to have our allocator shim code | 443 // dependency on TCMalloc. Really, we ought to have our allocator shim code |
447 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. | 444 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. |
448 // This works for now. | 445 // This works for now. |
449 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 446 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
450 // For tcmalloc, we need to tell it to behave like new. | 447 // For tcmalloc, we need to tell it to behave like new. |
451 tc_set_new_mode(1); | 448 tc_set_new_mode(1); |
452 | 449 |
453 // On windows, we've already set these thunks up in _heap_init() | 450 // On windows, we've already set these thunks up in _heap_init() |
454 base::allocator::SetGetStatsFunction(GetStatsThunk); | 451 base::allocator::SetGetStatsFunction(GetStatsThunk); |
455 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); | 452 base::allocator::SetReleaseFreeMemoryFunction(ReleaseFreeMemoryThunk); |
456 | |
457 // Provide optional hook for monitoring allocation quantities on a | |
458 // per-thread basis. Only set the hook if the environment indicates this | |
459 // needs to be enabled. | |
460 const char* profiling = getenv(tracked_objects::kAlternateProfilerTime); | |
461 if (profiling && | |
462 (atoi(profiling) == tracked_objects::TIME_SOURCE_TYPE_TCMALLOC)) { | |
463 tracked_objects::SetAlternateTimeSource( | |
464 MallocExtension::GetBytesAllocatedOnCurrentThread, | |
465 tracked_objects::TIME_SOURCE_TYPE_TCMALLOC); | |
466 } | |
467 #endif | 453 #endif |
468 | 454 |
469 // On Android, | 455 // On Android, |
470 // - setlocale() is not supported. | 456 // - setlocale() is not supported. |
471 // - We do not override the signal handlers so that we can get | 457 // - We do not override the signal handlers so that we can get |
472 // stack trace when crashing. | 458 // stack trace when crashing. |
473 // - The ipc_fd is passed through the Java service. | 459 // - The ipc_fd is passed through the Java service. |
474 // Thus, these are all disabled. | 460 // Thus, these are all disabled. |
475 #if !defined(OS_ANDROID) | 461 #if !defined(OS_ANDROID) |
476 // Set C library locale to make sure CommandLine can parse argument values | 462 // Set C library locale to make sure CommandLine can parse argument values |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 | 689 |
704 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 690 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
705 }; | 691 }; |
706 | 692 |
707 // static | 693 // static |
708 ContentMainRunner* ContentMainRunner::Create() { | 694 ContentMainRunner* ContentMainRunner::Create() { |
709 return new ContentMainRunnerImpl(); | 695 return new ContentMainRunnerImpl(); |
710 } | 696 } |
711 | 697 |
712 } // namespace content | 698 } // namespace content |
OLD | NEW |