| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "services/shell/service_manager.h" | 5 #include "services/shell/service_manager.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 // The target has specified that sources must request one of its provided | 190 // The target has specified that sources must request one of its provided |
| 191 // classes instead of specifying a wild-card for interfaces. | 191 // classes instead of specifying a wild-card for interfaces. |
| 192 if (HasClass(capability_spec_, kCapabilityClass_ExplicitClass) && | 192 if (HasClass(capability_spec_, kCapabilityClass_ExplicitClass) && |
| 193 (request.interfaces.count("*") != 0)) { | 193 (request.interfaces.count("*") != 0)) { |
| 194 request.interfaces.erase("*"); | 194 request.interfaces.erase("*"); |
| 195 } | 195 } |
| 196 | 196 |
| 197 service_->OnConnect( | 197 service_->OnConnect( |
| 198 mojom::Identity::From(params->source()), source_id, | 198 mojom::Identity::From(params->source()), source_id, |
| 199 params->TakeRemoteInterfaces(), params->TakeLocalInterfaces(), | 199 params->TakeRemoteInterfaces(), mojom::CapabilityRequest::From(request), |
| 200 mojom::CapabilityRequest::From(request), params->target().name()); | 200 params->target().name()); |
| 201 | 201 |
| 202 return true; | 202 return true; |
| 203 } | 203 } |
| 204 | 204 |
| 205 void StartWithService(mojom::ServicePtr service) { | 205 void StartWithService(mojom::ServicePtr service) { |
| 206 CHECK(!service_); | 206 CHECK(!service_); |
| 207 service_ = std::move(service); | 207 service_ = std::move(service); |
| 208 service_.set_connection_error_handler( | 208 service_.set_connection_error_handler( |
| 209 base::Bind(&Instance::OnServiceLost, base::Unretained(this), | 209 base::Bind(&Instance::OnServiceLost, base::Unretained(this), |
| 210 service_manager_->GetWeakPtr())); | 210 service_manager_->GetWeakPtr())); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 // Service: | 251 // Service: |
| 252 bool OnConnect(Connection* connection) override { | 252 bool OnConnect(Connection* connection) override { |
| 253 connection->AddInterface<mojom::ServiceManager>(this); | 253 connection->AddInterface<mojom::ServiceManager>(this); |
| 254 return true; | 254 return true; |
| 255 } | 255 } |
| 256 | 256 |
| 257 private: | 257 private: |
| 258 // mojom::Connector implementation: | 258 // mojom::Connector implementation: |
| 259 void Connect(mojom::IdentityPtr target_ptr, | 259 void Connect(mojom::IdentityPtr target_ptr, |
| 260 mojom::InterfaceProviderRequest remote_interfaces, | 260 mojom::InterfaceProviderRequest remote_interfaces, |
| 261 mojom::InterfaceProviderPtr local_interfaces, | |
| 262 mojom::ClientProcessConnectionPtr client_process_connection, | 261 mojom::ClientProcessConnectionPtr client_process_connection, |
| 263 const ConnectCallback& callback) override { | 262 const ConnectCallback& callback) override { |
| 264 Identity target = target_ptr.To<Identity>(); | 263 Identity target = target_ptr.To<Identity>(); |
| 265 if (target.user_id() == mojom::kInheritUserID) | 264 if (target.user_id() == mojom::kInheritUserID) |
| 266 target.set_user_id(identity_.user_id()); | 265 target.set_user_id(identity_.user_id()); |
| 267 | 266 |
| 268 if (!ValidateIdentity(target, callback)) | 267 if (!ValidateIdentity(target, callback)) |
| 269 return; | 268 return; |
| 270 if (!ValidateClientProcessConnection(&client_process_connection, target, | 269 if (!ValidateClientProcessConnection(&client_process_connection, target, |
| 271 callback)) { | 270 callback)) { |
| 272 return; | 271 return; |
| 273 } | 272 } |
| 274 if (!ValidateCapabilities(target, callback)) | 273 if (!ValidateCapabilities(target, callback)) |
| 275 return; | 274 return; |
| 276 | 275 |
| 277 std::unique_ptr<ConnectParams> params(new ConnectParams); | 276 std::unique_ptr<ConnectParams> params(new ConnectParams); |
| 278 params->set_source(identity_); | 277 params->set_source(identity_); |
| 279 params->set_target(target); | 278 params->set_target(target); |
| 280 params->set_remote_interfaces(std::move(remote_interfaces)); | 279 params->set_remote_interfaces(std::move(remote_interfaces)); |
| 281 params->set_local_interfaces(std::move(local_interfaces)); | |
| 282 params->set_client_process_connection(std::move(client_process_connection)); | 280 params->set_client_process_connection(std::move(client_process_connection)); |
| 283 params->set_connect_callback(callback); | 281 params->set_connect_callback(callback); |
| 284 service_manager_->Connect( | 282 service_manager_->Connect( |
| 285 std::move(params), nullptr, weak_factory_.GetWeakPtr()); | 283 std::move(params), nullptr, weak_factory_.GetWeakPtr()); |
| 286 } | 284 } |
| 287 | 285 |
| 288 void Clone(mojom::ConnectorRequest request) override { | 286 void Clone(mojom::ConnectorRequest request) override { |
| 289 connectors_.AddBinding(this, std::move(request)); | 287 connectors_.AddBinding(this, std::move(request)); |
| 290 } | 288 } |
| 291 | 289 |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 // Now that the instance has a Service, we can connect to it. | 807 // Now that the instance has a Service, we can connect to it. |
| 810 bool connected = instance->ConnectToService(¶ms); | 808 bool connected = instance->ConnectToService(¶ms); |
| 811 DCHECK(connected); | 809 DCHECK(connected); |
| 812 } | 810 } |
| 813 | 811 |
| 814 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { | 812 base::WeakPtr<ServiceManager> ServiceManager::GetWeakPtr() { |
| 815 return weak_ptr_factory_.GetWeakPtr(); | 813 return weak_ptr_factory_.GetWeakPtr(); |
| 816 } | 814 } |
| 817 | 815 |
| 818 } // namespace shell | 816 } // namespace shell |
| OLD | NEW |