OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "base/path_service.h" | 42 #include "base/path_service.h" |
43 #include "base/process_util.h" | 43 #include "base/process_util.h" |
44 #include "base/scoped_nsautorelease_pool.h" | 44 #include "base/scoped_nsautorelease_pool.h" |
45 #include "base/stats_counters.h" | 45 #include "base/stats_counters.h" |
46 #include "base/stats_table.h" | 46 #include "base/stats_table.h" |
47 #include "base/string_util.h" | 47 #include "base/string_util.h" |
48 #if defined(OS_WIN) | 48 #if defined(OS_WIN) |
49 #include "base/win_util.h" | 49 #include "base/win_util.h" |
50 #endif | 50 #endif |
51 #if defined(OS_MACOSX) | 51 #if defined(OS_MACOSX) |
| 52 #include "base/mac_util.h" |
| 53 #include "chrome/common/chrome_paths_internal.h" |
52 #include "chrome/app/breakpad_mac.h" | 54 #include "chrome/app/breakpad_mac.h" |
53 #endif | 55 #endif |
54 #if defined(OS_LINUX) | 56 #if defined(OS_LINUX) |
55 #include "chrome/app/breakpad_linux.h" | 57 #include "chrome/app/breakpad_linux.h" |
56 #endif | 58 #endif |
57 #include "chrome/app/scoped_ole_initializer.h" | 59 #include "chrome/app/scoped_ole_initializer.h" |
58 #include "chrome/browser/renderer_host/render_process_host.h" | 60 #include "chrome/browser/renderer_host/render_process_host.h" |
59 #include "chrome/common/chrome_constants.h" | 61 #include "chrome/common/chrome_constants.h" |
60 #include "chrome/common/chrome_counters.h" | 62 #include "chrome/common/chrome_counters.h" |
61 #include "chrome/common/chrome_descriptors.h" | 63 #include "chrome/common/chrome_descriptors.h" |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 #endif | 330 #endif |
329 | 331 |
330 // Initialize the command line. | 332 // Initialize the command line. |
331 #if defined(OS_WIN) | 333 #if defined(OS_WIN) |
332 CommandLine::Init(0, NULL); | 334 CommandLine::Init(0, NULL); |
333 #else | 335 #else |
334 CommandLine::Init(argc, argv); | 336 CommandLine::Init(argc, argv); |
335 #endif | 337 #endif |
336 | 338 |
337 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); | 339 const CommandLine& parsed_command_line = *CommandLine::ForCurrentProcess(); |
| 340 std::wstring process_type = |
| 341 parsed_command_line.GetSwitchValue(switches::kProcessType); |
| 342 |
| 343 #if defined(OS_MACOSX) |
| 344 // If process_type is not empty, this is the helper. Set the main app bundle |
| 345 // so code can fetch Mac resources. |
| 346 if (!process_type.empty()) { |
| 347 FilePath main_path(chrome::GetBrowserBundlePath()); |
| 348 mac_util::SetOverrideAppBundlePath(main_path); |
| 349 } |
| 350 #endif // OS_MACOSX |
338 | 351 |
339 #if defined(OS_WIN) | 352 #if defined(OS_WIN) |
340 // Must do this before any other usage of command line! | 353 // Must do this before any other usage of command line! |
341 if (HasDeprecatedArguments(parsed_command_line.command_line_string())) | 354 if (HasDeprecatedArguments(parsed_command_line.command_line_string())) |
342 return 1; | 355 return 1; |
343 #endif | 356 #endif |
344 | 357 |
345 #if defined(OS_LINUX) | 358 #if defined(OS_LINUX) |
346 // Show the man page on --help or -h. | 359 // Show the man page on --help or -h. |
347 if (parsed_command_line.HasSwitch(L"help") || | 360 if (parsed_command_line.HasSwitch(L"help") || |
(...skipping 18 matching lines...) Expand all Loading... |
366 } | 379 } |
367 #endif | 380 #endif |
368 #endif | 381 #endif |
369 | 382 |
370 #if defined(OS_POSIX) | 383 #if defined(OS_POSIX) |
371 // Always ignore SIGPIPE. We check the return value of write(). | 384 // Always ignore SIGPIPE. We check the return value of write(). |
372 CHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR); | 385 CHECK(signal(SIGPIPE, SIG_IGN) != SIG_ERR); |
373 #endif // OS_POSIX | 386 #endif // OS_POSIX |
374 | 387 |
375 int browser_pid; | 388 int browser_pid; |
376 std::wstring process_type = | |
377 parsed_command_line.GetSwitchValue(switches::kProcessType); | |
378 if (process_type.empty()) { | 389 if (process_type.empty()) { |
379 browser_pid = base::GetCurrentProcId(); | 390 browser_pid = base::GetCurrentProcId(); |
380 } else { | 391 } else { |
381 #if defined(OS_WIN) | 392 #if defined(OS_WIN) |
382 std::wstring channel_name = | 393 std::wstring channel_name = |
383 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); | 394 parsed_command_line.GetSwitchValue(switches::kProcessChannelID); |
384 | 395 |
385 browser_pid = StringToInt(WideToASCII(channel_name)); | 396 browser_pid = StringToInt(WideToASCII(channel_name)); |
386 DCHECK(browser_pid != 0); | 397 DCHECK(browser_pid != 0); |
387 #else | 398 #else |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 583 |
573 logging::CleanupChromeLogging(); | 584 logging::CleanupChromeLogging(); |
574 | 585 |
575 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) | 586 #if defined(OS_MACOSX) && defined(GOOGLE_CHROME_BUILD) |
576 // TODO(mark): See the TODO(mark) above at InitCrashReporter. | 587 // TODO(mark): See the TODO(mark) above at InitCrashReporter. |
577 DestructCrashReporter(); | 588 DestructCrashReporter(); |
578 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD | 589 #endif // OS_MACOSX && GOOGLE_CHROME_BUILD |
579 | 590 |
580 return rv; | 591 return rv; |
581 } | 592 } |
OLD | NEW |