| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 | 399 |
| 400 if (delegate) | 400 if (delegate) |
| 401 return delegate->RunProcess(process_type, main_params); | 401 return delegate->RunProcess(process_type, main_params); |
| 402 | 402 |
| 403 NOTREACHED() << "Unknown zygote process type: " << process_type; | 403 NOTREACHED() << "Unknown zygote process type: " << process_type; |
| 404 return 1; | 404 return 1; |
| 405 } | 405 } |
| 406 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 406 #endif // defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 407 | 407 |
| 408 #if !defined(OS_IOS) | 408 #if !defined(OS_IOS) |
| 409 static void RegisterMainThreadFactories() { |
| 410 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 411 UtilityProcessHost::RegisterUtilityMainThreadFactory( |
| 412 CreateInProcessUtilityThread); |
| 413 RenderProcessHost::RegisterRendererMainThreadFactory( |
| 414 CreateInProcessRendererThread); |
| 415 GpuProcessHost::RegisterGpuMainThreadFactory( |
| 416 CreateInProcessGpuThread); |
| 417 #else |
| 418 CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 419 if (command_line.HasSwitch(switches::kSingleProcess)) { |
| 420 LOG(FATAL) << |
| 421 "--single-process is not supported in chrome multiple dll browser."; |
| 422 } |
| 423 if (command_line.HasSwitch(switches::kInProcessGPU)) { |
| 424 LOG(FATAL) << |
| 425 "--in-process-gpu is not supported in chrome multiple dll browser."; |
| 426 } |
| 427 #endif |
| 428 } |
| 429 |
| 409 // Run the FooMain() for a given process type. | 430 // Run the FooMain() for a given process type. |
| 410 // If |process_type| is empty, runs BrowserMain(). | 431 // If |process_type| is empty, runs BrowserMain(). |
| 411 // Returns the exit code for this process. | 432 // Returns the exit code for this process. |
| 412 int RunNamedProcessTypeMain( | 433 int RunNamedProcessTypeMain( |
| 413 const std::string& process_type, | 434 const std::string& process_type, |
| 414 const MainFunctionParams& main_function_params, | 435 const MainFunctionParams& main_function_params, |
| 415 ContentMainDelegate* delegate) { | 436 ContentMainDelegate* delegate) { |
| 416 static const MainFunction kMainFunctions[] = { | 437 static const MainFunction kMainFunctions[] = { |
| 417 #if !defined(CHROME_MULTIPLE_DLL_CHILD) | 438 #if !defined(CHROME_MULTIPLE_DLL_CHILD) |
| 418 { "", BrowserMain }, | 439 { "", BrowserMain }, |
| 419 #endif | 440 #endif |
| 420 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | 441 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) |
| 421 #if defined(ENABLE_PLUGINS) | 442 #if defined(ENABLE_PLUGINS) |
| 422 { switches::kPluginProcess, PluginMain }, | 443 { switches::kPluginProcess, PluginMain }, |
| 423 { switches::kWorkerProcess, WorkerMain }, | 444 { switches::kWorkerProcess, WorkerMain }, |
| 424 { switches::kPpapiPluginProcess, PpapiPluginMain }, | 445 { switches::kPpapiPluginProcess, PpapiPluginMain }, |
| 425 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, | 446 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, |
| 426 #endif // ENABLE_PLUGINS | 447 #endif // ENABLE_PLUGINS |
| 427 { switches::kUtilityProcess, UtilityMain }, | 448 { switches::kUtilityProcess, UtilityMain }, |
| 428 { switches::kRendererProcess, RendererMain }, | 449 { switches::kRendererProcess, RendererMain }, |
| 429 { switches::kGpuProcess, GpuMain }, | 450 { switches::kGpuProcess, GpuMain }, |
| 430 #endif // !CHROME_MULTIPLE_DLL_BROWSER | 451 #endif // !CHROME_MULTIPLE_DLL_BROWSER |
| 431 }; | 452 }; |
| 432 | 453 |
| 433 #if !defined(CHROME_MULTIPLE_DLL_BROWSER) | 454 RegisterMainThreadFactories(); |
| 434 UtilityProcessHost::RegisterUtilityMainThreadFactory( | |
| 435 CreateInProcessUtilityThread); | |
| 436 RenderProcessHost::RegisterRendererMainThreadFactory( | |
| 437 CreateInProcessRendererThread); | |
| 438 GpuProcessHost::RegisterGpuMainThreadFactory( | |
| 439 CreateInProcessGpuThread); | |
| 440 #endif | |
| 441 | 455 |
| 442 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 456 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
| 443 if (process_type == kMainFunctions[i].name) { | 457 if (process_type == kMainFunctions[i].name) { |
| 444 if (delegate) { | 458 if (delegate) { |
| 445 int exit_code = delegate->RunProcess(process_type, | 459 int exit_code = delegate->RunProcess(process_type, |
| 446 main_function_params); | 460 main_function_params); |
| 447 #if defined(OS_ANDROID) | 461 #if defined(OS_ANDROID) |
| 448 // In Android's browser process, the negative exit code doesn't mean the | 462 // In Android's browser process, the negative exit code doesn't mean the |
| 449 // default behavior should be used as the UI message loop is managed by | 463 // default behavior should be used as the UI message loop is managed by |
| 450 // the Java and the browser process's default behavior is always | 464 // the Java and the browser process's default behavior is always |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 | 849 |
| 836 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 850 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 837 }; | 851 }; |
| 838 | 852 |
| 839 // static | 853 // static |
| 840 ContentMainRunner* ContentMainRunner::Create() { | 854 ContentMainRunner* ContentMainRunner::Create() { |
| 841 return new ContentMainRunnerImpl(); | 855 return new ContentMainRunnerImpl(); |
| 842 } | 856 } |
| 843 | 857 |
| 844 } // namespace content | 858 } // namespace content |
| OLD | NEW |