Chromium Code Reviews| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 #include "services/service_manager/background/background_service_manager.h" | 43 #include "services/service_manager/background/background_service_manager.h" |
| 44 #include "services/service_manager/public/cpp/connector.h" | 44 #include "services/service_manager/public/cpp/connector.h" |
| 45 #include "services/service_manager/public/cpp/identity.h" | 45 #include "services/service_manager/public/cpp/identity.h" |
| 46 #include "services/service_manager/public/cpp/service.h" | 46 #include "services/service_manager/public/cpp/service.h" |
| 47 #include "services/service_manager/public/cpp/service_context.h" | 47 #include "services/service_manager/public/cpp/service_context.h" |
| 48 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" | 48 #include "services/service_manager/public/cpp/standalone_service/standalone_serv ice.h" |
| 49 #include "services/service_manager/public/interfaces/service_factory.mojom.h" | 49 #include "services/service_manager/public/interfaces/service_factory.mojom.h" |
| 50 #include "services/service_manager/runner/common/client_util.h" | 50 #include "services/service_manager/runner/common/client_util.h" |
| 51 #include "services/service_manager/runner/common/switches.h" | 51 #include "services/service_manager/runner/common/switches.h" |
| 52 #include "services/service_manager/runner/init.h" | 52 #include "services/service_manager/runner/init.h" |
| 53 #include "services/ui/public/interfaces/constants.mojom.h" | |
| 53 #include "ui/base/resource/resource_bundle.h" | 54 #include "ui/base/resource/resource_bundle.h" |
| 54 #include "ui/base/ui_base_paths.h" | 55 #include "ui/base/ui_base_paths.h" |
| 55 #include "ui/base/ui_base_switches.h" | 56 #include "ui/base/ui_base_switches.h" |
| 56 | 57 |
| 57 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 58 #include "base/debug/leak_annotations.h" | 59 #include "base/debug/leak_annotations.h" |
| 59 #include "chrome/app/mash/mash_crash_reporter_client.h" | 60 #include "chrome/app/mash/mash_crash_reporter_client.h" |
| 60 #include "components/crash/content/app/breakpad_linux.h" // nogncheck | 61 #include "components/crash/content/app/breakpad_linux.h" // nogncheck |
| 61 #endif | 62 #endif |
| 62 | 63 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 148 #endif // defined(OS_CHROMEOS) | 149 #endif // defined(OS_CHROMEOS) |
| 149 | 150 |
| 150 // Quits |run_loop| if the |identity| of the quitting service is critical to the | 151 // Quits |run_loop| if the |identity| of the quitting service is critical to the |
| 151 // system (e.g. the window manager). Used in the main process. | 152 // system (e.g. the window manager). Used in the main process. |
| 152 void OnInstanceQuitInMain(base::RunLoop* run_loop, | 153 void OnInstanceQuitInMain(base::RunLoop* run_loop, |
| 153 int* exit_value, | 154 int* exit_value, |
| 154 const service_manager::Identity& identity) { | 155 const service_manager::Identity& identity) { |
| 155 DCHECK(exit_value); | 156 DCHECK(exit_value); |
| 156 DCHECK(run_loop); | 157 DCHECK(run_loop); |
| 157 | 158 |
| 158 // TODO(jamescook): Also shut down if the window server dies. | 159 if (identity.name() != mash::common::GetWindowManagerServiceName() && |
| 159 if (identity.name() != mash::common::GetWindowManagerServiceName()) | 160 identity.name() != ui::mojom::kServiceName) { |
| 160 return; | 161 return; |
| 162 } | |
| 161 | 163 |
| 162 if (!run_loop->running()) | 164 LOG(ERROR) << "Main process exiting because service " << identity.name() |
|
James Cook
2017/02/01 18:19:54
This wasn't needed. RunLoop::Quit() is a no-op if
Ken Rockot(use gerrit already)
2017/02/01 21:13:55
Ah right, missed this. In fact, it's also not poss
James Cook
2017/02/01 21:26:51
Acknowledged.
| |
| 163 return; | 165 << " quit unexpectedly."; |
| 164 | |
| 165 *exit_value = 1; | 166 *exit_value = 1; |
| 166 run_loop->Quit(); | 167 run_loop->Quit(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 } // namespace | 170 } // namespace |
| 170 | 171 |
| 171 MashRunner::MashRunner() {} | 172 MashRunner::MashRunner() {} |
| 172 | 173 |
| 173 MashRunner::~MashRunner() {} | 174 MashRunner::~MashRunner() {} |
| 174 | 175 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 kChromeMashServiceName, service_manager::mojom::kRootUserID), | 218 kChromeMashServiceName, service_manager::mojom::kRootUserID), |
| 218 std::move(service), nullptr); | 219 std::move(service), nullptr); |
| 219 | 220 |
| 220 // Quit the main process if an important child (e.g. window manager) dies. | 221 // Quit the main process if an important child (e.g. window manager) dies. |
| 221 // On Chrome OS the OS-level session_manager will restart the main process. | 222 // On Chrome OS the OS-level session_manager will restart the main process. |
| 222 base::RunLoop run_loop; | 223 base::RunLoop run_loop; |
| 223 int exit_value = 0; | 224 int exit_value = 0; |
| 224 background_service_manager.SetInstanceQuitCallback( | 225 background_service_manager.SetInstanceQuitCallback( |
| 225 base::Bind(&OnInstanceQuitInMain, &run_loop, &exit_value)); | 226 base::Bind(&OnInstanceQuitInMain, &run_loop, &exit_value)); |
| 226 | 227 |
| 227 // Ping services that we know we want to launch on startup. | 228 // Ping services that we know we want to launch on startup (UI service, |
| 228 // TODO(jamescook): Start the window server / ui service explicitly. | 229 // window manager, quick launch app). |
| 230 context_->connector()->Connect(ui::mojom::kServiceName); | |
| 229 context_->connector()->Connect(mash::common::GetWindowManagerServiceName()); | 231 context_->connector()->Connect(mash::common::GetWindowManagerServiceName()); |
| 230 context_->connector()->Connect(mash::quick_launch::mojom::kServiceName); | 232 context_->connector()->Connect(mash::quick_launch::mojom::kServiceName); |
| 231 | 233 |
| 232 run_loop.Run(); | 234 run_loop.Run(); |
| 233 | 235 |
| 234 context_.reset(); | 236 context_.reset(); |
| 235 return exit_value; | 237 return exit_value; |
| 236 } | 238 } |
| 237 | 239 |
| 238 int MashRunner::RunChild() { | 240 int MashRunner::RunChild() { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 313 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { | 315 command_line->GetSwitchValueASCII(switches::kWaitForDebugger)) { |
| 314 return; | 316 return; |
| 315 } | 317 } |
| 316 | 318 |
| 317 // Include the pid as logging may not have been initialized yet (the pid | 319 // Include the pid as logging may not have been initialized yet (the pid |
| 318 // printed out by logging is wrong). | 320 // printed out by logging is wrong). |
| 319 LOG(WARNING) << "waiting for debugger to attach for service " << service_name | 321 LOG(WARNING) << "waiting for debugger to attach for service " << service_name |
| 320 << " pid=" << base::Process::Current().Pid(); | 322 << " pid=" << base::Process::Current().Pid(); |
| 321 base::debug::WaitForDebugger(120, true); | 323 base::debug::WaitForDebugger(120, true); |
| 322 } | 324 } |
| OLD | NEW |