OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 91 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
92 extern "C" { | 92 extern "C" { |
93 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, | 93 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, |
94 sandbox::SandboxInterfaceInfo* sandbox_info, | 94 sandbox::SandboxInterfaceInfo* sandbox_info, |
95 TCHAR* command_line); | 95 TCHAR* command_line); |
96 } | 96 } |
97 #elif defined(OS_POSIX) | 97 #elif defined(OS_POSIX) |
98 extern "C" { | 98 extern "C" { |
99 __attribute__((visibility("default"))) | 99 __attribute__((visibility("default"))) |
100 int ChromeMain(int argc, const char** argv); | 100 int ChromeMain(int argc, char** argv); |
101 } | 101 } |
102 #endif | 102 #endif |
103 | 103 |
104 namespace { | 104 namespace { |
105 | 105 |
106 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
107 const wchar_t kProfilingDll[] = L"memory_watcher.dll"; | 107 const wchar_t kProfilingDll[] = L"memory_watcher.dll"; |
108 | 108 |
109 // Load the memory profiling DLL. All it needs to be activated | 109 // Load the memory profiling DLL. All it needs to be activated |
110 // is to be loaded. Return true on success, false otherwise. | 110 // is to be loaded. Return true on success, false otherwise. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 #endif | 291 #endif |
292 } | 292 } |
293 | 293 |
294 } // namespace | 294 } // namespace |
295 | 295 |
296 #if defined(OS_WIN) | 296 #if defined(OS_WIN) |
297 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, | 297 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, |
298 sandbox::SandboxInterfaceInfo* sandbox_info, | 298 sandbox::SandboxInterfaceInfo* sandbox_info, |
299 TCHAR* command_line) { | 299 TCHAR* command_line) { |
300 #elif defined(OS_POSIX) | 300 #elif defined(OS_POSIX) |
301 int ChromeMain(int argc, const char** argv) { | 301 int ChromeMain(int argc, char** argv) { |
302 #endif | 302 #endif |
303 | 303 |
304 #if defined(OS_MACOSX) | 304 #if defined(OS_MACOSX) |
305 // TODO(mark): Some of these things ought to be handled in chrome_exe_main.mm. | 305 // TODO(mark): Some of these things ought to be handled in chrome_exe_main.mm. |
306 // Under the current architecture, nothing in chrome_exe_main can rely | 306 // Under the current architecture, nothing in chrome_exe_main can rely |
307 // directly on chrome_dll code on the Mac, though, so until some of this code | 307 // directly on chrome_dll code on the Mac, though, so until some of this code |
308 // is refactored to avoid such a dependency, it lives here. See also the | 308 // is refactored to avoid such a dependency, it lives here. See also the |
309 // TODO(mark) below at InitCrashReporter() and DestructCrashReporter(). | 309 // TODO(mark) below at InitCrashReporter() and DestructCrashReporter(). |
310 base::EnableTerminationOnHeapCorruption(); | 310 base::EnableTerminationOnHeapCorruption(); |
311 #endif // OS_MACOSX | 311 #endif // OS_MACOSX |
(...skipping 24 matching lines...) Expand all Loading... |
336 // in correct encoding. | 336 // in correct encoding. |
337 setlocale(LC_ALL, ""); | 337 setlocale(LC_ALL, ""); |
338 #endif | 338 #endif |
339 | 339 |
340 // Initialize the command line. | 340 // Initialize the command line. |
341 #if defined(OS_WIN) | 341 #if defined(OS_WIN) |
342 CommandLine::Init(0, NULL); | 342 CommandLine::Init(0, NULL); |
343 #else | 343 #else |
344 CommandLine::Init(argc, argv); | 344 CommandLine::Init(argc, argv); |
345 #endif | 345 #endif |
| 346 #if defined(OS_LINUX) |
| 347 // Set up CommandLine::SetProcTitle() support. |
| 348 CommandLine::SetTrueArgv(argv); |
| 349 #endif |
346 | 350 |
347 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 351 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
348 std::wstring process_type = | 352 std::wstring process_type = |
349 parsed_command_line.GetSwitchValue(switches::kProcessType); | 353 parsed_command_line.GetSwitchValue(switches::kProcessType); |
350 | 354 |
351 #if defined(OS_MACOSX) | 355 #if defined(OS_MACOSX) |
352 // If process_type is not empty, this is the helper. Set the main app bundle | 356 // If process_type is not empty, this is the helper. Set the main app bundle |
353 // so code can fetch Mac resources. | 357 // so code can fetch Mac resources. |
354 if (!process_type.empty()) { | 358 if (!process_type.empty()) { |
355 FilePath main_path(chrome::GetBrowserBundlePath()); | 359 FilePath main_path(chrome::GetBrowserBundlePath()); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 // We want to be sure to init NSPR on the main thread. | 591 // We want to be sure to init NSPR on the main thread. |
588 base::EnsureNSPRInit(); | 592 base::EnsureNSPRInit(); |
589 | 593 |
590 g_thread_init(NULL); | 594 g_thread_init(NULL); |
591 // Glib type system initialization. Needed at least for gconf, | 595 // Glib type system initialization. Needed at least for gconf, |
592 // used in net/proxy/proxy_config_service_linux.cc. Most likely | 596 // used in net/proxy/proxy_config_service_linux.cc. Most likely |
593 // this is superfluous as gtk_init() ought to do this. It's | 597 // this is superfluous as gtk_init() ought to do this. It's |
594 // definitely harmless, so retained as a reminder of this | 598 // definitely harmless, so retained as a reminder of this |
595 // requirement for gconf. | 599 // requirement for gconf. |
596 g_type_init(); | 600 g_type_init(); |
597 // gtk_init() can change |argc| and |argv|, but nobody else uses them. | 601 // gtk_init() can change |argc| and |argv|. |
598 gtk_init(&argc, const_cast<char***>(&argv)); | 602 gtk_init(&argc, &argv); |
599 SetUpGLibLogHandler(); | 603 SetUpGLibLogHandler(); |
600 #endif | 604 #endif |
601 | 605 |
602 ScopedOleInitializer ole_initializer; | 606 ScopedOleInitializer ole_initializer; |
603 rv = BrowserMain(main_params); | 607 rv = BrowserMain(main_params); |
604 } else { | 608 } else { |
605 NOTREACHED() << "Unknown process type"; | 609 NOTREACHED() << "Unknown process type"; |
606 } | 610 } |
607 | 611 |
608 if (!process_type.empty()) { | 612 if (!process_type.empty()) { |
(...skipping 10 matching lines...) Expand all Loading... |
619 | 623 |
620 logging::CleanupChromeLogging(); | 624 logging::CleanupChromeLogging(); |
621 | 625 |
622 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) | 626 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) |
623 // TODO(mark): See the TODO(mark) above at InitCrashReporter. | 627 // TODO(mark): See the TODO(mark) above at InitCrashReporter. |
624 DestructCrashReporter(); | 628 DestructCrashReporter(); |
625 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD | 629 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD |
626 | 630 |
627 return rv; | 631 return rv; |
628 } | 632 } |
OLD | NEW |