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