Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Unified Diff: content/app/content_main.cc

Issue 2613653003: Move some basic early process init into Service Manager (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/app/content_main.cc
diff --git a/content/app/content_main.cc b/content/app/content_main.cc
index b983bf8191d9d1e59e27d2a9250569d8fc793751..ef922a6541edb825b260ac1df77437ae99836d94 100644
--- a/content/app/content_main.cc
+++ b/content/app/content_main.cc
@@ -6,22 +6,52 @@
#include <memory>
+#include "base/macros.h"
#include "content/public/app/content_main_runner.h"
+#include "services/service_manager/embedder/main.h"
+#include "services/service_manager/embedder/main_delegate.h"
namespace content {
-int ContentMain(const ContentMainParams& params) {
- std::unique_ptr<ContentMainRunner> main_runner(ContentMainRunner::Create());
+namespace {
+
+class ContentServiceManagerMainDelegate : public service_manager::MainDelegate {
+ public:
+ explicit ContentServiceManagerMainDelegate(const ContentMainParams& params)
+ : content_main_params_(params),
+ main_runner_(ContentMainRunner::Create()) {}
+ ~ContentServiceManagerMainDelegate() override {}
+
+ // service_manager::MainDelegate:
+ bool Initialize(const InitializeParams& params, int* exit_code) override {
+#if defined(OS_MACOSX)
+ content_main_params_.autorelease_pool = params.autorelease_pool;
+#endif
+ *exit_code = main_runner_->Initialize(content_main_params_);
+ return *exit_code < 0;
+ }
- int exit_code = main_runner->Initialize(params);
- if (exit_code >= 0)
- return exit_code;
+ int Run() override { return main_runner_->Run(); }
- exit_code = main_runner->Run();
+ void ShutDown() override { main_runner_->Shutdown(); }
- main_runner->Shutdown();
+ private:
+ ContentMainParams content_main_params_;
+ std::unique_ptr<ContentMainRunner> main_runner_;
- return exit_code;
+ DISALLOW_COPY_AND_ASSIGN(ContentServiceManagerMainDelegate);
+};
+
+} // namespace
+
+int ContentMain(const ContentMainParams& params) {
+ ContentServiceManagerMainDelegate delegate(params);
+ service_manager::MainParams main_params(&delegate);
+#if defined(OS_POSIX) && !defined(OS_ANDROID)
+ main_params.argc = params.argc;
+ main_params.argv = params.argv;
+#endif
+ return service_manager::Main(main_params);
}
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698