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

Side by Side Diff: mojo/public/cpp/application/lib/service_provider_impl.cc

Issue 1977033002: Make ServiceRegistry (which implements) ApplicationConnection just wrap a ServiceProviderImpl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 7 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
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 "mojo/public/cpp/application/service_provider_impl.h" 5 #include "mojo/public/cpp/application/service_provider_impl.h"
6 6
7 #include "mojo/public/cpp/application/service_connector.h" 7 #include "mojo/public/cpp/application/service_connector.h"
8 #include "mojo/public/cpp/environment/logging.h" 8 #include "mojo/public/cpp/environment/logging.h"
9 9
10 namespace mojo { 10 namespace mojo {
11 11
12 ServiceProviderImpl::ServiceProviderImpl() 12 ServiceProviderImpl::ServiceProviderImpl()
13 : binding_(this), fallback_service_provider_(nullptr) { 13 : binding_(this), fallback_service_provider_(nullptr) {
14 } 14 }
15 15
16 ServiceProviderImpl::ServiceProviderImpl( 16 ServiceProviderImpl::ServiceProviderImpl(
17 const ConnectionContext& connection_context, 17 const ConnectionContext& connection_context,
18 InterfaceRequest<ServiceProvider> service_provider_request) 18 InterfaceRequest<ServiceProvider> service_provider_request)
19 : connection_context_(connection_context), 19 : binding_(this), fallback_service_provider_(nullptr) {
20 binding_(this, service_provider_request.Pass()), 20 if (service_provider_request.is_pending())
21 fallback_service_provider_(nullptr) {} 21 Bind(connection_context, service_provider_request.Pass());
22 }
22 23
23 ServiceProviderImpl::~ServiceProviderImpl() {} 24 ServiceProviderImpl::~ServiceProviderImpl() {}
24 25
25 void ServiceProviderImpl::Bind( 26 void ServiceProviderImpl::Bind(
26 const ConnectionContext& connection_context, 27 const ConnectionContext& connection_context,
27 InterfaceRequest<ServiceProvider> service_provider_request) { 28 InterfaceRequest<ServiceProvider> service_provider_request) {
28 connection_context_ = connection_context; 29 connection_context_ = connection_context;
29 binding_.Bind(service_provider_request.Pass()); 30 binding_.Bind(service_provider_request.Pass());
30 } 31 }
31 32
32 void ServiceProviderImpl::Close() { 33 void ServiceProviderImpl::Close() {
33 if (binding_.is_bound()) { 34 if (binding_.is_bound()) {
34 binding_.Close(); 35 binding_.Close();
35 connection_context_ = ConnectionContext(); 36 connection_context_ = ConnectionContext();
36 } 37 }
37 } 38 }
38 39
39 void ServiceProviderImpl::ConnectToService( 40 void ServiceProviderImpl::ConnectToService(
40 const String& service_name, 41 const String& service_name,
41 ScopedMessagePipeHandle client_handle) { 42 ScopedMessagePipeHandle client_handle) {
42 bool service_found = service_connector_registry_.ConnectToService( 43 bool service_found = service_connector_registry_.ConnectToService(
43 connection_context_, service_name, &client_handle); 44 connection_context_, service_name, &client_handle);
44 if (!service_found && fallback_service_provider_) { 45 if (!service_found && fallback_service_provider_) {
45 fallback_service_provider_->ConnectToService(service_name, 46 fallback_service_provider_->ConnectToService(service_name,
46 client_handle.Pass()); 47 client_handle.Pass());
47 } 48 }
48 } 49 }
49 50
50 } // namespace mojo 51 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/application_connection.h ('k') | mojo/public/cpp/application/lib/service_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698