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

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

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

Powered by Google App Engine
This is Rietveld 408576698