| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 title_(title), | 54 title_(title), |
| 55 request_(std::move(request)) { | 55 request_(std::move(request)) { |
| 56 Start(); | 56 Start(); |
| 57 } | 57 } |
| 58 ~ProvidedService() override { | 58 ~ProvidedService() override { |
| 59 Join(); | 59 Join(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // service_manager::Service: | 63 // service_manager::Service: |
| 64 void OnStart(const Identity& identity) override { | 64 void OnStart(const ServiceInfo& info) override { |
| 65 identity_ = identity; | 65 identity_ = info.identity; |
| 66 bindings_.set_connection_error_handler( | 66 bindings_.set_connection_error_handler( |
| 67 base::Bind(&ProvidedService::OnConnectionError, | 67 base::Bind(&ProvidedService::OnConnectionError, |
| 68 base::Unretained(this))); | 68 base::Unretained(this))); |
| 69 } | 69 } |
| 70 bool OnConnect(const Identity& remote_identity, | 70 bool OnConnect(const ServiceInfo& remote_info, |
| 71 InterfaceRegistry* registry) override { | 71 InterfaceRegistry* registry) override { |
| 72 registry->AddInterface<test::mojom::ConnectTestService>(this); | 72 registry->AddInterface<test::mojom::ConnectTestService>(this); |
| 73 registry->AddInterface<test::mojom::BlockedInterface>(this); | 73 registry->AddInterface<test::mojom::BlockedInterface>(this); |
| 74 registry->AddInterface<test::mojom::UserIdTest>(this); | 74 registry->AddInterface<test::mojom::UserIdTest>(this); |
| 75 | 75 |
| 76 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); | 76 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); |
| 77 state->connection_remote_name = remote_identity.name(); | 77 state->connection_remote_name = remote_info.identity.name(); |
| 78 state->connection_remote_userid = remote_identity.user_id(); | 78 state->connection_remote_userid = remote_info.identity.user_id(); |
| 79 state->initialize_local_name = identity_.name(); | 79 state->initialize_local_name = identity_.name(); |
| 80 state->initialize_userid = identity_.user_id(); | 80 state->initialize_userid = identity_.user_id(); |
| 81 | 81 |
| 82 connector()->ConnectToInterface(remote_identity, &caller_); | 82 connector()->ConnectToInterface(remote_info.identity, &caller_); |
| 83 caller_->ConnectionAccepted(std::move(state)); | 83 caller_->ConnectionAccepted(std::move(state)); |
| 84 | 84 |
| 85 return true; | 85 return true; |
| 86 } | 86 } |
| 87 | 87 |
| 88 // InterfaceFactory<test::mojom::ConnectTestService>: | 88 // InterfaceFactory<test::mojom::ConnectTestService>: |
| 89 void Create(const Identity& remote_identity, | 89 void Create(const Identity& remote_identity, |
| 90 test::mojom::ConnectTestServiceRequest request) override { | 90 test::mojom::ConnectTestServiceRequest request) override { |
| 91 bindings_.AddBinding(this, std::move(request)); | 91 bindings_.AddBinding(this, std::move(request)); |
| 92 } | 92 } |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 public InterfaceFactory<mojom::ServiceFactory>, | 162 public InterfaceFactory<mojom::ServiceFactory>, |
| 163 public InterfaceFactory<test::mojom::ConnectTestService>, | 163 public InterfaceFactory<test::mojom::ConnectTestService>, |
| 164 public mojom::ServiceFactory, | 164 public mojom::ServiceFactory, |
| 165 public test::mojom::ConnectTestService { | 165 public test::mojom::ConnectTestService { |
| 166 public: | 166 public: |
| 167 ConnectTestService() {} | 167 ConnectTestService() {} |
| 168 ~ConnectTestService() override {} | 168 ~ConnectTestService() override {} |
| 169 | 169 |
| 170 private: | 170 private: |
| 171 // service_manager::Service: | 171 // service_manager::Service: |
| 172 void OnStart(const Identity& identity) override { | 172 void OnStart(const ServiceInfo& info) override { |
| 173 identity_ = identity; | 173 identity_ = info.identity; |
| 174 bindings_.set_connection_error_handler( | 174 bindings_.set_connection_error_handler( |
| 175 base::Bind(&ConnectTestService::OnConnectionError, | 175 base::Bind(&ConnectTestService::OnConnectionError, |
| 176 base::Unretained(this))); | 176 base::Unretained(this))); |
| 177 } | 177 } |
| 178 bool OnConnect(const Identity& remote_identity, | 178 bool OnConnect(const ServiceInfo& remote_info, |
| 179 InterfaceRegistry* registry) override { | 179 InterfaceRegistry* registry) override { |
| 180 registry->AddInterface<ServiceFactory>(this); | 180 registry->AddInterface<ServiceFactory>(this); |
| 181 registry->AddInterface<test::mojom::ConnectTestService>(this); | 181 registry->AddInterface<test::mojom::ConnectTestService>(this); |
| 182 return true; | 182 return true; |
| 183 } | 183 } |
| 184 | 184 |
| 185 // InterfaceFactory<mojom::ServiceFactory>: | 185 // InterfaceFactory<mojom::ServiceFactory>: |
| 186 void Create(const Identity& remote_identity, | 186 void Create(const Identity& remote_identity, |
| 187 mojom::ServiceFactoryRequest request) override { | 187 mojom::ServiceFactoryRequest request) override { |
| 188 service_factory_bindings_.AddBinding(this, std::move(request)); | 188 service_factory_bindings_.AddBinding(this, std::move(request)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); | 224 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); |
| 225 }; | 225 }; |
| 226 | 226 |
| 227 } // namespace service_manager | 227 } // namespace service_manager |
| 228 | 228 |
| 229 MojoResult ServiceMain(MojoHandle service_request_handle) { | 229 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 230 service_manager::ServiceRunner runner( | 230 service_manager::ServiceRunner runner( |
| 231 new service_manager::ConnectTestService); | 231 new service_manager::ConnectTestService); |
| 232 return runner.Run(service_request_handle); | 232 return runner.Run(service_request_handle); |
| 233 } | 233 } |
| OLD | NEW |