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

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

Issue 2795883002: Eliminate OnConnect usage (Closed)
Patch Set: . Created 3 years, 8 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 | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <map> 7 #include <map>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h" 11 #include "mojo/public/cpp/bindings/strong_binding.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 "services/service_manager/public/c/main.h" 13 #include "services/service_manager/public/c/main.h"
14 #include "services/service_manager/public/cpp/binder_registry.h"
14 #include "services/service_manager/public/cpp/interface_factory.h" 15 #include "services/service_manager/public/cpp/interface_factory.h"
15 #include "services/service_manager/public/cpp/service.h" 16 #include "services/service_manager/public/cpp/service.h"
16 #include "services/service_manager/public/cpp/service_runner.h" 17 #include "services/service_manager/public/cpp/service_runner.h"
17 18
18 namespace mojo { 19 namespace mojo {
19 namespace test { 20 namespace test {
20 namespace versioning { 21 namespace versioning {
21 22
22 struct EmployeeInfo { 23 struct EmployeeInfo {
23 public: 24 public:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 private: 92 private:
92 std::map<uint64_t, EmployeeInfo*> employees_; 93 std::map<uint64_t, EmployeeInfo*> employees_;
93 94
94 StrongBinding<HumanResourceDatabase> strong_binding_; 95 StrongBinding<HumanResourceDatabase> strong_binding_;
95 }; 96 };
96 97
97 class HumanResourceSystemServer 98 class HumanResourceSystemServer
98 : public service_manager::Service, 99 : public service_manager::Service,
99 public InterfaceFactory<HumanResourceDatabase> { 100 public InterfaceFactory<HumanResourceDatabase> {
100 public: 101 public:
101 HumanResourceSystemServer() {} 102 HumanResourceSystemServer() {
103 registry_.AddInterface<HumanResourceDatabase>(this);
104 }
102 105
103 // service_manager::Service implementation. 106 // service_manager::Service implementation.
104 bool OnConnect(Connection* connection) override { 107 void OnBindInterface(const service_manager::ServiceInfo& source_info,
105 connection->AddInterface<HumanResourceDatabase>(this); 108 const std::string& interface_name,
106 return true; 109 mojo::ScopedMessagePipeHandle interface_pipe) override {
110 registry_.BindInterface(source_info.identity, interface_name,
111 std::move(interface_pipe));
107 } 112 }
108 113
109 // InterfaceFactory<HumanResourceDatabase> implementation. 114 // InterfaceFactory<HumanResourceDatabase> implementation.
110 void Create(Connection* connection, 115 void Create(Connection* connection,
111 InterfaceRequest<HumanResourceDatabase> request) override { 116 InterfaceRequest<HumanResourceDatabase> request) override {
112 // It will be deleted automatically when the underlying pipe encounters a 117 // It will be deleted automatically when the underlying pipe encounters a
113 // connection error. 118 // connection error.
114 new HumanResourceDatabaseImpl(std::move(request)); 119 new HumanResourceDatabaseImpl(std::move(request));
115 } 120 }
121
122 private:
123 service_manager::BinderRegistry registry_;
116 }; 124 };
117 125
118 } // namespace versioning 126 } // namespace versioning
119 } // namespace test 127 } // namespace test
120 } // namespace mojo 128 } // namespace mojo
121 129
122 MojoResult ServiceMain(MojoHandle request) { 130 MojoResult ServiceMain(MojoHandle request) {
123 mojo::ServiceRunner runner( 131 mojo::ServiceRunner runner(
124 new mojo::test::versioning::HumanResourceSystemServer()); 132 new mojo::test::versioning::HumanResourceSystemServer());
125 133
126 return runner.Run(request); 134 return runner.Run(request);
127 } 135 }
OLDNEW
« no previous file with comments | « media/mojo/services/media_service.cc ('k') | services/catalog/catalog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698