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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "mojo/public/cpp/application/service_provider_impl.h"
6
7 #include <utility>
8
9 namespace mojo {
10
11 ServiceProviderImpl::ServiceProviderImpl()
12 : binding_(this), fallback_service_provider_(nullptr) {
13 }
14
15 ServiceProviderImpl::ServiceProviderImpl(
16 const ConnectionContext& connection_context,
17 InterfaceRequest<ServiceProvider> service_provider_request)
18 : binding_(this), fallback_service_provider_(nullptr) {
19 if (service_provider_request.is_pending())
20 Bind(connection_context, service_provider_request.Pass());
21 }
22
23 ServiceProviderImpl::~ServiceProviderImpl() {}
24
25 void ServiceProviderImpl::Bind(
26 const ConnectionContext& connection_context,
27 InterfaceRequest<ServiceProvider> service_provider_request) {
28 connection_context_ = connection_context;
29 binding_.Bind(service_provider_request.Pass());
30 }
31
32 void ServiceProviderImpl::Close() {
33 if (binding_.is_bound()) {
34 binding_.Close();
35 connection_context_ = ConnectionContext();
36 }
37 }
38
39 void ServiceProviderImpl::AddServiceForName(
40 std::unique_ptr<ServiceConnector> service_connector,
41 const std::string& service_name) {
42 name_to_service_connector_[service_name] = std::move(service_connector);
43 }
44
45 void ServiceProviderImpl::RemoveServiceForName(
46 const std::string& service_name) {
47 auto it = name_to_service_connector_.find(service_name);
48 if (it != name_to_service_connector_.end())
49 name_to_service_connector_.erase(it);
50 }
51
52 void ServiceProviderImpl::ConnectToService(
53 const String& service_name,
54 ScopedMessagePipeHandle client_handle) {
55 auto it = name_to_service_connector_.find(service_name);
56 if (it != name_to_service_connector_.end()) {
57 it->second->ConnectToService(connection_context_, client_handle.Pass());
58 } else if (fallback_service_provider_) {
59 fallback_service_provider_->ConnectToService(service_name,
60 client_handle.Pass());
61 }
62 }
63
64 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/application/lib/run_application.cc ('k') | mojo/public/cpp/application/run_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698