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.h" | 5 #include "content/public/app/content_main.h" |
6 | 6 |
7 #include "content/app/content_service_manager_main_delegate.h" | 7 #include <memory> |
8 #include "services/service_manager/embedder/main.h" | 8 |
| 9 #include "base/debug/activity_tracker.h" |
| 10 #include "content/public/app/content_main_runner.h" |
9 | 11 |
10 namespace content { | 12 namespace content { |
11 | 13 |
12 int ContentMain(const ContentMainParams& params) { | 14 int ContentMain(const ContentMainParams& params) { |
13 ContentServiceManagerMainDelegate delegate(params); | 15 std::unique_ptr<ContentMainRunner> main_runner(ContentMainRunner::Create()); |
14 service_manager::MainParams main_params(&delegate); | 16 |
15 #if defined(OS_POSIX) && !defined(OS_ANDROID) | 17 int exit_code = main_runner->Initialize(params); |
16 main_params.argc = params.argc; | 18 if (exit_code >= 0) { |
17 main_params.argv = params.argv; | 19 base::debug::GlobalActivityTracker* tracker = |
18 #endif | 20 base::debug::GlobalActivityTracker::Get(); |
19 return service_manager::Main(main_params); | 21 if (tracker) { |
| 22 tracker->SetProcessPhase( |
| 23 base::debug::GlobalActivityTracker::PROCESS_LAUNCH_FAILED); |
| 24 tracker->process_data().SetInt("exit-code", exit_code); |
| 25 } |
| 26 return exit_code; |
| 27 } |
| 28 |
| 29 exit_code = main_runner->Run(); |
| 30 |
| 31 main_runner->Shutdown(); |
| 32 |
| 33 base::debug::GlobalActivityTracker* tracker = |
| 34 base::debug::GlobalActivityTracker::Get(); |
| 35 if (tracker) { |
| 36 if (exit_code == 0) { |
| 37 tracker->SetProcessPhaseIfEnabled( |
| 38 base::debug::GlobalActivityTracker::PROCESS_EXITED_CLEANLY); |
| 39 } else { |
| 40 tracker->SetProcessPhaseIfEnabled( |
| 41 base::debug::GlobalActivityTracker::PROCESS_EXITED_WITH_CODE); |
| 42 tracker->process_data().SetInt("exit-code", exit_code); |
| 43 } |
| 44 } |
| 45 |
| 46 return exit_code; |
20 } | 47 } |
21 | 48 |
22 } // namespace content | 49 } // namespace content |
OLD | NEW |