| 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 "mojo/public/cpp/bindings/binding_set.h" | 5 #include "mojo/public/cpp/bindings/binding_set.h" |
| 6 #include "services/service_manager/background/tests/test.mojom.h" | 6 #include "services/service_manager/background/tests/test.mojom.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_registry.h" | 8 #include "services/service_manager/public/cpp/interface_registry.h" |
| 9 #include "services/service_manager/public/cpp/service.h" | 9 #include "services/service_manager/public/cpp/service.h" |
| 10 #include "services/service_manager/public/cpp/service_context.h" | 10 #include "services/service_manager/public/cpp/service_context.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 TestClient() {} | 21 TestClient() {} |
| 22 ~TestClient() override {} | 22 ~TestClient() override {} |
| 23 | 23 |
| 24 private: | 24 private: |
| 25 // Service: | 25 // Service: |
| 26 bool OnConnect(const ServiceInfo& remote_info, | 26 bool OnConnect(const ServiceInfo& remote_info, |
| 27 InterfaceRegistry* registry) override { | 27 InterfaceRegistry* registry) override { |
| 28 registry->AddInterface(this); | 28 registry->AddInterface(this); |
| 29 return true; | 29 return true; |
| 30 } | 30 } |
| 31 bool OnStop() override { | |
| 32 return true; | |
| 33 } | |
| 34 | 31 |
| 35 // InterfaceFactory<mojom::TestService>: | 32 // InterfaceFactory<mojom::TestService>: |
| 36 void Create(const Identity& remote_identity, | 33 void Create(const Identity& remote_identity, |
| 37 mojo::InterfaceRequest<mojom::TestService> request) override { | 34 mojo::InterfaceRequest<mojom::TestService> request) override { |
| 38 bindings_.AddBinding(this, std::move(request)); | 35 bindings_.AddBinding(this, std::move(request)); |
| 39 } | 36 } |
| 40 | 37 |
| 41 // mojom::TestService | 38 // mojom::TestService |
| 42 void Test(const TestCallback& callback) override { | 39 void Test(const TestCallback& callback) override { |
| 43 callback.Run(); | 40 callback.Run(); |
| 44 } | 41 } |
| 45 | 42 |
| 46 void Quit() override { context()->RequestQuit(); } | 43 void Quit() override { context()->RequestQuit(); } |
| 47 | 44 |
| 48 mojo::BindingSet<mojom::TestService> bindings_; | 45 mojo::BindingSet<mojom::TestService> bindings_; |
| 49 | 46 |
| 50 DISALLOW_COPY_AND_ASSIGN(TestClient); | 47 DISALLOW_COPY_AND_ASSIGN(TestClient); |
| 51 }; | 48 }; |
| 52 | 49 |
| 53 } // namespace service_manager | 50 } // namespace service_manager |
| 54 | 51 |
| 55 MojoResult ServiceMain(MojoHandle service_request_handle) { | 52 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 56 service_manager::ServiceRunner runner(new service_manager::TestClient); | 53 service_manager::ServiceRunner runner(new service_manager::TestClient); |
| 57 return runner.Run(service_request_handle); | 54 return runner.Run(service_request_handle); |
| 58 } | 55 } |
| OLD | NEW |