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