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

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

Issue 1975253002: ApplicationConnection devolution, part 2.1. (Closed) Base URL: https://github.com/domokit/mojo.git@work792-x-work791_service_registry_spimpl
Patch Set: 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 | « examples/native_run_app/native_run_app.cc ('k') | mojo/ui/content_viewer_app.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_connection.h" 9 #include "mojo/public/cpp/application/application_connection.h"
10 #include "mojo/public/cpp/application/application_delegate.h" 10 #include "mojo/public/cpp/application/application_delegate.h"
11 #include "mojo/public/cpp/application/application_runner.h" 11 #include "mojo/public/cpp/application/application_runner.h"
12 #include "mojo/public/cpp/application/interface_factory.h"
13 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
14 #include "mojo/public/cpp/system/macros.h" 13 #include "mojo/public/cpp/system/macros.h"
15 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h" 14 #include "mojo/public/interfaces/bindings/tests/versioning_test_service.mojom.h"
16 15
17 namespace mojo { 16 namespace mojo {
18 namespace test { 17 namespace test {
19 namespace versioning { 18 namespace versioning {
20 19
21 struct EmployeeInfo { 20 struct EmployeeInfo {
22 public: 21 public:
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 employees_[id]->finger_print = finger_print.Pass(); 85 employees_[id]->finger_print = finger_print.Pass();
87 callback.Run(true); 86 callback.Run(true);
88 } 87 }
89 88
90 private: 89 private:
91 std::map<uint64_t, EmployeeInfo*> employees_; 90 std::map<uint64_t, EmployeeInfo*> employees_;
92 91
93 StrongBinding<HumanResourceDatabase> strong_binding_; 92 StrongBinding<HumanResourceDatabase> strong_binding_;
94 }; 93 };
95 94
96 class HumanResourceSystemServer 95 class HumanResourceSystemServer : public ApplicationDelegate {
97 : public ApplicationDelegate,
98 public InterfaceFactory<HumanResourceDatabase> {
99 public: 96 public:
100 HumanResourceSystemServer() {} 97 HumanResourceSystemServer() {}
101 98
102 // ApplicationDelegate implementation. 99 // ApplicationDelegate implementation.
103 bool ConfigureIncomingConnection(ApplicationConnection* connection) override { 100 bool ConfigureIncomingConnection(ApplicationConnection* connection) override {
104 connection->AddService<HumanResourceDatabase>(this); 101 connection->GetServiceProviderImpl().AddService<HumanResourceDatabase>(
102 [](const ConnectionContext& connection_context,
103 InterfaceRequest<HumanResourceDatabase> hr_db_request) {
104 // It will be deleted automatically when the underlying pipe
105 // encounters a connection error.
106 new HumanResourceDatabaseImpl(hr_db_request.Pass());
107 });
105 return true; 108 return true;
106 } 109 }
107
108 // InterfaceFactory<HumanResourceDatabase> implementation.
109 void Create(const ConnectionContext& connection_context,
110 InterfaceRequest<HumanResourceDatabase> request) override {
111 // It will be deleted automatically when the underlying pipe encounters a
112 // connection error.
113 new HumanResourceDatabaseImpl(request.Pass());
114 }
115 }; 110 };
116 111
117 } // namespace versioning 112 } // namespace versioning
118 } // namespace test 113 } // namespace test
119 } // namespace mojo 114 } // namespace mojo
120 115
121 MojoResult MojoMain(MojoHandle application_request) { 116 MojoResult MojoMain(MojoHandle application_request) {
122 mojo::ApplicationRunner runner( 117 mojo::ApplicationRunner runner(
123 std::unique_ptr<mojo::test::versioning::HumanResourceSystemServer>( 118 std::unique_ptr<mojo::test::versioning::HumanResourceSystemServer>(
124 new mojo::test::versioning::HumanResourceSystemServer())); 119 new mojo::test::versioning::HumanResourceSystemServer()));
125 120
126 return runner.Run(application_request); 121 return runner.Run(application_request);
127 } 122 }
OLDNEW
« no previous file with comments | « examples/native_run_app/native_run_app.cc ('k') | mojo/ui/content_viewer_app.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698