| 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 <memory> |
| 6 #include "base/command_line.h" | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "mojo/public/cpp/bindings/binding_set.h" | 9 #include "mojo/public/cpp/bindings/binding_set.h" |
| 10 #include "services/service_manager/public/cpp/connection.h" | 10 #include "services/service_manager/public/c/main.h" |
| 11 #include "services/service_manager/public/cpp/connector.h" | |
| 12 #include "services/service_manager/public/cpp/interface_factory.h" | 11 #include "services/service_manager/public/cpp/interface_factory.h" |
| 13 #include "services/service_manager/public/cpp/interface_registry.h" | 12 #include "services/service_manager/public/cpp/interface_registry.h" |
| 14 #include "services/service_manager/public/cpp/service.h" | 13 #include "services/service_manager/public/cpp/service.h" |
| 15 #include "services/service_manager/public/cpp/service_context.h" | 14 #include "services/service_manager/public/cpp/service_context.h" |
| 16 #include "services/service_manager/runner/child/test_native_main.h" | 15 #include "services/service_manager/public/cpp/service_runner.h" |
| 17 #include "services/service_manager/runner/init.h" | |
| 18 #include "services/service_manager/tests/connect/connect_test.mojom.h" | 16 #include "services/service_manager/tests/connect/connect_test.mojom.h" |
| 19 | 17 |
| 20 using service_manager::test::mojom::ConnectTestService; | 18 using service_manager::test::mojom::ConnectTestService; |
| 21 using service_manager::test::mojom::ConnectTestServiceRequest; | 19 using service_manager::test::mojom::ConnectTestServiceRequest; |
| 22 | 20 |
| 23 namespace { | 21 namespace { |
| 24 | 22 |
| 25 class Target : public service_manager::Service, | 23 class Target : public service_manager::Service, |
| 26 public service_manager::InterfaceFactory<ConnectTestService>, | 24 public service_manager::InterfaceFactory<ConnectTestService>, |
| 27 public ConnectTestService { | 25 public ConnectTestService { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 40 // service_manager::InterfaceFactory<ConnectTestService>: | 38 // service_manager::InterfaceFactory<ConnectTestService>: |
| 41 void Create(const service_manager::Identity& remote_identity, | 39 void Create(const service_manager::Identity& remote_identity, |
| 42 ConnectTestServiceRequest request) override { | 40 ConnectTestServiceRequest request) override { |
| 43 bindings_.AddBinding(this, std::move(request)); | 41 bindings_.AddBinding(this, std::move(request)); |
| 44 } | 42 } |
| 45 | 43 |
| 46 // ConnectTestService: | 44 // ConnectTestService: |
| 47 void GetTitle(const GetTitleCallback& callback) override { | 45 void GetTitle(const GetTitleCallback& callback) override { |
| 48 callback.Run("connect_test_exe"); | 46 callback.Run("connect_test_exe"); |
| 49 } | 47 } |
| 48 |
| 50 void GetInstance(const GetInstanceCallback& callback) override { | 49 void GetInstance(const GetInstanceCallback& callback) override { |
| 51 callback.Run(context()->identity().instance()); | 50 callback.Run(context()->identity().instance()); |
| 52 } | 51 } |
| 53 | 52 |
| 54 mojo::BindingSet<ConnectTestService> bindings_; | 53 mojo::BindingSet<ConnectTestService> bindings_; |
| 55 | 54 |
| 56 DISALLOW_COPY_AND_ASSIGN(Target); | 55 DISALLOW_COPY_AND_ASSIGN(Target); |
| 57 }; | 56 }; |
| 58 | 57 |
| 59 } // namespace | 58 } // namespac |
| 60 | 59 |
| 61 int main(int argc, char** argv) { | 60 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 62 base::AtExitManager at_exit; | 61 service_manager::ServiceRunner runner(new Target); |
| 63 base::CommandLine::Init(argc, argv); | 62 return runner.Run(service_request_handle); |
| 64 | |
| 65 service_manager::InitializeLogging(); | |
| 66 return service_manager::TestNativeMain(base::MakeUnique<Target>()); | |
| 67 } | 63 } |
| OLD | NEW |