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