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 #if !defined(OS_IOS) |
169 (!defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD)) | |
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 static void Set(const std::string& process_type, | 285 static void Set(const std::string& process_type, |
287 ContentMainDelegate* delegate) { | 286 ContentMainDelegate* delegate) { |
288 ContentClient* content_client = GetContentClient(); | 287 ContentClient* content_client = GetContentClient(); |
289 if (process_type.empty()) { | 288 if (process_type.empty()) { |
290 if (delegate) | 289 if (delegate) |
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 (!defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD)) | |
298 if (process_type == switches::kPluginProcess || | 296 if (process_type == switches::kPluginProcess || |
299 process_type == switches::kPpapiPluginProcess) { | 297 process_type == switches::kPpapiPluginProcess) { |
300 if (delegate) | 298 if (delegate) |
301 content_client->plugin_ = delegate->CreateContentPluginClient(); | 299 content_client->plugin_ = delegate->CreateContentPluginClient(); |
302 if (!content_client->plugin_) | 300 if (!content_client->plugin_) |
303 content_client->plugin_ = &g_empty_content_plugin_client.Get(); | 301 content_client->plugin_ = &g_empty_content_plugin_client.Get(); |
304 // Single process not supported in split dll mode. | 302 // Single process not supported in split dll mode. |
305 } else if (process_type == switches::kRendererProcess || | 303 } else if (process_type == switches::kRendererProcess || |
306 CommandLine::ForCurrentProcess()->HasSwitch( | 304 CommandLine::ForCurrentProcess()->HasSwitch( |
307 switches::kSingleProcess)) { | 305 switches::kSingleProcess)) { |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 | 399 |
402 #if !defined(OS_IOS) | 400 #if !defined(OS_IOS) |
403 // Run the FooMain() for a given process type. | 401 // Run the FooMain() for a given process type. |
404 // If |process_type| is empty, runs BrowserMain(). | 402 // If |process_type| is empty, runs BrowserMain(). |
405 // Returns the exit code for this process. | 403 // Returns the exit code for this process. |
406 int RunNamedProcessTypeMain( | 404 int RunNamedProcessTypeMain( |
407 const std::string& process_type, | 405 const std::string& process_type, |
408 const MainFunctionParams& main_function_params, | 406 const MainFunctionParams& main_function_params, |
409 ContentMainDelegate* delegate) { | 407 ContentMainDelegate* delegate) { |
410 static const MainFunction kMainFunctions[] = { | 408 static const MainFunction kMainFunctions[] = { |
411 #if !defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_BROWSER) | |
412 { "", BrowserMain }, | 409 { "", BrowserMain }, |
413 #endif | |
414 #if !defined(CHROME_MULTIPLE_DLL) || defined(CHROME_MULTIPLE_DLL_CHILD) | |
415 #if defined(ENABLE_PLUGINS) | 410 #if defined(ENABLE_PLUGINS) |
416 { switches::kPluginProcess, PluginMain }, | 411 { switches::kPluginProcess, PluginMain }, |
417 { switches::kWorkerProcess, WorkerMain }, | 412 { switches::kWorkerProcess, WorkerMain }, |
418 { switches::kPpapiPluginProcess, PpapiPluginMain }, | 413 { switches::kPpapiPluginProcess, PpapiPluginMain }, |
419 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, | 414 { switches::kPpapiBrokerProcess, PpapiBrokerMain }, |
420 #endif // ENABLE_PLUGINS | 415 #endif |
421 { switches::kUtilityProcess, UtilityMain }, | 416 { switches::kUtilityProcess, UtilityMain }, |
422 { switches::kRendererProcess, RendererMain }, | 417 { switches::kRendererProcess, RendererMain }, |
423 { switches::kGpuProcess, GpuMain }, | 418 { switches::kGpuProcess, GpuMain }, |
424 #endif // !CHROME_MULTIPLE_DLL || CHROME_MULTIPLE_DLL_CHILD | |
425 }; | 419 }; |
426 | 420 |
427 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { | 421 for (size_t i = 0; i < arraysize(kMainFunctions); ++i) { |
428 if (process_type == kMainFunctions[i].name) { | 422 if (process_type == kMainFunctions[i].name) { |
429 if (delegate) { | 423 if (delegate) { |
430 int exit_code = delegate->RunProcess(process_type, | 424 int exit_code = delegate->RunProcess(process_type, |
431 main_function_params); | 425 main_function_params); |
432 #if defined(OS_ANDROID) | 426 #if defined(OS_ANDROID) |
433 // In Android's browser process, the negative exit code doesn't mean the | 427 // In Android's browser process, the negative exit code doesn't mean the |
434 // default behavior should be used as the UI message loop is managed by | 428 // default behavior should be used as the UI message loop is managed by |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 | 815 |
822 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 816 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
823 }; | 817 }; |
824 | 818 |
825 // static | 819 // static |
826 ContentMainRunner* ContentMainRunner::Create() { | 820 ContentMainRunner* ContentMainRunner::Create() { |
827 return new ContentMainRunnerImpl(); | 821 return new ContentMainRunnerImpl(); |
828 } | 822 } |
829 | 823 |
830 } // namespace content | 824 } // namespace content |
OLD | NEW |