| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // TODO(port): the ifdefs in here are a first step towards trying to determine | 5 // TODO(port): the ifdefs in here are a first step towards trying to determine |
| 6 // the correct abstraction for all the OS functionality required at this | 6 // the correct abstraction for all the OS functionality required at this |
| 7 // stage of process initialization. It should not be taken as a final | 7 // stage of process initialization. It should not be taken as a final |
| 8 // abstraction. | 8 // abstraction. |
| 9 | 9 |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); | 325 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 326 #else | 326 #else |
| 327 if (!parsed_command_line.HasSwitch(switches::kDisableBreakpad)) { | 327 if (!parsed_command_line.HasSwitch(switches::kDisableBreakpad)) { |
| 328 _CrtSetReportMode(_CRT_ASSERT, 0); | 328 _CrtSetReportMode(_CRT_ASSERT, 0); |
| 329 } | 329 } |
| 330 #endif | 330 #endif |
| 331 | 331 |
| 332 // Enable the low fragmentation heap for the CRT heap. The heap is not changed | 332 // Enable the low fragmentation heap for the CRT heap. The heap is not changed |
| 333 // if the process is run under the debugger is enabled or if certain gflags | 333 // if the process is run under the debugger is enabled or if certain gflags |
| 334 // are set. | 334 // are set. |
| 335 bool use_lfh = false; | 335 if (parsed_command_line.HasSwitch(switches::kUseLowFragHeapCrt) && |
| 336 if (parsed_command_line.HasSwitch(switches::kUseLowFragHeapCrt)) | 336 (parsed_command_line.GetSwitchValueASCII(switches::kUseLowFragHeapCrt) |
| 337 use_lfh = parsed_command_line.GetSwitchValue(switches::kUseLowFragHeapCrt) | 337 != "false")) { |
| 338 != L"false"; | |
| 339 if (use_lfh) { | |
| 340 void* crt_heap = reinterpret_cast<void*>(_get_heap_handle()); | 338 void* crt_heap = reinterpret_cast<void*>(_get_heap_handle()); |
| 341 ULONG enable_lfh = 2; | 339 ULONG enable_lfh = 2; |
| 342 HeapSetInformation(crt_heap, HeapCompatibilityInformation, | 340 HeapSetInformation(crt_heap, HeapCompatibilityInformation, |
| 343 &enable_lfh, sizeof(enable_lfh)); | 341 &enable_lfh, sizeof(enable_lfh)); |
| 344 } | 342 } |
| 345 #endif | 343 #endif |
| 346 } | 344 } |
| 347 | 345 |
| 348 // Enable the heap profiler if the appropriate command-line switch is | 346 // Enable the heap profiler if the appropriate command-line switch is |
| 349 // present, bailing out of the app we can't. | 347 // present, bailing out of the app we can't. |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 // Disable sync and extensions if we're in "browse without sign-in" mode. | 572 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 575 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 573 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 576 singleton_command_line->AppendSwitch(switches::kDisableSync); | 574 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 577 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 575 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 578 } | 576 } |
| 579 #endif | 577 #endif |
| 580 | 578 |
| 581 base::ProcessId browser_pid = base::GetCurrentProcId(); | 579 base::ProcessId browser_pid = base::GetCurrentProcId(); |
| 582 if (SubprocessIsBrowserChild(process_type)) { | 580 if (SubprocessIsBrowserChild(process_type)) { |
| 583 #if defined(OS_WIN) | 581 #if defined(OS_WIN) |
| 584 std::wstring channel_name = | 582 std::string channel_name = |
| 585 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); | 583 parsed_command_line.GetSwitchValueASCII(switches::kProcessChannelID); |
| 586 | 584 |
| 587 int browser_pid_int; | 585 int browser_pid_int; |
| 588 base::StringToInt(WideToUTF8(channel_name), &browser_pid_int); | 586 base::StringToInt(channel_name, &browser_pid_int); |
| 589 browser_pid = static_cast<base::ProcessId>(browser_pid_int); | 587 browser_pid = static_cast<base::ProcessId>(browser_pid_int); |
| 590 DCHECK_NE(browser_pid, 0u); | 588 DCHECK_NE(browser_pid, 0u); |
| 591 #elif defined(OS_MACOSX) | 589 #elif defined(OS_MACOSX) |
| 592 browser_pid = base::GetCurrentProcId(); | 590 browser_pid = base::GetCurrentProcId(); |
| 593 #elif defined(OS_POSIX) | 591 #elif defined(OS_POSIX) |
| 594 // On linux, we're in the zygote here; so we need the parent process' id. | 592 // On linux, we're in the zygote here; so we need the parent process' id. |
| 595 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); | 593 browser_pid = base::GetParentProcessId(base::GetCurrentProcId()); |
| 596 #endif | 594 #endif |
| 597 | 595 |
| 598 #if defined(OS_POSIX) | 596 #if defined(OS_POSIX) |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 // sources. The language should have been passed in to us from the | 735 // sources. The language should have been passed in to us from the |
| 738 // browser process as a command line flag. | 736 // browser process as a command line flag. |
| 739 DCHECK(parsed_command_line.HasSwitch(switches::kLang) || | 737 DCHECK(parsed_command_line.HasSwitch(switches::kLang) || |
| 740 process_type == switches::kZygoteProcess); | 738 process_type == switches::kZygoteProcess); |
| 741 | 739 |
| 742 // TODO(markusheintz): The command line flag --lang is actually processed | 740 // TODO(markusheintz): The command line flag --lang is actually processed |
| 743 // by the CommandLinePrefStore, and made available through the PrefService | 741 // by the CommandLinePrefStore, and made available through the PrefService |
| 744 // via the preference prefs::kApplicationLocale. The browser process uses | 742 // via the preference prefs::kApplicationLocale. The browser process uses |
| 745 // the --lang flag to passe the value of the PrefService in here. Maybe this | 743 // the --lang flag to passe the value of the PrefService in here. Maybe this |
| 746 // value could be passed in a different way. | 744 // value could be passed in a different way. |
| 747 ResourceBundle::InitSharedInstance( | 745 ResourceBundle::InitSharedInstance(ASCIIToWide( |
| 748 parsed_command_line.GetSwitchValue(switches::kLang)); | 746 parsed_command_line.GetSwitchValueASCII(switches::kLang))); |
| 749 | 747 |
| 750 #if defined(OS_MACOSX) | 748 #if defined(OS_MACOSX) |
| 751 // Update the process name (need resources to get the strings, so | 749 // Update the process name (need resources to get the strings, so |
| 752 // only do this when ResourcesBundle has been initialized). | 750 // only do this when ResourcesBundle has been initialized). |
| 753 SetMacProcessName(process_type); | 751 SetMacProcessName(process_type); |
| 754 #endif // defined(OS_MACOSX) | 752 #endif // defined(OS_MACOSX) |
| 755 } | 753 } |
| 756 | 754 |
| 757 if (!process_type.empty()) | 755 if (!process_type.empty()) |
| 758 CommonSubprocessInit(); | 756 CommonSubprocessInit(); |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 914 |
| 917 logging::CleanupChromeLogging(); | 915 logging::CleanupChromeLogging(); |
| 918 | 916 |
| 919 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) | 917 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) |
| 920 // TODO(mark): See the TODO(mark) above at InitCrashReporter. | 918 // TODO(mark): See the TODO(mark) above at InitCrashReporter. |
| 921 DestructCrashReporter(); | 919 DestructCrashReporter(); |
| 922 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD | 920 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD |
| 923 | 921 |
| 924 return rv; | 922 return rv; |
| 925 } | 923 } |
| OLD | NEW |