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 "base/allocator/allocator_extension.h" | |
7 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
9 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
10 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
11 #include "base/file_path.h" | 12 #include "base/file_path.h" |
12 #include "base/i18n/icu_util.h" | 13 #include "base/i18n/icu_util.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/metrics/stats_table.h" | 16 #include "base/metrics/stats_table.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
(...skipping 13 matching lines...) Expand all Loading... | |
30 #include "content/public/common/url_constants.h" | 31 #include "content/public/common/url_constants.h" |
31 #include "crypto/nss_util.h" | 32 #include "crypto/nss_util.h" |
32 #include "ipc/ipc_switches.h" | 33 #include "ipc/ipc_switches.h" |
33 #include "media/base/media.h" | 34 #include "media/base/media.h" |
34 #include "sandbox/src/sandbox_types.h" | 35 #include "sandbox/src/sandbox_types.h" |
35 #include "ui/base/ui_base_switches.h" | 36 #include "ui/base/ui_base_switches.h" |
36 #include "ui/base/ui_base_paths.h" | 37 #include "ui/base/ui_base_paths.h" |
37 #include "ui/base/win/dpi.h" | 38 #include "ui/base/win/dpi.h" |
38 #include "webkit/glue/webkit_glue.h" | 39 #include "webkit/glue/webkit_glue.h" |
39 | 40 |
41 #if defined(USE_TCMALLOC) | |
42 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | |
43 #endif | |
44 | |
40 #if defined(OS_WIN) | 45 #if defined(OS_WIN) |
41 #include <atlbase.h> | 46 #include <atlbase.h> |
42 #include <atlapp.h> | 47 #include <atlapp.h> |
43 #include <malloc.h> | 48 #include <malloc.h> |
44 #elif defined(OS_MACOSX) | 49 #elif defined(OS_MACOSX) |
45 #include "base/mac/scoped_nsautorelease_pool.h" | 50 #include "base/mac/scoped_nsautorelease_pool.h" |
46 #include "base/mach_ipc_mac.h" | 51 #include "base/mach_ipc_mac.h" |
47 #include "base/system_monitor/system_monitor.h" | 52 #include "base/system_monitor/system_monitor.h" |
48 #include "content/browser/mach_broker_mac.h" | 53 #include "content/browser/mach_broker_mac.h" |
49 #include "content/common/sandbox_init_mac.h" | 54 #include "content/common/sandbox_init_mac.h" |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 : is_initialized_(false), | 312 : is_initialized_(false), |
308 is_shutdown_(false), | 313 is_shutdown_(false), |
309 completed_basic_startup_(false) { | 314 completed_basic_startup_(false) { |
310 } | 315 } |
311 | 316 |
312 ~ContentMainRunnerImpl() { | 317 ~ContentMainRunnerImpl() { |
313 if (is_initialized_ && !is_shutdown_) | 318 if (is_initialized_ && !is_shutdown_) |
314 Shutdown(); | 319 Shutdown(); |
315 } | 320 } |
316 | 321 |
322 #if defined(USE_TCMALLOC) | |
323 static void get_stats_thunk(char* buffer, int buffer_length) { | |
jam
2012/04/26 21:28:20
nit: chrome style is GetStatsThunk. also below
| |
324 MallocExtension::instance()->GetStats(buffer, buffer_length); | |
jam
2012/04/26 21:28:20
nit: 2 spaces.. also below
| |
325 } | |
326 | |
327 static void release_free_memory_thunk() { | |
328 MallocExtension::instance()->ReleaseFreeMemory(); | |
329 } | |
330 #endif | |
331 | |
332 | |
317 #if defined(OS_WIN) | 333 #if defined(OS_WIN) |
318 virtual int Initialize(HINSTANCE instance, | 334 virtual int Initialize(HINSTANCE instance, |
319 sandbox::SandboxInterfaceInfo* sandbox_info, | 335 sandbox::SandboxInterfaceInfo* sandbox_info, |
320 content::ContentMainDelegate* delegate) OVERRIDE { | 336 content::ContentMainDelegate* delegate) OVERRIDE { |
321 // argc/argv are ignored on Windows; see command_line.h for details. | 337 // argc/argv are ignored on Windows; see command_line.h for details. |
322 int argc = 0; | 338 int argc = 0; |
323 char** argv = NULL; | 339 char** argv = NULL; |
324 | 340 |
325 content::RegisterInvalidParamHandler(); | 341 content::RegisterInvalidParamHandler(); |
326 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); | 342 _Module.Init(NULL, static_cast<HINSTANCE>(instance)); |
(...skipping 11 matching lines...) Expand all Loading... | |
338 // process_util_linux.cc with the definition of | 354 // process_util_linux.cc with the definition of |
339 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a | 355 // EnableTerminationOnOutOfMemory(). That's because base shouldn't have a |
340 // dependency on TCMalloc. Really, we ought to have our allocator shim code | 356 // dependency on TCMalloc. Really, we ought to have our allocator shim code |
341 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. | 357 // implement this EnableTerminationOnOutOfMemory() function. Whateverz. |
342 // This works for now. | 358 // This works for now. |
343 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 359 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
344 // For tcmalloc, we need to tell it to behave like new. | 360 // For tcmalloc, we need to tell it to behave like new. |
345 tc_set_new_mode(1); | 361 tc_set_new_mode(1); |
346 #endif | 362 #endif |
347 | 363 |
364 // On windows, we've already set these thunks up in _heap_init() | |
365 #if !defined(OS_WIN) && defined(USE_TCMALLOC) | |
jam
2012/04/26 21:28:20
nit: if you don't want windows, then move this up
| |
366 base::allocator::SetGetStatsFunction(get_stats_thunk); | |
367 base::allocator::SetReleaseFreeMemoryFunction(release_free_memory_thunk); | |
368 #endif | |
369 | |
348 #if !defined(OS_ANDROID) | 370 #if !defined(OS_ANDROID) |
349 // Set C library locale to make sure CommandLine can parse argument values | 371 // Set C library locale to make sure CommandLine can parse argument values |
350 // in correct encoding. | 372 // in correct encoding. |
351 setlocale(LC_ALL, ""); | 373 setlocale(LC_ALL, ""); |
352 #endif | 374 #endif |
353 | 375 |
354 SetupSignalHandlers(); | 376 SetupSignalHandlers(); |
355 | 377 |
356 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); | 378 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); |
357 g_fds->Set(kPrimaryIPCChannel, | 379 g_fds->Set(kPrimaryIPCChannel, |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 } // namespace | 606 } // namespace |
585 | 607 |
586 namespace content { | 608 namespace content { |
587 | 609 |
588 // static | 610 // static |
589 ContentMainRunner* ContentMainRunner::Create() { | 611 ContentMainRunner* ContentMainRunner::Create() { |
590 return new ContentMainRunnerImpl(); | 612 return new ContentMainRunnerImpl(); |
591 } | 613 } |
592 | 614 |
593 } // namespace content | 615 } // namespace content |
OLD | NEW |