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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "mojo/public/c/system/main.h" | 9 #include "mojo/public/c/system/main.h" |
10 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
11 #include "mojo/public/cpp/system/macros.h" | 11 #include "mojo/public/cpp/system/macros.h" |
12 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h" | 12 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h" |
13 #include "mojo/shell/public/cpp/application_connection.h" | |
14 #include "mojo/shell/public/cpp/application_delegate.h" | |
15 #include "mojo/shell/public/cpp/application_runner.h" | 13 #include "mojo/shell/public/cpp/application_runner.h" |
16 #include "mojo/shell/public/cpp/interface_factory.h" | 14 #include "mojo/shell/public/cpp/interface_factory.h" |
| 15 #include "mojo/shell/public/cpp/shell_client.h" |
17 | 16 |
18 namespace mojo { | 17 namespace mojo { |
19 namespace test { | 18 namespace test { |
20 namespace versioning { | 19 namespace versioning { |
21 | 20 |
22 struct EmployeeInfo { | 21 struct EmployeeInfo { |
23 public: | 22 public: |
24 EmployeeInfo() {} | 23 EmployeeInfo() {} |
25 | 24 |
26 EmployeePtr employee; | 25 EmployeePtr employee; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 callback.Run(true); | 87 callback.Run(true); |
89 } | 88 } |
90 | 89 |
91 private: | 90 private: |
92 std::map<uint64_t, EmployeeInfo*> employees_; | 91 std::map<uint64_t, EmployeeInfo*> employees_; |
93 | 92 |
94 StrongBinding<HumanResourceDatabase> strong_binding_; | 93 StrongBinding<HumanResourceDatabase> strong_binding_; |
95 }; | 94 }; |
96 | 95 |
97 class HumanResourceSystemServer | 96 class HumanResourceSystemServer |
98 : public ApplicationDelegate, | 97 : public ShellClient, |
99 public InterfaceFactory<HumanResourceDatabase> { | 98 public InterfaceFactory<HumanResourceDatabase> { |
100 public: | 99 public: |
101 HumanResourceSystemServer() {} | 100 HumanResourceSystemServer() {} |
102 | 101 |
103 // ApplicationDelegate implementation. | 102 // mojo::ShellClient implementation. |
104 bool AcceptConnection(ApplicationConnection* connection) override { | 103 bool AcceptConnection(Connection* connection) override { |
105 connection->AddService<HumanResourceDatabase>(this); | 104 connection->AddService<HumanResourceDatabase>(this); |
106 return true; | 105 return true; |
107 } | 106 } |
108 | 107 |
109 // InterfaceFactory<HumanResourceDatabase> implementation. | 108 // InterfaceFactory<HumanResourceDatabase> implementation. |
110 void Create(ApplicationConnection* connection, | 109 void Create(Connection* connection, |
111 InterfaceRequest<HumanResourceDatabase> request) override { | 110 InterfaceRequest<HumanResourceDatabase> request) override { |
112 // It will be deleted automatically when the underlying pipe encounters a | 111 // It will be deleted automatically when the underlying pipe encounters a |
113 // connection error. | 112 // connection error. |
114 new HumanResourceDatabaseImpl(request.Pass()); | 113 new HumanResourceDatabaseImpl(request.Pass()); |
115 } | 114 } |
116 }; | 115 }; |
117 | 116 |
118 } // namespace versioning | 117 } // namespace versioning |
119 } // namespace test | 118 } // namespace test |
120 } // namespace mojo | 119 } // namespace mojo |
121 | 120 |
122 MojoResult MojoMain(MojoHandle application_request) { | 121 MojoResult MojoMain(MojoHandle application_request) { |
123 mojo::ApplicationRunner runner( | 122 mojo::ApplicationRunner runner( |
124 new mojo::test::versioning::HumanResourceSystemServer()); | 123 new mojo::test::versioning::HumanResourceSystemServer()); |
125 | 124 |
126 return runner.Run(application_request); | 125 return runner.Run(application_request); |
127 } | 126 } |
OLD | NEW |