| 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 "base/macros.h" | 5 #include "base/macros.h" |
| 6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
| 7 #include "services/service_manager/public/c/main.h" | 7 #include "services/service_manager/public/c/main.h" |
| 8 #include "services/service_manager/public/cpp/interface_factory.h" | 8 #include "services/service_manager/public/cpp/interface_factory.h" |
| 9 #include "services/service_manager/public/cpp/interface_registry.h" | 9 #include "services/service_manager/public/cpp/interface_registry.h" |
| 10 #include "services/service_manager/public/cpp/service.h" | 10 #include "services/service_manager/public/cpp/service.h" |
| 11 #include "services/service_manager/public/cpp/service_runner.h" | 11 #include "services/service_manager/public/cpp/service_runner.h" |
| 12 #include "services/service_manager/tests/shutdown/shutdown_unittest.mojom.h" | 12 #include "services/service_manager/tests/shutdown/shutdown_unittest.mojom.h" |
| 13 | 13 |
| 14 namespace service_manager { | 14 namespace service_manager { |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 service_manager::ServiceRunner* g_app = nullptr; | 17 service_manager::ServiceRunner* g_app = nullptr; |
| 18 | 18 |
| 19 class ShutdownServiceApp | 19 class ShutdownServiceApp |
| 20 : public Service, | 20 : public Service, |
| 21 public InterfaceFactory<mojom::ShutdownTestService>, | 21 public InterfaceFactory<mojom::ShutdownTestService>, |
| 22 public mojom::ShutdownTestService { | 22 public mojom::ShutdownTestService { |
| 23 public: | 23 public: |
| 24 ShutdownServiceApp() {} | 24 ShutdownServiceApp() {} |
| 25 ~ShutdownServiceApp() override {} | 25 ~ShutdownServiceApp() override {} |
| 26 | 26 |
| 27 private: | 27 private: |
| 28 // service_manager::Service: | 28 // service_manager::Service: |
| 29 bool OnConnect(const Identity& remote_identity, | 29 bool OnConnect(const ServiceInfo& remote_info, |
| 30 InterfaceRegistry* registry) override { | 30 InterfaceRegistry* registry) override { |
| 31 registry->AddInterface<mojom::ShutdownTestService>(this); | 31 registry->AddInterface<mojom::ShutdownTestService>(this); |
| 32 return true; | 32 return true; |
| 33 } | 33 } |
| 34 | 34 |
| 35 // InterfaceFactory<mojom::ShutdownTestService>: | 35 // InterfaceFactory<mojom::ShutdownTestService>: |
| 36 void Create(const Identity& remote_identity, | 36 void Create(const Identity& remote_identity, |
| 37 mojom::ShutdownTestServiceRequest request) override { | 37 mojom::ShutdownTestServiceRequest request) override { |
| 38 bindings_.AddBinding(this, std::move(request)); | 38 bindings_.AddBinding(this, std::move(request)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // mojom::ShutdownTestService: | 41 // mojom::ShutdownTestService: |
| 42 void SetClient(mojom::ShutdownTestClientPtr client) override {} | 42 void SetClient(mojom::ShutdownTestClientPtr client) override {} |
| 43 void ShutDown() override { g_app->Quit(); } | 43 void ShutDown() override { g_app->Quit(); } |
| 44 | 44 |
| 45 mojo::BindingSet<mojom::ShutdownTestService> bindings_; | 45 mojo::BindingSet<mojom::ShutdownTestService> bindings_; |
| 46 | 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ShutdownServiceApp); | 47 DISALLOW_COPY_AND_ASSIGN(ShutdownServiceApp); |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 } // namespace | 50 } // namespace |
| 51 } // namespace service_manager | 51 } // namespace service_manager |
| 52 | 52 |
| 53 MojoResult ServiceMain(MojoHandle service_request_handle) { | 53 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 54 service_manager::ServiceRunner runner( | 54 service_manager::ServiceRunner runner( |
| 55 new service_manager::ShutdownServiceApp); | 55 new service_manager::ShutdownServiceApp); |
| 56 service_manager::g_app = &runner; | 56 service_manager::g_app = &runner; |
| 57 return runner.Run(service_request_handle); | 57 return runner.Run(service_request_handle); |
| 58 } | 58 } |
| OLD | NEW |