| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/public/app/content_main_runner.h" | 5 #include "content/public/app/content_main_runner.h" |
| 6 | 6 |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "base/allocator/allocator_extension.h" | 9 #include "base/allocator/allocator_extension.h" |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 #endif | 118 #endif |
| 119 extern int PpapiPluginMain(const MainFunctionParams&); | 119 extern int PpapiPluginMain(const MainFunctionParams&); |
| 120 extern int PpapiBrokerMain(const MainFunctionParams&); | 120 extern int PpapiBrokerMain(const MainFunctionParams&); |
| 121 #endif | 121 #endif |
| 122 extern int RendererMain(const content::MainFunctionParams&); | 122 extern int RendererMain(const content::MainFunctionParams&); |
| 123 extern int UtilityMain(const MainFunctionParams&); | 123 extern int UtilityMain(const MainFunctionParams&); |
| 124 } // namespace content | 124 } // namespace content |
| 125 | 125 |
| 126 namespace content { | 126 namespace content { |
| 127 | 127 |
| 128 #if !defined(CHROME_MULTIPLE_DLL_CHILD) |
| 128 base::LazyInstance<ContentBrowserClient> | 129 base::LazyInstance<ContentBrowserClient> |
| 129 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; | 130 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; |
| 131 #endif // !CHROME_MULTIPLE_DLL_CHILD |
| 132 |
| 130 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) | 133 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 131 base::LazyInstance<ContentPluginClient> | 134 base::LazyInstance<ContentPluginClient> |
| 132 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; | 135 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; |
| 133 base::LazyInstance<ContentRendererClient> | 136 base::LazyInstance<ContentRendererClient> |
| 134 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 137 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| 135 base::LazyInstance<ContentUtilityClient> | 138 base::LazyInstance<ContentUtilityClient> |
| 136 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 139 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
| 137 #endif // !OS_IOS && !CHROME_MULTIPLE_DLL_BROWSER | 140 #endif // !OS_IOS && !CHROME_MULTIPLE_DLL_BROWSER |
| 138 | 141 |
| 139 #if defined(OS_WIN) | 142 #if defined(OS_WIN) |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 new base::StatsTable(table_ident, kStatsMaxThreads, kStatsMaxCounters); | 238 new base::StatsTable(table_ident, kStatsMaxThreads, kStatsMaxCounters); |
| 236 base::StatsTable::set_current(stats_table); | 239 base::StatsTable::set_current(stats_table); |
| 237 } | 240 } |
| 238 } | 241 } |
| 239 | 242 |
| 240 class ContentClientInitializer { | 243 class ContentClientInitializer { |
| 241 public: | 244 public: |
| 242 static void Set(const std::string& process_type, | 245 static void Set(const std::string& process_type, |
| 243 ContentMainDelegate* delegate) { | 246 ContentMainDelegate* delegate) { |
| 244 ContentClient* content_client = GetContentClient(); | 247 ContentClient* content_client = GetContentClient(); |
| 248 #if !defined(CHROME_MULTIPLE_DLL_CHILD) |
| 245 if (process_type.empty()) { | 249 if (process_type.empty()) { |
| 246 if (delegate) | 250 if (delegate) |
| 247 content_client->browser_ = delegate->CreateContentBrowserClient(); | 251 content_client->browser_ = delegate->CreateContentBrowserClient(); |
| 248 if (!content_client->browser_) | 252 if (!content_client->browser_) |
| 249 content_client->browser_ = &g_empty_content_browser_client.Get(); | 253 content_client->browser_ = &g_empty_content_browser_client.Get(); |
| 250 } | 254 } |
| 255 #endif // !CHROME_MULTIPLE_DLL_CHILD |
| 251 | 256 |
| 252 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) | 257 #if !defined(OS_IOS) && !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 253 if (process_type == switches::kPluginProcess || | 258 if (process_type == switches::kPluginProcess || |
| 254 process_type == switches::kPpapiPluginProcess) { | 259 process_type == switches::kPpapiPluginProcess) { |
| 255 if (delegate) | 260 if (delegate) |
| 256 content_client->plugin_ = delegate->CreateContentPluginClient(); | 261 content_client->plugin_ = delegate->CreateContentPluginClient(); |
| 257 if (!content_client->plugin_) | 262 if (!content_client->plugin_) |
| 258 content_client->plugin_ = &g_empty_content_plugin_client.Get(); | 263 content_client->plugin_ = &g_empty_content_plugin_client.Get(); |
| 259 // Single process not supported in split dll mode. | 264 // Single process not supported in split dll mode. |
| 260 } else if (process_type == switches::kRendererProcess || | 265 } else if (process_type == switches::kRendererProcess || |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 if (delegate) | 347 if (delegate) |
| 343 return delegate->RunProcess(process_type, main_params); | 348 return delegate->RunProcess(process_type, main_params); |
| 344 | 349 |
| 345 NOTREACHED() << "Unknown zygote process type: " << process_type; | 350 NOTREACHED() << "Unknown zygote process type: " << process_type; |
| 346 return 1; | 351 return 1; |
| 347 } | 352 } |
| 348 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 353 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 349 | 354 |
| 350 #if !defined(OS_IOS) | 355 #if !defined(OS_IOS) |
| 351 static void RegisterMainThreadFactories() { | 356 static void RegisterMainThreadFactories() { |
| 352 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | 357 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) && !defined(CHROME_MULTIPLE_DLL_CHILD) |
| 353 UtilityProcessHostImpl::RegisterUtilityMainThreadFactory( | 358 UtilityProcessHostImpl::RegisterUtilityMainThreadFactory( |
| 354 CreateInProcessUtilityThread); | 359 CreateInProcessUtilityThread); |
| 355 RenderProcessHostImpl::RegisterRendererMainThreadFactory( | 360 RenderProcessHostImpl::RegisterRendererMainThreadFactory( |
| 356 CreateInProcessRendererThread); | 361 CreateInProcessRendererThread); |
| 357 GpuProcessHost::RegisterGpuMainThreadFactory( | 362 GpuProcessHost::RegisterGpuMainThreadFactory( |
| 358 CreateInProcessGpuThread); | 363 CreateInProcessGpuThread); |
| 359 #else | 364 #else |
| 360 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); | 365 base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); |
| 361 if (command_line.HasSwitch(switches::kSingleProcess)) { | 366 if (command_line.HasSwitch(switches::kSingleProcess)) { |
| 362 LOG(FATAL) << | 367 LOG(FATAL) << |
| 363 "--single-process is not supported in chrome multiple dll browser."; | 368 "--single-process is not supported in chrome multiple dll browser."; |
| 364 } | 369 } |
| 365 if (command_line.HasSwitch(switches::kInProcessGPU)) { | 370 if (command_line.HasSwitch(switches::kInProcessGPU)) { |
| 366 LOG(FATAL) << | 371 LOG(FATAL) << |
| 367 "--in-process-gpu is not supported in chrome multiple dll browser."; | 372 "--in-process-gpu is not supported in chrome multiple dll browser."; |
| 368 } | 373 } |
| 369 #endif | 374 #endif // !CHROME_MULTIPLE_DLL_BROWSER && !CHROME_MULTIPLE_DLL_CHILD |
| 370 } | 375 } |
| 371 | 376 |
| 372 // Run the FooMain() for a given process type. | 377 // Run the FooMain() for a given process type. |
| 373 // If |process_type| is empty, runs BrowserMain(). | 378 // If |process_type| is empty, runs BrowserMain(). |
| 374 // Returns the exit code for this process. | 379 // Returns the exit code for this process. |
| 375 int RunNamedProcessTypeMain( | 380 int RunNamedProcessTypeMain( |
| 376 const std::string& process_type, | 381 const std::string& process_type, |
| 377 const MainFunctionParams& main_function_params, | 382 const MainFunctionParams& main_function_params, |
| 378 ContentMainDelegate* delegate) { | 383 ContentMainDelegate* delegate) { |
| 379 static const MainFunction kMainFunctions[] = { | 384 static const MainFunction kMainFunctions[] = { |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 | 826 |
| 822 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 827 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 823 }; | 828 }; |
| 824 | 829 |
| 825 // static | 830 // static |
| 826 ContentMainRunner* ContentMainRunner::Create() { | 831 ContentMainRunner* ContentMainRunner::Create() { |
| 827 return new ContentMainRunnerImpl(); | 832 return new ContentMainRunnerImpl(); |
| 828 } | 833 } |
| 829 | 834 |
| 830 } // namespace content | 835 } // namespace content |
| OLD | NEW |