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 "app/app_paths.h" | 7 #include "app/app_paths.h" |
8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/debugger.h" | 10 #include "base/debug/debugger.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "content/common/content_paths.h" | 42 #include "content/common/content_paths.h" |
43 #include "content/common/main_function_params.h" | 43 #include "content/common/main_function_params.h" |
44 #include "content/common/sandbox_init_wrapper.h" | 44 #include "content/common/sandbox_init_wrapper.h" |
45 #include "content/common/set_process_title.h" | 45 #include "content/common/set_process_title.h" |
46 #include "ipc/ipc_switches.h" | 46 #include "ipc/ipc_switches.h" |
47 #include "media/base/media.h" | 47 #include "media/base/media.h" |
48 #include "ui/base/resource/resource_bundle.h" | 48 #include "ui/base/resource/resource_bundle.h" |
49 #include "ui/base/ui_base_paths.h" | 49 #include "ui/base/ui_base_paths.h" |
50 #include "ui/base/ui_base_switches.h" | 50 #include "ui/base/ui_base_switches.h" |
51 | 51 |
| 52 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 53 #include "chrome/common/nacl_fork_delegate_linux.h" |
| 54 #include "content/common/zygote_fork_delegate_linux.h" |
| 55 #endif |
| 56 |
52 #if defined(OS_WIN) | 57 #if defined(OS_WIN) |
53 #include <algorithm> | 58 #include <algorithm> |
54 #include <malloc.h> | 59 #include <malloc.h> |
55 #include "base/string_util.h" | 60 #include "base/string_util.h" |
56 #include "base/win/registry.h" | 61 #include "base/win/registry.h" |
57 #include "sandbox/src/sandbox.h" | 62 #include "sandbox/src/sandbox.h" |
58 #include "tools/memory_watcher/memory_watcher.h" | 63 #include "tools/memory_watcher/memory_watcher.h" |
59 #endif | 64 #endif |
60 | 65 |
61 #if defined(OS_MACOSX) | 66 #if defined(OS_MACOSX) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 extern int BrowserMain(const MainFunctionParams&); | 111 extern int BrowserMain(const MainFunctionParams&); |
107 extern int RendererMain(const MainFunctionParams&); | 112 extern int RendererMain(const MainFunctionParams&); |
108 extern int GpuMain(const MainFunctionParams&); | 113 extern int GpuMain(const MainFunctionParams&); |
109 extern int PluginMain(const MainFunctionParams&); | 114 extern int PluginMain(const MainFunctionParams&); |
110 extern int PpapiPluginMain(const MainFunctionParams&); | 115 extern int PpapiPluginMain(const MainFunctionParams&); |
111 extern int PpapiBrokerMain(const MainFunctionParams&); | 116 extern int PpapiBrokerMain(const MainFunctionParams&); |
112 extern int WorkerMain(const MainFunctionParams&); | 117 extern int WorkerMain(const MainFunctionParams&); |
113 extern int NaClMain(const MainFunctionParams&); | 118 extern int NaClMain(const MainFunctionParams&); |
114 extern int UtilityMain(const MainFunctionParams&); | 119 extern int UtilityMain(const MainFunctionParams&); |
115 extern int ProfileImportMain(const MainFunctionParams&); | 120 extern int ProfileImportMain(const MainFunctionParams&); |
116 extern int ZygoteMain(const MainFunctionParams&); | 121 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
| 122 extern int ZygoteMain(const MainFunctionParams&, |
| 123 ZygoteForkDelegate* forkdelegate); |
| 124 #endif |
117 #if defined(_WIN64) | 125 #if defined(_WIN64) |
118 extern int NaClBrokerMain(const MainFunctionParams&); | 126 extern int NaClBrokerMain(const MainFunctionParams&); |
119 #endif | 127 #endif |
120 extern int ServiceProcessMain(const MainFunctionParams&); | 128 extern int ServiceProcessMain(const MainFunctionParams&); |
121 | 129 |
122 #if defined(OS_WIN) | 130 #if defined(OS_WIN) |
123 // TODO(erikkay): isn't this already defined somewhere? | 131 // TODO(erikkay): isn't this already defined somewhere? |
124 #define DLLEXPORT __declspec(dllexport) | 132 #define DLLEXPORT __declspec(dllexport) |
125 | 133 |
126 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 134 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 }; | 440 }; |
433 | 441 |
434 // Each Renderer we spawn will re-attempt initialization of the media | 442 // Each Renderer we spawn will re-attempt initialization of the media |
435 // libraries, at which point failure will be detected and handled, so | 443 // libraries, at which point failure will be detected and handled, so |
436 // we do not need to cope with initialization failures here. | 444 // we do not need to cope with initialization failures here. |
437 FilePath media_path; | 445 FilePath media_path; |
438 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) | 446 if (PathService::Get(chrome::DIR_MEDIA_LIBS, &media_path)) |
439 media::InitializeMediaLibrary(media_path); | 447 media::InitializeMediaLibrary(media_path); |
440 | 448 |
441 // This function call can return multiple times, once per fork(). | 449 // This function call can return multiple times, once per fork(). |
442 if (!ZygoteMain(main_function_params)) | 450 if (!ZygoteMain(main_function_params, new NaClForkDelegate())) |
443 return 1; | 451 return 1; |
444 | 452 |
445 // Zygote::HandleForkRequest may have reallocated the command | 453 // Zygote::HandleForkRequest may have reallocated the command |
446 // line so update it here with the new version. | 454 // line so update it here with the new version. |
447 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 455 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
448 | 456 |
449 // The StatsTable must be initialized in each process; we already | 457 // The StatsTable must be initialized in each process; we already |
450 // initialized for the browser process, now we need to initialize | 458 // initialized for the browser process, now we need to initialize |
451 // within the new processes as well. | 459 // within the new processes as well. |
452 pid_t browser_pid = base::GetParentProcessId( | 460 pid_t browser_pid = base::GetParentProcessId( |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
839 | 847 |
840 if (SubprocessNeedsResourceBundle(process_type)) | 848 if (SubprocessNeedsResourceBundle(process_type)) |
841 ResourceBundle::CleanupSharedInstance(); | 849 ResourceBundle::CleanupSharedInstance(); |
842 | 850 |
843 logging::CleanupChromeLogging(); | 851 logging::CleanupChromeLogging(); |
844 | 852 |
845 chrome_main::LowLevelShutdown(); | 853 chrome_main::LowLevelShutdown(); |
846 | 854 |
847 return exit_code; | 855 return exit_code; |
848 } | 856 } |
OLD | NEW |