| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/lazy_instance.h" | 6 #include "base/lazy_instance.h" |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/metrics/stats_counters.h" | 8 #include "base/metrics/stats_counters.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include <gtk/gtk.h> | 82 #include <gtk/gtk.h> |
| 83 #include <stdlib.h> | 83 #include <stdlib.h> |
| 84 #include <string.h> | 84 #include <string.h> |
| 85 #include "ui/base/x/x11_util.h" | 85 #include "ui/base/x/x11_util.h" |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 #if defined(USE_LINUX_BREAKPAD) | 88 #if defined(USE_LINUX_BREAKPAD) |
| 89 #include "chrome/app/breakpad_linux.h" | 89 #include "chrome/app/breakpad_linux.h" |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 #if !defined(NACL_WIN64) // We don't build the this code on win nacl64. | |
| 93 base::LazyInstance<chrome::ChromeContentBrowserClient> | 92 base::LazyInstance<chrome::ChromeContentBrowserClient> |
| 94 g_chrome_content_browser_client(base::LINKER_INITIALIZED); | 93 g_chrome_content_browser_client(base::LINKER_INITIALIZED); |
| 95 base::LazyInstance<chrome::ChromeContentRendererClient> | 94 base::LazyInstance<chrome::ChromeContentRendererClient> |
| 96 g_chrome_content_renderer_client(base::LINKER_INITIALIZED); | 95 g_chrome_content_renderer_client(base::LINKER_INITIALIZED); |
| 97 base::LazyInstance<chrome::ChromeContentUtilityClient> | 96 base::LazyInstance<chrome::ChromeContentUtilityClient> |
| 98 g_chrome_content_utility_client(base::LINKER_INITIALIZED); | 97 g_chrome_content_utility_client(base::LINKER_INITIALIZED); |
| 99 #endif // NACL_WIN64 | |
| 100 | |
| 101 base::LazyInstance<chrome::ChromeContentPluginClient> | 98 base::LazyInstance<chrome::ChromeContentPluginClient> |
| 102 g_chrome_content_plugin_client(base::LINKER_INITIALIZED); | 99 g_chrome_content_plugin_client(base::LINKER_INITIALIZED); |
| 103 | 100 |
| 104 extern int RendererMain(const MainFunctionParams&); | 101 extern int RendererMain(const MainFunctionParams&); |
| 105 extern int NaClMain(const MainFunctionParams&); | 102 extern int NaClMain(const MainFunctionParams&); |
| 106 extern int ProfileImportMain(const MainFunctionParams&); | 103 extern int ProfileImportMain(const MainFunctionParams&); |
| 107 #if defined(_WIN64) | |
| 108 extern int NaClBrokerMain(const MainFunctionParams&); | |
| 109 #endif | |
| 110 extern int ServiceProcessMain(const MainFunctionParams&); | 104 extern int ServiceProcessMain(const MainFunctionParams&); |
| 111 | 105 |
| 112 #if defined(OS_WIN) | 106 #if defined(OS_WIN) |
| 113 // TODO(erikkay): isn't this already defined somewhere? | |
| 114 #define DLLEXPORT __declspec(dllexport) | 107 #define DLLEXPORT __declspec(dllexport) |
| 115 | 108 |
| 116 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. | 109 // We use extern C for the prototype DLLEXPORT to avoid C++ name mangling. |
| 117 extern "C" { | 110 extern "C" { |
| 118 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, | 111 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, |
| 119 sandbox::SandboxInterfaceInfo* sandbox_info); | 112 sandbox::SandboxInterfaceInfo* sandbox_info); |
| 120 } | 113 } |
| 121 #elif defined(OS_POSIX) | 114 #elif defined(OS_POSIX) |
| 122 extern "C" { | 115 extern "C" { |
| 123 __attribute__((visibility("default"))) | 116 __attribute__((visibility("default"))) |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 // present, bailing out of the app we can't. | 257 // present, bailing out of the app we can't. |
| 265 void EnableHeapProfiler(const CommandLine& command_line) { | 258 void EnableHeapProfiler(const CommandLine& command_line) { |
| 266 #if defined(OS_WIN) | 259 #if defined(OS_WIN) |
| 267 if (command_line.HasSwitch(switches::kMemoryProfiling)) | 260 if (command_line.HasSwitch(switches::kMemoryProfiling)) |
| 268 if (!LoadMemoryProfiler()) | 261 if (!LoadMemoryProfiler()) |
| 269 exit(-1); | 262 exit(-1); |
| 270 #endif | 263 #endif |
| 271 } | 264 } |
| 272 | 265 |
| 273 void InitializeChromeContentRendererClient() { | 266 void InitializeChromeContentRendererClient() { |
| 274 #if !defined(NACL_WIN64) // We don't build the renderer code on win nacl64. | |
| 275 content::GetContentClient()->set_renderer( | 267 content::GetContentClient()->set_renderer( |
| 276 &g_chrome_content_renderer_client.Get()); | 268 &g_chrome_content_renderer_client.Get()); |
| 277 #endif | |
| 278 } | 269 } |
| 279 | 270 |
| 280 void InitializeChromeContentClient(const std::string& process_type) { | 271 void InitializeChromeContentClient(const std::string& process_type) { |
| 281 if (process_type.empty()) { | 272 if (process_type.empty()) { |
| 282 #if !defined(NACL_WIN64) // We don't build the this code on win nacl64. | |
| 283 content::GetContentClient()->set_browser( | 273 content::GetContentClient()->set_browser( |
| 284 &g_chrome_content_browser_client.Get()); | 274 &g_chrome_content_browser_client.Get()); |
| 285 #endif | |
| 286 } else if (process_type == switches::kPluginProcess) { | 275 } else if (process_type == switches::kPluginProcess) { |
| 287 content::GetContentClient()->set_plugin( | 276 content::GetContentClient()->set_plugin( |
| 288 &g_chrome_content_plugin_client.Get()); | 277 &g_chrome_content_plugin_client.Get()); |
| 289 } else if (process_type == switches::kRendererProcess || | 278 } else if (process_type == switches::kRendererProcess || |
| 290 process_type == switches::kExtensionProcess) { | 279 process_type == switches::kExtensionProcess) { |
| 291 InitializeChromeContentRendererClient(); | 280 InitializeChromeContentRendererClient(); |
| 292 } else if (process_type == switches::kUtilityProcess) { | 281 } else if (process_type == switches::kUtilityProcess) { |
| 293 #if !defined(NACL_WIN64) // We don't build this code on win nacl64. | |
| 294 content::GetContentClient()->set_utility( | 282 content::GetContentClient()->set_utility( |
| 295 &g_chrome_content_utility_client.Get()); | 283 &g_chrome_content_utility_client.Get()); |
| 296 #endif | |
| 297 } | 284 } |
| 298 } | 285 } |
| 299 | 286 |
| 300 // Returns true if this subprocess type needs the ResourceBundle initialized | 287 // Returns true if this subprocess type needs the ResourceBundle initialized |
| 301 // and resources loaded. | 288 // and resources loaded. |
| 302 bool SubprocessNeedsResourceBundle(const std::string& process_type) { | 289 bool SubprocessNeedsResourceBundle(const std::string& process_type) { |
| 303 return | 290 return |
| 304 #if defined(OS_WIN) || defined(OS_MACOSX) | 291 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 305 // Windows needs resources for the default/null plugin. | 292 // Windows needs resources for the default/null plugin. |
| 306 // Mac needs them for the plugin process name. | 293 // Mac needs them for the plugin process name. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 { switches::kExtensionProcess, RendererMain }, | 648 { switches::kExtensionProcess, RendererMain }, |
| 662 { switches::kServiceProcess, ServiceProcessMain }, | 649 { switches::kServiceProcess, ServiceProcessMain }, |
| 663 #if defined(OS_MACOSX) | 650 #if defined(OS_MACOSX) |
| 664 // TODO(port): Use OOP profile import - http://crbug.com/22142 . | 651 // TODO(port): Use OOP profile import - http://crbug.com/22142 . |
| 665 { switches::kProfileImportProcess, ProfileImportMain }, | 652 { switches::kProfileImportProcess, ProfileImportMain }, |
| 666 { switches::kRelauncherProcess, | 653 { switches::kRelauncherProcess, |
| 667 mac_relauncher::internal::RelauncherMain }, | 654 mac_relauncher::internal::RelauncherMain }, |
| 668 #endif | 655 #endif |
| 669 #if !defined(DISABLE_NACL) | 656 #if !defined(DISABLE_NACL) |
| 670 { switches::kNaClLoaderProcess, NaClMain }, | 657 { switches::kNaClLoaderProcess, NaClMain }, |
| 671 #if defined(_WIN64) // The broker process is used only on Win64. | |
| 672 { switches::kNaClBrokerProcess, NaClBrokerMain }, | |
| 673 #endif | |
| 674 #endif // DISABLE_NACL | 658 #endif // DISABLE_NACL |
| 675 }; | 659 }; |
| 676 | 660 |
| 677 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 661 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
| 678 if (process_type == kMainFunctions[i].name) | 662 if (process_type == kMainFunctions[i].name) |
| 679 return kMainFunctions[i].function(main_function_params); | 663 return kMainFunctions[i].function(main_function_params); |
| 680 } | 664 } |
| 681 | 665 |
| 682 NOTREACHED() << "Unknown process type: " << process_type; | 666 NOTREACHED() << "Unknown process type: " << process_type; |
| 683 return 1; | 667 return 1; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, | 741 DLLEXPORT int __cdecl ChromeMain(HINSTANCE instance, |
| 758 sandbox::SandboxInterfaceInfo* sandbox_info) { | 742 sandbox::SandboxInterfaceInfo* sandbox_info) { |
| 759 ChromeMainDelegate chrome_main_delegate; | 743 ChromeMainDelegate chrome_main_delegate; |
| 760 return content::ContentMain(instance, sandbox_info, &chrome_main_delegate); | 744 return content::ContentMain(instance, sandbox_info, &chrome_main_delegate); |
| 761 #elif defined(OS_POSIX) | 745 #elif defined(OS_POSIX) |
| 762 int ChromeMain(int argc, char** argv) { | 746 int ChromeMain(int argc, char** argv) { |
| 763 ChromeMainDelegate chrome_main_delegate; | 747 ChromeMainDelegate chrome_main_delegate; |
| 764 return content::ContentMain(argc, argv, &chrome_main_delegate); | 748 return content::ContentMain(argc, argv, &chrome_main_delegate); |
| 765 #endif | 749 #endif |
| 766 } | 750 } |
| OLD | NEW |