| 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 #ifndef SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ | 6 #define SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "mojo/public/cpp/bindings/binding_set.h" | 12 #include "mojo/public/cpp/bindings/binding_set.h" |
| 13 #include "services/service_manager/public/cpp/interface_factory.h" | 13 #include "services/service_manager/public/cpp/interface_factory.h" |
| 14 #include "services/service_manager/public/cpp/service.h" | 14 #include "services/service_manager/public/cpp/service.h" |
| 15 #include "services/service_manager/public/cpp/service_runner.h" | 15 #include "services/service_manager/public/cpp/service_runner.h" |
| 16 #include "services/service_manager/public/interfaces/service.mojom.h" | 16 #include "services/service_manager/public/interfaces/service.mojom.h" |
| 17 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h" | 17 #include "services/service_manager/tests/lifecycle/lifecycle_unittest.mojom.h" |
| 18 | 18 |
| 19 using LifecycleControl = service_manager::test::mojom::LifecycleControl; | |
| 20 using LifecycleControlRequest = | |
| 21 service_manager::test::mojom::LifecycleControlRequest; | |
| 22 | |
| 23 namespace service_manager { | 19 namespace service_manager { |
| 24 class ServiceContext; | |
| 25 | |
| 26 namespace test { | 20 namespace test { |
| 27 | 21 |
| 28 class AppClient : public Service, | 22 class AppClient : public Service, |
| 29 public InterfaceFactory<LifecycleControl>, | 23 public InterfaceFactory<mojom::LifecycleControl>, |
| 30 public LifecycleControl { | 24 public mojom::LifecycleControl { |
| 31 public: | 25 public: |
| 32 AppClient(); | 26 AppClient(); |
| 33 explicit AppClient(service_manager::mojom::ServiceRequest request); | |
| 34 ~AppClient() override; | 27 ~AppClient() override; |
| 35 | 28 |
| 36 void set_runner(ServiceRunner* runner) { | 29 void set_runner(ServiceRunner* runner) { runner_ = runner; } |
| 37 runner_ = runner; | |
| 38 } | |
| 39 | 30 |
| 40 // Service: | 31 // Serivce: |
| 32 void OnStart(ServiceContext* context) override; |
| 41 bool OnConnect(const ServiceInfo& remote_info, | 33 bool OnConnect(const ServiceInfo& remote_info, |
| 42 InterfaceRegistry* registry) override; | 34 InterfaceRegistry* registry) override; |
| 43 | 35 |
| 44 // InterfaceFactory<LifecycleControl>: | 36 // InterfaceFactory<LifecycleControl>: |
| 45 void Create(const Identity& remote_identity, | 37 void Create(const Identity& remote_identity, |
| 46 LifecycleControlRequest request) override; | 38 mojom::LifecycleControlRequest request) override; |
| 47 | 39 |
| 48 // LifecycleControl: | 40 // LifecycleControl: |
| 49 void Ping(const PingCallback& callback) override; | 41 void Ping(const PingCallback& callback) override; |
| 50 void GracefulQuit() override; | 42 void GracefulQuit() override; |
| 51 void Crash() override; | 43 void Crash() override; |
| 52 void CloseServiceManagerConnection() override; | 44 void CloseServiceManagerConnection() override; |
| 53 | 45 |
| 54 private: | 46 private: |
| 47 class ServiceImpl; |
| 48 |
| 55 void BindingLost(); | 49 void BindingLost(); |
| 56 | 50 |
| 51 ServiceContext* context_; |
| 57 ServiceRunner* runner_ = nullptr; | 52 ServiceRunner* runner_ = nullptr; |
| 58 mojo::BindingSet<LifecycleControl> bindings_; | 53 mojo::BindingSet<mojom::LifecycleControl> bindings_; |
| 59 std::unique_ptr<ServiceContext> context_; | |
| 60 | 54 |
| 61 DISALLOW_COPY_AND_ASSIGN(AppClient); | 55 DISALLOW_COPY_AND_ASSIGN(AppClient); |
| 62 }; | 56 }; |
| 63 | 57 |
| 64 } // namespace test | 58 } // namespace test |
| 65 } // namespace service_manager | 59 } // namespace service_manager |
| 66 | 60 |
| 67 #endif // SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ | 61 #endif // SERVICES_SERVICE_MANAGER_TESTS_LIFECYCLE_APP_CLIENT_H_ |
| OLD | NEW |