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