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