| 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 <map> | 5 #include <map> |
| 6 #include <memory> | 6 #include <memory> |
| 7 | 7 |
| 8 #include "mojo/public/c/system/main.h" | 8 #include "mojo/public/c/system/main.h" |
| 9 #include "mojo/public/cpp/application/application_delegate.h" | 9 #include "mojo/public/cpp/application/application_impl_base.h" |
| 10 #include "mojo/public/cpp/application/application_runner.h" | 10 #include "mojo/public/cpp/application/run_application.h" |
| 11 #include "mojo/public/cpp/application/service_provider_impl.h" | 11 #include "mojo/public/cpp/application/service_provider_impl.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/public/cpp/system/macros.h" | 13 #include "mojo/public/cpp/system/macros.h" |
| 14 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h" | 14 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h" |
| 15 | 15 |
| 16 namespace mojo { | 16 namespace mojo { |
| 17 namespace test { | 17 namespace test { |
| 18 namespace versioning { | 18 namespace versioning { |
| 19 | 19 |
| 20 struct EmployeeInfo { | 20 struct EmployeeInfo { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 employees_[id]->finger_print = finger_print.Pass(); | 85 employees_[id]->finger_print = finger_print.Pass(); |
| 86 callback.Run(true); | 86 callback.Run(true); |
| 87 } | 87 } |
| 88 | 88 |
| 89 private: | 89 private: |
| 90 std::map<uint64_t, EmployeeInfo*> employees_; | 90 std::map<uint64_t, EmployeeInfo*> employees_; |
| 91 | 91 |
| 92 StrongBinding<HumanResourceDatabase> strong_binding_; | 92 StrongBinding<HumanResourceDatabase> strong_binding_; |
| 93 |
| 94 MOJO_DISALLOW_COPY_AND_ASSIGN(HumanResourceDatabaseImpl); |
| 93 }; | 95 }; |
| 94 | 96 |
| 95 class HumanResourceSystemServer : public ApplicationDelegate { | 97 class HumanResourceSystemServer : public ApplicationImplBase { |
| 96 public: | 98 public: |
| 97 HumanResourceSystemServer() {} | 99 HumanResourceSystemServer() {} |
| 100 ~HumanResourceSystemServer() override {} |
| 98 | 101 |
| 99 // ApplicationDelegate implementation. | 102 // |ApplicationImplBase| overrides: |
| 100 bool ConfigureIncomingConnection( | 103 bool OnAcceptConnection(ServiceProviderImpl* service_provider_impl) override { |
| 101 ServiceProviderImpl* service_provider_impl) override { | |
| 102 service_provider_impl->AddService<HumanResourceDatabase>( | 104 service_provider_impl->AddService<HumanResourceDatabase>( |
| 103 [](const ConnectionContext& connection_context, | 105 [](const ConnectionContext& connection_context, |
| 104 InterfaceRequest<HumanResourceDatabase> hr_db_request) { | 106 InterfaceRequest<HumanResourceDatabase> hr_db_request) { |
| 105 // It will be deleted automatically when the underlying pipe | 107 // It will be deleted automatically when the underlying pipe |
| 106 // encounters a connection error. | 108 // encounters a connection error. |
| 107 new HumanResourceDatabaseImpl(hr_db_request.Pass()); | 109 new HumanResourceDatabaseImpl(hr_db_request.Pass()); |
| 108 }); | 110 }); |
| 109 return true; | 111 return true; |
| 110 } | 112 } |
| 113 |
| 114 private: |
| 115 MOJO_DISALLOW_COPY_AND_ASSIGN(HumanResourceSystemServer); |
| 111 }; | 116 }; |
| 112 | 117 |
| 113 } // namespace versioning | 118 } // namespace versioning |
| 114 } // namespace test | 119 } // namespace test |
| 115 } // namespace mojo | 120 } // namespace mojo |
| 116 | 121 |
| 117 MojoResult MojoMain(MojoHandle application_request) { | 122 MojoResult MojoMain(MojoHandle application_request) { |
| 118 mojo::ApplicationRunner runner( | 123 mojo::test::versioning::HumanResourceSystemServer hr_system_server; |
| 119 std::unique_ptr<mojo::test::versioning::HumanResourceSystemServer>( | 124 mojo::RunApplication(application_request, &hr_system_server); |
| 120 new mojo::test::versioning::HumanResourceSystemServer())); | 125 return MOJO_RESULT_OK; |
| 121 | |
| 122 return runner.Run(application_request); | |
| 123 } | 126 } |
| OLD | NEW |