| 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
|
|
|