| 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 "base/at_exit.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "mojo/public/cpp/bindings/binding_set.h" | 8 #include "mojo/public/cpp/bindings/binding_set.h" |
| 9 #include "services/service_manager/public/cpp/connection.h" | 9 #include "services/service_manager/public/cpp/connection.h" |
| 10 #include "services/service_manager/public/cpp/connector.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| 11 #include "services/service_manager/public/cpp/interface_factory.h" | 11 #include "services/service_manager/public/cpp/interface_factory.h" |
| 12 #include "services/service_manager/public/cpp/interface_registry.h" | 12 #include "services/service_manager/public/cpp/interface_registry.h" |
| 13 #include "services/service_manager/public/cpp/service.h" | 13 #include "services/service_manager/public/cpp/service.h" |
| 14 #include "services/service_manager/runner/child/test_native_main.h" | 14 #include "services/service_manager/runner/child/test_native_main.h" |
| 15 #include "services/service_manager/runner/init.h" | 15 #include "services/service_manager/runner/init.h" |
| 16 #include "services/service_manager/tests/connect/connect_test.mojom.h" | 16 #include "services/service_manager/tests/connect/connect_test.mojom.h" |
| 17 | 17 |
| 18 using shell::test::mojom::ConnectTestService; | 18 using service_manager::test::mojom::ConnectTestService; |
| 19 using shell::test::mojom::ConnectTestServiceRequest; | 19 using service_manager::test::mojom::ConnectTestServiceRequest; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class Target : public shell::Service, | 23 class Target : public service_manager::Service, |
| 24 public shell::InterfaceFactory<ConnectTestService>, | 24 public service_manager::InterfaceFactory<ConnectTestService>, |
| 25 public ConnectTestService { | 25 public ConnectTestService { |
| 26 public: | 26 public: |
| 27 Target() {} | 27 Target() {} |
| 28 ~Target() override {} | 28 ~Target() override {} |
| 29 | 29 |
| 30 private: | 30 private: |
| 31 // shell::Service: | 31 // service_manager::Service: |
| 32 void OnStart(const shell::Identity& identity) override { | 32 void OnStart(const service_manager::Identity& identity) override { |
| 33 identity_ = identity; | 33 identity_ = identity; |
| 34 } | 34 } |
| 35 bool OnConnect(const shell::Identity& remote_identity, | 35 bool OnConnect(const service_manager::Identity& remote_identity, |
| 36 shell::InterfaceRegistry* registry) override { | 36 service_manager::InterfaceRegistry* registry) override { |
| 37 registry->AddInterface<ConnectTestService>(this); | 37 registry->AddInterface<ConnectTestService>(this); |
| 38 return true; | 38 return true; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // shell::InterfaceFactory<ConnectTestService>: | 41 // service_manager::InterfaceFactory<ConnectTestService>: |
| 42 void Create(const shell::Identity& remote_identity, | 42 void Create(const service_manager::Identity& remote_identity, |
| 43 ConnectTestServiceRequest request) override { | 43 ConnectTestServiceRequest request) override { |
| 44 bindings_.AddBinding(this, std::move(request)); | 44 bindings_.AddBinding(this, std::move(request)); |
| 45 } | 45 } |
| 46 | 46 |
| 47 // ConnectTestService: | 47 // ConnectTestService: |
| 48 void GetTitle(const GetTitleCallback& callback) override { | 48 void GetTitle(const GetTitleCallback& callback) override { |
| 49 callback.Run("connect_test_exe"); | 49 callback.Run("connect_test_exe"); |
| 50 } | 50 } |
| 51 void GetInstance(const GetInstanceCallback& callback) override { | 51 void GetInstance(const GetInstanceCallback& callback) override { |
| 52 callback.Run(identity_.instance()); | 52 callback.Run(identity_.instance()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 shell::Identity identity_; | 55 service_manager::Identity identity_; |
| 56 mojo::BindingSet<ConnectTestService> bindings_; | 56 mojo::BindingSet<ConnectTestService> bindings_; |
| 57 | 57 |
| 58 DISALLOW_COPY_AND_ASSIGN(Target); | 58 DISALLOW_COPY_AND_ASSIGN(Target); |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 int main(int argc, char** argv) { | 63 int main(int argc, char** argv) { |
| 64 base::AtExitManager at_exit; | 64 base::AtExitManager at_exit; |
| 65 base::CommandLine::Init(argc, argv); | 65 base::CommandLine::Init(argc, argv); |
| 66 | 66 |
| 67 shell::InitializeLogging(); | 67 service_manager::InitializeLogging(); |
| 68 | 68 |
| 69 Target target; | 69 Target target; |
| 70 return shell::TestNativeMain(&target); | 70 return service_manager::TestNativeMain(&target); |
| 71 } | 71 } |
| OLD | NEW |