| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/at_exit.h" | 5 #include "base/at_exit.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "media/mojo/services/media_service_factory.h" | 9 #include "media/mojo/services/media_service_factory.h" |
| 10 #include "services/service_manager/public/c/main.h" | 10 #include "services/service_manager/public/c/main.h" |
| 11 #include "services/service_manager/public/cpp/service_runner.h" | 11 #include "services/service_manager/public/cpp/service_runner.h" |
| 12 | 12 |
| 13 namespace { | |
| 14 | |
| 15 service_manager::ServiceRunner* g_runner = nullptr; | |
| 16 | |
| 17 void QuitApplication() { | |
| 18 DCHECK(g_runner); | |
| 19 g_runner->Quit(); | |
| 20 } | |
| 21 | |
| 22 } // namespace | |
| 23 | |
| 24 MojoResult ServiceMain(MojoHandle mojo_handle) { | 13 MojoResult ServiceMain(MojoHandle mojo_handle) { |
| 25 // Enable logging. | 14 // Enable logging. |
| 26 base::AtExitManager at_exit; | 15 base::AtExitManager at_exit; |
| 27 service_manager::ServiceRunner::InitBaseCommandLine(); | 16 service_manager::ServiceRunner::InitBaseCommandLine(); |
| 28 | 17 |
| 29 logging::LoggingSettings settings; | 18 logging::LoggingSettings settings; |
| 30 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 19 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 31 logging::InitLogging(settings); | 20 logging::InitLogging(settings); |
| 32 | 21 |
| 33 std::unique_ptr<service_manager::Service> service = | 22 std::unique_ptr<service_manager::Service> service = |
| 34 media::CreateMediaServiceForTesting(base::Bind(&QuitApplication)); | 23 media::CreateMediaServiceForTesting(); |
| 35 service_manager::ServiceRunner runner(service.release()); | 24 service_manager::ServiceRunner runner(service.release()); |
| 36 g_runner = &runner; | |
| 37 return runner.Run(mojo_handle, false /* init_base */); | 25 return runner.Run(mojo_handle, false /* init_base */); |
| 38 } | 26 } |
| OLD | NEW |