OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/app/chrome_main.h" | 5 #include "chrome/app/chrome_main.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/debug/debugger.h" | 9 #include "base/debug/debugger.h" |
10 #include "base/i18n/icu_util.h" | 10 #include "base/i18n/icu_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/common/content_paths.h" | 40 #include "content/common/content_paths.h" |
41 #include "content/common/main_function_params.h" | 41 #include "content/common/main_function_params.h" |
42 #include "content/common/sandbox_init_wrapper.h" | 42 #include "content/common/sandbox_init_wrapper.h" |
43 #include "content/common/set_process_title.h" | 43 #include "content/common/set_process_title.h" |
44 #include "ipc/ipc_switches.h" | 44 #include "ipc/ipc_switches.h" |
45 #include "media/base/media.h" | 45 #include "media/base/media.h" |
46 #include "ui/base/resource/resource_bundle.h" | 46 #include "ui/base/resource/resource_bundle.h" |
47 #include "ui/base/ui_base_paths.h" | 47 #include "ui/base/ui_base_paths.h" |
48 #include "ui/base/ui_base_switches.h" | 48 #include "ui/base/ui_base_switches.h" |
49 | 49 |
50 #if defined(OS_POSIX) && !defined(OS_MACOSX) | |
51 #include "chrome/common/nacl_fork_delegate_linux.h" | |
52 #include "content/common/zygote_fork_delegate_linux.h" | |
53 #endif | |
54 | |
55 #if defined(OS_WIN) | 50 #if defined(OS_WIN) |
56 #include <algorithm> | 51 #include <algorithm> |
57 #include <malloc.h> | 52 #include <malloc.h> |
58 #include "base/string_util.h" | 53 #include "base/string_util.h" |
59 #include "base/win/registry.h" | 54 #include "base/win/registry.h" |
60 #include "sandbox/src/sandbox.h" | 55 #include "sandbox/src/sandbox.h" |
61 #include "tools/memory_watcher/memory_watcher.h" | 56 #include "tools/memory_watcher/memory_watcher.h" |
62 #endif | 57 #endif |
63 | 58 |
64 #if defined(OS_MACOSX) | 59 #if defined(OS_MACOSX) |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 extern int BrowserMain(const MainFunctionParams&); | 105 extern int BrowserMain(const MainFunctionParams&); |
111 extern int RendererMain(const MainFunctionParams&); | 106 extern int RendererMain(const MainFunctionParams&); |
112 extern int GpuMain(const MainFunctionParams&); | 107 extern int GpuMain(const MainFunctionParams&); |
113 extern int PluginMain(const MainFunctionParams&); | 108 extern int PluginMain(const MainFunctionParams&); |
114 extern int PpapiPluginMain(const MainFunctionParams&); | 109 extern int PpapiPluginMain(const MainFunctionParams&); |
115 extern int PpapiBrokerMain(const MainFunctionParams&); | 110 extern int PpapiBrokerMain(const MainFunctionParams&); |
116 extern int WorkerMain(const MainFunctionParams&); | 111 extern int WorkerMain(const MainFunctionParams&); |
117 extern int NaClMain(const MainFunctionParams&); | 112 extern int NaClMain(const MainFunctionParams&); |
118 extern int UtilityMain(const MainFunctionParams&); | 113 extern int UtilityMain(const MainFunctionParams&); |
119 extern int ProfileImportMain(const MainFunctionParams&); | 114 extern int ProfileImportMain(const MainFunctionParams&); |
120 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 115 extern int ZygoteMain(const MainFunctionParams&); |
121 extern int ZygoteMain(const MainFunctionParams&, const ZygoteForkDelegate&); | |
122 #endif | |
123 #if defined(_WIN64) | 116 #if defined(_WIN64) |
124 extern int NaClBrokerMain(const MainFunctionParams&); | 117 extern int NaClBrokerMain(const MainFunctionParams&); |
125 #endif | 118 #endif |
126 extern int ServiceProcessMain(const MainFunctionParams&); | 119 extern int ServiceProcessMain(const MainFunctionParams&); |
127 | 120 |
128 #if defined(OS_WIN) | 121 #if defined(OS_WIN) |
129 // TODO(erikkay): isn't this already defined somewhere? | 122 // TODO(erikkay): isn't this already defined somewhere? |
130 #define DLLEXPORT __declspec(dllexport) | 123 #define DLLEXPORT __declspec(dllexport) |
131 | 124 |
132 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 125 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 }; | 443 }; |
451 | 444 |
452 // Each Renderer we spawn will re-attempt initialization of the media | 445 // Each Renderer we spawn will re-attempt initialization of the media |
453 // libraries, at which point failure will be detected and handled, so | 446 // libraries, at which point failure will be detected and handled, so |
454 // we do not need to cope with initialization failures here. | 447 // we do not need to cope with initialization failures here. |
455 FilePath media_path; | 448 FilePath media_path; |
456 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) | 449 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) |
457 media::InitializeMediaLibrary(media_path); | 450 media::InitializeMediaLibrary(media_path); |
458 | 451 |
459 // This function call can return multiple times, once per fork(). | 452 // This function call can return multiple times, once per fork(). |
460 NaClForkDelegate nacl_fork_delegate; | 453 if (!ZygoteMain(main_function_params)) |
461 if (!ZygoteMain(main_function_params, nacl_fork_delegate)) | |
462 return 1; | 454 return 1; |
463 | 455 |
464 // Zygote::HandleForkRequest may have reallocated the command | 456 // Zygote::HandleForkRequest may have reallocated the command |
465 // line so update it here with the new version. | 457 // line so update it here with the new version. |
466 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 458 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
467 | 459 |
468 // The StatsTable must be initialized in each process; we already | 460 // The StatsTable must be initialized in each process; we already |
469 // initialized for the browser process, now we need to initialize | 461 // initialized for the browser process, now we need to initialize |
470 // within the new processes as well. | 462 // within the new processes as well. |
471 pid_t browser_pid = base::GetParentProcessId( | 463 pid_t browser_pid = base::GetParentProcessId( |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 | 854 |
863 if (SubprocessNeedsResourceBundle(process_type)) | 855 if (SubprocessNeedsResourceBundle(process_type)) |
864 ResourceBundle::CleanupSharedInstance(); | 856 ResourceBundle::CleanupSharedInstance(); |
865 | 857 |
866 logging::CleanupChromeLogging(); | 858 logging::CleanupChromeLogging(); |
867 | 859 |
868 chrome_main::LowLevelShutdown(); | 860 chrome_main::LowLevelShutdown(); |
869 | 861 |
870 return exit_code; | 862 return exit_code; |
871 } | 863 } |
OLD | NEW |