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

Side by Side 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 unified diff | Download patch
OLDNEW
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.h" 5 #include "content/public/app/content_main.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h"
9 #include "content/public/app/content_main_runner.h" 10 #include "content/public/app/content_main_runner.h"
11 #include "services/service_manager/embedder/main.h"
12 #include "services/service_manager/embedder/main_delegate.h"
10 13
11 namespace content { 14 namespace content {
12 15
16 namespace {
17
18 class ContentServiceManagerMainDelegate : public service_manager::MainDelegate {
19 public:
20 explicit ContentServiceManagerMainDelegate(const ContentMainParams& params)
21 : content_main_params_(params),
22 main_runner_(ContentMainRunner::Create()) {}
23 ~ContentServiceManagerMainDelegate() override {}
24
25 // service_manager::MainDelegate:
26 bool Initialize(const InitializeParams& params, int* exit_code) override {
27 #if defined(OS_MACOSX)
28 content_main_params_.autorelease_pool = params.autorelease_pool;
29 #endif
30 *exit_code = main_runner_->Initialize(content_main_params_);
31 return *exit_code < 0;
32 }
33
34 int Run() override { return main_runner_->Run(); }
35
36 void ShutDown() override { main_runner_->Shutdown(); }
37
38 private:
39 ContentMainParams content_main_params_;
40 std::unique_ptr<ContentMainRunner> main_runner_;
41
42 DISALLOW_COPY_AND_ASSIGN(ContentServiceManagerMainDelegate);
43 };
44
45 } // namespace
46
13 int ContentMain(const ContentMainParams& params) { 47 int ContentMain(const ContentMainParams& params) {
14 std::unique_ptr<ContentMainRunner> main_runner(ContentMainRunner::Create()); 48 ContentServiceManagerMainDelegate delegate(params);
15 49 service_manager::MainParams main_params(&delegate);
16 int exit_code = main_runner->Initialize(params); 50 #if defined(OS_POSIX) && !defined(OS_ANDROID)
17 if (exit_code >= 0) 51 main_params.argc = params.argc;
18 return exit_code; 52 main_params.argv = params.argv;
19 53 #endif
20 exit_code = main_runner->Run(); 54 return service_manager::Main(main_params);
21
22 main_runner->Shutdown();
23
24 return exit_code;
25 } 55 }
26 56
27 } // namespace content 57 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698