| 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 "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 InterfaceRequest<ServiceProvider> request) | 17 InterfaceRequest<ServiceProvider> service_provider_request) |
| 18 : binding_(this, request.Pass()), fallback_service_provider_(nullptr) { | 18 : binding_(this, service_provider_request.Pass()), |
| 19 } | 19 fallback_service_provider_(nullptr) {} |
| 20 | 20 |
| 21 ServiceProviderImpl::~ServiceProviderImpl() { | 21 ServiceProviderImpl::~ServiceProviderImpl() {} |
| 22 } | |
| 23 | 22 |
| 24 void ServiceProviderImpl::Bind(InterfaceRequest<ServiceProvider> request) { | 23 void ServiceProviderImpl::Bind( |
| 25 binding_.Bind(request.Pass()); | 24 InterfaceRequest<ServiceProvider> service_provider_request) { |
| 25 binding_.Bind(service_provider_request.Pass()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ServiceProviderImpl::Close() { | 28 void ServiceProviderImpl::Close() { |
| 29 if (binding_.is_bound()) | 29 if (binding_.is_bound()) |
| 30 binding_.Close(); | 30 binding_.Close(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 void ServiceProviderImpl::ConnectToService( | 33 void ServiceProviderImpl::ConnectToService( |
| 34 const String& service_name, | 34 const String& service_name, |
| 35 ScopedMessagePipeHandle client_handle) { | 35 ScopedMessagePipeHandle client_handle) { |
| 36 // TODO(beng): perhaps take app connection thru ctor so that we can pass | 36 // TODO(beng): perhaps take app connection thru ctor so that we can pass |
| 37 // ApplicationConnection through? | 37 // ApplicationConnection through? |
| 38 bool service_found = service_connector_registry_.ConnectToService( | 38 bool service_found = service_connector_registry_.ConnectToService( |
| 39 nullptr, service_name, &client_handle); | 39 nullptr, service_name, &client_handle); |
| 40 if (!service_found && fallback_service_provider_) { | 40 if (!service_found && fallback_service_provider_) { |
| 41 fallback_service_provider_->ConnectToService(service_name, | 41 fallback_service_provider_->ConnectToService(service_name, |
| 42 client_handle.Pass()); | 42 client_handle.Pass()); |
| 43 } | 43 } |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace mojo | 46 } // namespace mojo |
| OLD | NEW |