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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 #endif | 94 #endif |
95 | 95 |
96 #endif // OS_POSIX | 96 #endif // OS_POSIX |
97 | 97 |
98 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) | 98 #if !defined(OS_MACOSX) && defined(USE_TCMALLOC) |
99 extern "C" { | 99 extern "C" { |
100 int tc_set_new_mode(int mode); | 100 int tc_set_new_mode(int mode); |
101 } | 101 } |
102 #endif | 102 #endif |
103 | 103 |
| 104 #if defined(USE_MOJO) |
| 105 #include "content/common/mojo/mojo_init.h" |
| 106 #endif |
| 107 |
104 namespace content { | 108 namespace content { |
105 extern int GpuMain(const content::MainFunctionParams&); | 109 extern int GpuMain(const content::MainFunctionParams&); |
106 #if defined(ENABLE_PLUGINS) | 110 #if defined(ENABLE_PLUGINS) |
107 extern int PluginMain(const content::MainFunctionParams&); | 111 extern int PluginMain(const content::MainFunctionParams&); |
108 extern int PpapiPluginMain(const MainFunctionParams&); | 112 extern int PpapiPluginMain(const MainFunctionParams&); |
109 extern int PpapiBrokerMain(const MainFunctionParams&); | 113 extern int PpapiBrokerMain(const MainFunctionParams&); |
110 #endif | 114 #endif |
111 extern int RendererMain(const content::MainFunctionParams&); | 115 extern int RendererMain(const content::MainFunctionParams&); |
112 extern int UtilityMain(const MainFunctionParams&); | 116 extern int UtilityMain(const MainFunctionParams&); |
113 extern int WorkerMain(const MainFunctionParams&); | 117 extern int WorkerMain(const MainFunctionParams&); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 } | 526 } |
523 | 527 |
524 static void ReleaseFreeMemoryThunk() { | 528 static void ReleaseFreeMemoryThunk() { |
525 MallocExtension::instance()->ReleaseFreeMemory(); | 529 MallocExtension::instance()->ReleaseFreeMemory(); |
526 } | 530 } |
527 #endif | 531 #endif |
528 | 532 |
529 virtual int Initialize(const ContentMainParams& params) OVERRIDE { | 533 virtual int Initialize(const ContentMainParams& params) OVERRIDE { |
530 ui_task_ = params.ui_task; | 534 ui_task_ = params.ui_task; |
531 | 535 |
532 #if defined(OS_WIN) | 536 #if defined(OS_WIN) |
533 RegisterInvalidParamHandler(); | 537 RegisterInvalidParamHandler(); |
534 _Module.Init(NULL, static_cast<HINSTANCE>(params.instance)); | 538 _Module.Init(NULL, static_cast<HINSTANCE>(params.instance)); |
535 | 539 |
536 sandbox_info_ = *params.sandbox_info; | 540 sandbox_info_ = *params.sandbox_info; |
537 #else // !OS_WIN | 541 #else // !OS_WIN |
538 | 542 |
539 #if defined(OS_ANDROID) | 543 #if defined(OS_ANDROID) |
540 // See note at the initialization of ExitManager, below; basically, | 544 // See note at the initialization of ExitManager, below; basically, |
541 // only Android builds have the ctor/dtor handlers set up to use | 545 // only Android builds have the ctor/dtor handlers set up to use |
542 // TRACE_EVENT right away. | 546 // TRACE_EVENT right away. |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 int exit_code; | 658 int exit_code; |
655 if (delegate_ && delegate_->BasicStartupComplete(&exit_code)) | 659 if (delegate_ && delegate_->BasicStartupComplete(&exit_code)) |
656 return exit_code; | 660 return exit_code; |
657 | 661 |
658 completed_basic_startup_ = true; | 662 completed_basic_startup_ = true; |
659 | 663 |
660 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 664 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
661 std::string process_type = | 665 std::string process_type = |
662 command_line.GetSwitchValueASCII(switches::kProcessType); | 666 command_line.GetSwitchValueASCII(switches::kProcessType); |
663 | 667 |
| 668 #if defined(USE_MOJO) |
| 669 // Initialize mojo here so that services can be registered. |
| 670 InitializeMojo(); |
| 671 #endif |
| 672 |
664 if (!GetContentClient()) | 673 if (!GetContentClient()) |
665 SetContentClient(&empty_content_client_); | 674 SetContentClient(&empty_content_client_); |
666 ContentClientInitializer::Set(process_type, delegate_); | 675 ContentClientInitializer::Set(process_type, delegate_); |
667 | 676 |
668 #if defined(OS_WIN) | 677 #if defined(OS_WIN) |
669 // Route stdio to parent console (if any) or create one. | 678 // Route stdio to parent console (if any) or create one. |
670 if (command_line.HasSwitch(switches::kEnableLogging)) | 679 if (command_line.HasSwitch(switches::kEnableLogging)) |
671 base::RouteStdioToConsole(); | 680 base::RouteStdioToConsole(); |
672 #endif | 681 #endif |
673 | 682 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 | 857 |
849 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); | 858 DISALLOW_COPY_AND_ASSIGN(ContentMainRunnerImpl); |
850 }; | 859 }; |
851 | 860 |
852 // static | 861 // static |
853 ContentMainRunner* ContentMainRunner::Create() { | 862 ContentMainRunner* ContentMainRunner::Create() { |
854 return new ContentMainRunnerImpl(); | 863 return new ContentMainRunnerImpl(); |
855 } | 864 } |
856 | 865 |
857 } // namespace content | 866 } // namespace content |
OLD | NEW |