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

Side by Side Diff: services/shell/service_manager.cc

Issue 2209943002: Eliminate outgoing InterfaceProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tracing
Patch Set: . Created 4 years, 4 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 | « services/shell/public/interfaces/service.mojom ('k') | services/shell/standalone/context.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 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
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
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
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(&params); 808 bool connected = instance->ConnectToService(&params);
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
OLDNEW
« no previous file with comments | « services/shell/public/interfaces/service.mojom ('k') | services/shell/standalone/context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698