| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 NOTREACHED(); | 158 NOTREACHED(); |
| 159 } | 159 } |
| 160 } | 160 } |
| 161 #endif // defined(OS_WIN) | 161 #endif // defined(OS_WIN) |
| 162 } // namespace | 162 } // namespace |
| 163 | 163 |
| 164 namespace content { | 164 namespace content { |
| 165 | 165 |
| 166 base::LazyInstance<ContentBrowserClient> | 166 base::LazyInstance<ContentBrowserClient> |
| 167 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; | 167 g_empty_content_browser_client = LAZY_INSTANCE_INITIALIZER; |
| 168 #if !defined(OS_IOS) | 168 // TODO(scottmg): http://crbug.com/237249 Split into browser and child. |
| 169 #if !defined(OS_IOS) && !defined(CHROME_SPLIT_DLL) |
| 169 base::LazyInstance<ContentPluginClient> | 170 base::LazyInstance<ContentPluginClient> |
| 170 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; | 171 g_empty_content_plugin_client = LAZY_INSTANCE_INITIALIZER; |
| 171 base::LazyInstance<ContentRendererClient> | 172 base::LazyInstance<ContentRendererClient> |
| 172 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; | 173 g_empty_content_renderer_client = LAZY_INSTANCE_INITIALIZER; |
| 173 base::LazyInstance<ContentUtilityClient> | 174 base::LazyInstance<ContentUtilityClient> |
| 174 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; | 175 g_empty_content_utility_client = LAZY_INSTANCE_INITIALIZER; |
| 175 #endif // !OS_IOS | 176 #endif // !OS_IOS |
| 176 | 177 |
| 177 #if defined(OS_WIN) | 178 #if defined(OS_WIN) |
| 178 | 179 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 content_client->browser_ = delegate->CreateContentBrowserClient(); | 291 content_client->browser_ = delegate->CreateContentBrowserClient(); |
| 291 if (!content_client->browser_) | 292 if (!content_client->browser_) |
| 292 content_client->browser_ = &g_empty_content_browser_client.Get(); | 293 content_client->browser_ = &g_empty_content_browser_client.Get(); |
| 293 } | 294 } |
| 294 | 295 |
| 295 #if !defined(OS_IOS) | 296 #if !defined(OS_IOS) |
| 296 if (process_type == switches::kPluginProcess || | 297 if (process_type == switches::kPluginProcess || |
| 297 process_type == switches::kPpapiPluginProcess) { | 298 process_type == switches::kPpapiPluginProcess) { |
| 298 if (delegate) | 299 if (delegate) |
| 299 content_client->plugin_ = delegate->CreateContentPluginClient(); | 300 content_client->plugin_ = delegate->CreateContentPluginClient(); |
| 301 // TODO(scottmg): http://crbug.com/237249 Should be in _child. |
| 302 #if !defined(CHROME_SPLIT_DLL) |
| 300 if (!content_client->plugin_) | 303 if (!content_client->plugin_) |
| 301 content_client->plugin_ = &g_empty_content_plugin_client.Get(); | 304 content_client->plugin_ = &g_empty_content_plugin_client.Get(); |
| 305 #endif |
| 306 // Single process not supported in split dll mode. |
| 307 #if !defined(CHROME_SPLIT_DLL) |
| 302 } else if (process_type == switches::kRendererProcess || | 308 } else if (process_type == switches::kRendererProcess || |
| 303 CommandLine::ForCurrentProcess()->HasSwitch( | 309 CommandLine::ForCurrentProcess()->HasSwitch( |
| 304 switches::kSingleProcess)) { | 310 switches::kSingleProcess)) { |
| 305 if (delegate) | 311 if (delegate) |
| 306 content_client->renderer_ = delegate->CreateContentRendererClient(); | 312 content_client->renderer_ = delegate->CreateContentRendererClient(); |
| 307 if (!content_client->renderer_) | 313 if (!content_client->renderer_) |
| 308 content_client->renderer_ = &g_empty_content_renderer_client.Get(); | 314 content_client->renderer_ = &g_empty_content_renderer_client.Get(); |
| 315 #endif |
| 309 } else if (process_type == switches::kUtilityProcess) { | 316 } else if (process_type == switches::kUtilityProcess) { |
| 310 if (delegate) | 317 if (delegate) |
| 311 content_client->utility_ = delegate->CreateContentUtilityClient(); | 318 content_client->utility_ = delegate->CreateContentUtilityClient(); |
| 319 // TODO(scottmg): http://crbug.com/237249 Should be in _child. |
| 320 #if !defined(CHROME_SPLIT_DLL) |
| 312 if (!content_client->utility_) | 321 if (!content_client->utility_) |
| 313 content_client->utility_ = &g_empty_content_utility_client.Get(); | 322 content_client->utility_ = &g_empty_content_utility_client.Get(); |
| 323 #endif |
| 314 } | 324 } |
| 315 #endif // !OS_IOS | 325 #endif // !OS_IOS |
| 316 } | 326 } |
| 317 }; | 327 }; |
| 318 | 328 |
| 319 // We dispatch to a process-type-specific FooMain() based on a command-line | 329 // We dispatch to a process-type-specific FooMain() based on a command-line |
| 320 // flag. This struct is used to build a table of (flag, main function) pairs. | 330 // flag. This struct is used to build a table of (flag, main function) pairs. |
| 321 struct MainFunction { | 331 struct MainFunction { |
| 322 const char* name; | 332 const char* name; |
| 323 int (*function)(const MainFunctionParams&); | 333 int (*function)(const MainFunctionParams&); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 #if !defined(OS_IOS) | 404 #if !defined(OS_IOS) |
| 395 // Run the FooMain() for a given process type. | 405 // Run the FooMain() for a given process type. |
| 396 // If |process_type| is empty, runs BrowserMain(). | 406 // If |process_type| is empty, runs BrowserMain(). |
| 397 // Returns the exit code for this process. | 407 // Returns the exit code for this process. |
| 398 int RunNamedProcessTypeMain( | 408 int RunNamedProcessTypeMain( |
| 399 const std::string& process_type, | 409 const std::string& process_type, |
| 400 const MainFunctionParams& main_function_params, | 410 const MainFunctionParams& main_function_params, |
| 401 ContentMainDelegate* delegate) { | 411 ContentMainDelegate* delegate) { |
| 402 static const MainFunction kMainFunctions[] = { | 412 static const MainFunction kMainFunctions[] = { |
| 403 { "", BrowserMain }, | 413 { "", BrowserMain }, |
| 404 { switches::kRendererProcess, RendererMain }, | |
| 405 #if defined(ENABLE_PLUGINS) | 414 #if defined(ENABLE_PLUGINS) |
| 415 // TODO(scottmg): http://crbug.com/237249 This will have to be split into |
| 416 // content_main_runner_browser and content_main_runner_child. |
| 417 #if !defined(CHROME_SPLIT_DLL) |
| 406 { switches::kPluginProcess, PluginMain }, | 418 { switches::kPluginProcess, PluginMain }, |
| 407 { switches::kWorkerProcess, WorkerMain }, | 419 { switches::kWorkerProcess, WorkerMain }, |
| 420 #endif |
| 408 { switches::kPpapiPluginProcess, PpapiPluginMain }, | 421 { switches::kPpapiPluginProcess, PpapiPluginMain }, |
| 409 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, | 422 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, |
| 410 #endif | 423 #endif |
| 424 // TODO(scottmg): http://crbug.com/237249 This will have to be split into |
| 425 // content_main_runner_browser and content_main_runner_child. |
| 426 #if !defined(CHROME_SPLIT_DLL) |
| 411 { switches::kUtilityProcess, UtilityMain }, | 427 { switches::kUtilityProcess, UtilityMain }, |
| 428 { switches::kRendererProcess, RendererMain }, |
| 429 #endif |
| 412 { switches::kGpuProcess, GpuMain }, | 430 { switches::kGpuProcess, GpuMain }, |
| 413 }; | 431 }; |
| 414 | 432 |
| 415 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 433 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
| 416 if (process_type == kMainFunctions[i].name) { | 434 if (process_type == kMainFunctions[i].name) { |
| 417 if (delegate) { | 435 if (delegate) { |
| 418 int exit_code = delegate->RunProcess(process_type, | 436 int exit_code = delegate->RunProcess(process_type, |
| 419 main_function_params); | 437 main_function_params); |
| 420 #if defined(OS_ANDROID) | 438 #if defined(OS_ANDROID) |
| 421 // In Android's browser process, the negative exit code doesn't mean the | 439 // In Android's browser process, the negative exit code doesn't mean the |
| (...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 830 |
| 813 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 831 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
| 814 }; | 832 }; |
| 815 | 833 |
| 816 // static | 834 // static |
| 817 ContentMainRunner* ContentMainRunner::Create() { | 835 ContentMainRunner* ContentMainRunner::Create() { |
| 818 return new ContentMainRunnerImpl(); | 836 return new ContentMainRunnerImpl(); |
| 819 } | 837 } |
| 820 | 838 |
| 821 } // namespace content | 839 } // namespace content |
| OLD | NEW |