Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(480)

Side by Side Diff: mojo/public/cpp/bindings/tests/versioning_test_service.cc

Issue 2004493002: Add a mojo::RunApplication() for running implementations of ApplicationImplBase. (Closed) Base URL: https://github.com/domokit/mojo.git@work790_environment_no_instantiate
Patch Set: rebased Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/public/cpp/application/run_application.h ('k') | mojo/services/log/cpp/log_client.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/run_application.h ('k') | mojo/services/log/cpp/log_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698