| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 private: | 62 private: |
| 63 // shell::Service: | 63 // shell::Service: |
| 64 void OnStart(const Identity& identity) override { | 64 void OnStart(const Identity& identity) override { |
| 65 identity_ = identity; | 65 identity_ = 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(Connection* connection) override { | 70 bool OnConnect(const Identity& remote_identity, |
| 71 connection->AddInterface<test::mojom::ConnectTestService>(this); | 71 InterfaceRegistry* registry) override { |
| 72 connection->AddInterface<test::mojom::BlockedInterface>(this); | 72 registry->AddInterface<test::mojom::ConnectTestService>(this); |
| 73 connection->AddInterface<test::mojom::UserIdTest>(this); | 73 registry->AddInterface<test::mojom::BlockedInterface>(this); |
| 74 registry->AddInterface<test::mojom::UserIdTest>(this); |
| 74 | 75 |
| 75 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); | 76 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); |
| 76 state->connection_remote_name = connection->GetRemoteIdentity().name(); | 77 state->connection_remote_name = remote_identity.name(); |
| 77 state->connection_remote_userid = connection->GetRemoteIdentity().user_id(); | 78 state->connection_remote_userid = remote_identity.user_id(); |
| 78 state->initialize_local_name = identity_.name(); | 79 state->initialize_local_name = identity_.name(); |
| 79 state->initialize_userid = identity_.user_id(); | 80 state->initialize_userid = identity_.user_id(); |
| 80 | 81 |
| 81 connector()->ConnectToInterface(connection->GetRemoteIdentity(), &caller_); | 82 connector()->ConnectToInterface(remote_identity, &caller_); |
| 82 caller_->ConnectionAccepted(std::move(state)); | 83 caller_->ConnectionAccepted(std::move(state)); |
| 83 | 84 |
| 84 return true; | 85 return true; |
| 85 } | 86 } |
| 86 | 87 |
| 87 // InterfaceFactory<test::mojom::ConnectTestService>: | 88 // InterfaceFactory<test::mojom::ConnectTestService>: |
| 88 void Create(const Identity& remote_identity, | 89 void Create(const Identity& remote_identity, |
| 89 test::mojom::ConnectTestServiceRequest request) override { | 90 test::mojom::ConnectTestServiceRequest request) override { |
| 90 bindings_.AddBinding(this, std::move(request)); | 91 bindings_.AddBinding(this, std::move(request)); |
| 91 } | 92 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 ~ConnectTestService() override {} | 168 ~ConnectTestService() override {} |
| 168 | 169 |
| 169 private: | 170 private: |
| 170 // shell::Service: | 171 // shell::Service: |
| 171 void OnStart(const Identity& identity) override { | 172 void OnStart(const Identity& identity) override { |
| 172 identity_ = identity; | 173 identity_ = identity; |
| 173 bindings_.set_connection_error_handler( | 174 bindings_.set_connection_error_handler( |
| 174 base::Bind(&ConnectTestService::OnConnectionError, | 175 base::Bind(&ConnectTestService::OnConnectionError, |
| 175 base::Unretained(this))); | 176 base::Unretained(this))); |
| 176 } | 177 } |
| 177 bool OnConnect(Connection* connection) override { | 178 bool OnConnect(const Identity& remote_identity, |
| 178 connection->AddInterface<ServiceFactory>(this); | 179 InterfaceRegistry* registry) override { |
| 179 connection->AddInterface<test::mojom::ConnectTestService>(this); | 180 registry->AddInterface<ServiceFactory>(this); |
| 181 registry->AddInterface<test::mojom::ConnectTestService>(this); |
| 180 return true; | 182 return true; |
| 181 } | 183 } |
| 182 | 184 |
| 183 // InterfaceFactory<mojom::ServiceFactory>: | 185 // InterfaceFactory<mojom::ServiceFactory>: |
| 184 void Create(const Identity& remote_identity, | 186 void Create(const Identity& remote_identity, |
| 185 mojom::ServiceFactoryRequest request) override { | 187 mojom::ServiceFactoryRequest request) override { |
| 186 service_factory_bindings_.AddBinding(this, std::move(request)); | 188 service_factory_bindings_.AddBinding(this, std::move(request)); |
| 187 } | 189 } |
| 188 | 190 |
| 189 // InterfaceFactory<test::mojom::ConnectTestService>: | 191 // InterfaceFactory<test::mojom::ConnectTestService>: |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 | 223 |
| 222 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); | 224 DISALLOW_COPY_AND_ASSIGN(ConnectTestService); |
| 223 }; | 225 }; |
| 224 | 226 |
| 225 } // namespace shell | 227 } // namespace shell |
| 226 | 228 |
| 227 MojoResult ServiceMain(MojoHandle service_request_handle) { | 229 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 228 shell::ServiceRunner runner(new shell::ConnectTestService); | 230 shell::ServiceRunner runner(new shell::ConnectTestService); |
| 229 return runner.Run(service_request_handle); | 231 return runner.Run(service_request_handle); |
| 230 } | 232 } |
| OLD | NEW |