OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/app/mash/mash_runner.h" | 5 #include "chrome/app/mash/mash_runner.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 #include "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" | 49 #include "services/service_manager/public/cpp/standalone_service/standalone_serv
ice.h" |
50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 50 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
51 #include "services/service_manager/runner/common/client_util.h" | 51 #include "services/service_manager/runner/common/client_util.h" |
52 #include "services/service_manager/runner/common/switches.h" | 52 #include "services/service_manager/runner/common/switches.h" |
53 #include "services/service_manager/runner/init.h" | 53 #include "services/service_manager/runner/init.h" |
54 #include "services/ui/public/interfaces/constants.mojom.h" | 54 #include "services/ui/public/interfaces/constants.mojom.h" |
55 #include "ui/base/resource/resource_bundle.h" | 55 #include "ui/base/resource/resource_bundle.h" |
56 #include "ui/base/ui_base_paths.h" | 56 #include "ui/base/ui_base_paths.h" |
57 #include "ui/base/ui_base_switches.h" | 57 #include "ui/base/ui_base_switches.h" |
58 | 58 |
| 59 #if defined(OS_POSIX) |
| 60 #include "base/threading/thread_task_runner_handle.h" |
| 61 #include "chrome/app/shutdown_signal_handlers_posix.h" |
| 62 #endif |
| 63 |
59 using service_manager::mojom::ServiceFactory; | 64 using service_manager::mojom::ServiceFactory; |
60 | 65 |
61 namespace { | 66 namespace { |
62 | 67 |
63 // kProcessType used to identify child processes. | 68 // kProcessType used to identify child processes. |
64 const char* kMashChild = "mash-child"; | 69 const char* kMashChild = "mash-child"; |
65 | 70 |
66 const char kChromeMashServiceName[] = "chrome_mash"; | 71 const char kChromeMashServiceName[] = "chrome_mash"; |
67 | 72 |
68 bool IsChild() { | 73 bool IsChild() { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 kChromeMashServiceName, service_manager::mojom::kRootUserID), | 201 kChromeMashServiceName, service_manager::mojom::kRootUserID), |
197 std::move(service), nullptr); | 202 std::move(service), nullptr); |
198 | 203 |
199 // Quit the main process if an important child (e.g. window manager) dies. | 204 // Quit the main process if an important child (e.g. window manager) dies. |
200 // On Chrome OS the OS-level session_manager will restart the main process. | 205 // On Chrome OS the OS-level session_manager will restart the main process. |
201 base::RunLoop run_loop; | 206 base::RunLoop run_loop; |
202 int exit_value = 0; | 207 int exit_value = 0; |
203 background_service_manager.SetInstanceQuitCallback( | 208 background_service_manager.SetInstanceQuitCallback( |
204 base::Bind(&OnInstanceQuitInMain, &run_loop, &exit_value)); | 209 base::Bind(&OnInstanceQuitInMain, &run_loop, &exit_value)); |
205 | 210 |
| 211 #if defined(OS_POSIX) |
| 212 // Quit the main process in response to shutdown signals (like SIGTERM). |
| 213 // These signals are used by Linux distributions to request clean shutdown. |
| 214 // On Chrome OS the SIGTERM signal is sent by session_manager. |
| 215 InstallShutdownSignalHandlers(run_loop.QuitClosure(), |
| 216 base::ThreadTaskRunnerHandle::Get()); |
| 217 #endif |
| 218 |
206 // Ping services that we know we want to launch on startup (UI service, | 219 // Ping services that we know we want to launch on startup (UI service, |
207 // window manager, quick launch app). | 220 // window manager, quick launch app). |
208 context.connector()->Connect(ui::mojom::kServiceName); | 221 context.connector()->Connect(ui::mojom::kServiceName); |
209 context.connector()->Connect(mash::common::GetWindowManagerServiceName()); | 222 context.connector()->Connect(mash::common::GetWindowManagerServiceName()); |
210 context.connector()->Connect(mash::quick_launch::mojom::kServiceName); | 223 context.connector()->Connect(mash::quick_launch::mojom::kServiceName); |
211 context.connector()->Connect(content::mojom::kPackagedServicesServiceName); | 224 context.connector()->Connect(content::mojom::kPackagedServicesServiceName); |
212 | 225 |
213 run_loop.Run(); | 226 run_loop.Run(); |
214 | 227 |
215 // |context| must be destroyed before the message loop. | 228 // |context| must be destroyed before the message loop. |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { | 300 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { |
288 return; | 301 return; |
289 } | 302 } |
290 | 303 |
291 // Include the pid as logging may not have been initialized yet (the pid | 304 // Include the pid as logging may not have been initialized yet (the pid |
292 // printed out by logging is wrong). | 305 // printed out by logging is wrong). |
293 LOG(WARNING) << "waiting for debugger to attach for service " << service_name | 306 LOG(WARNING) << "waiting for debugger to attach for service " << service_name |
294 << " pid=" << base::Process::Current().Pid(); | 307 << " pid=" << base::Process::Current().Pid(); |
295 base::debug::WaitForDebugger(120, true); | 308 base::debug::WaitForDebugger(120, true); |
296 } | 309 } |
OLD | NEW |