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/application/public/cpp/lib/service_registry.h" | 5 #include "mojo/application/public/cpp/lib/service_registry.h" |
6 | 6 |
7 #include "base/logging.h" | |
7 #include "mojo/application/public/cpp/application_connection.h" | 8 #include "mojo/application/public/cpp/application_connection.h" |
8 #include "mojo/application/public/cpp/application_impl.h" | |
9 #include "mojo/application/public/cpp/service_connector.h" | 9 #include "mojo/application/public/cpp/service_connector.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 namespace internal { | 12 namespace internal { |
13 | 13 |
14 ServiceRegistry::ServiceRegistry( | 14 ServiceRegistry::ServiceRegistry( |
15 ApplicationImpl* application_impl, | |
16 const std::string& connection_url, | 15 const std::string& connection_url, |
17 const std::string& remote_url, | 16 const std::string& remote_url, |
18 ServiceProviderPtr remote_services, | 17 ServiceProviderPtr remote_services, |
19 InterfaceRequest<ServiceProvider> local_services, | 18 InterfaceRequest<ServiceProvider> local_services, |
20 const std::set<std::string>& allowed_interfaces) | 19 const std::set<std::string>& allowed_interfaces) |
21 : application_impl_(application_impl), | 20 : connection_url_(connection_url), |
22 connection_url_(connection_url), | |
23 remote_url_(remote_url), | 21 remote_url_(remote_url), |
24 local_binding_(this), | 22 local_binding_(this), |
25 remote_service_provider_(remote_services.Pass()), | 23 remote_service_provider_(remote_services.Pass()), |
26 allowed_interfaces_(allowed_interfaces), | 24 allowed_interfaces_(allowed_interfaces), |
27 allow_all_interfaces_(allowed_interfaces_.size() == 1 && | 25 allow_all_interfaces_(allowed_interfaces_.size() == 1 && |
28 allowed_interfaces_.count("*") == 1) { | 26 allowed_interfaces_.count("*") == 1) { |
29 if (local_services.is_pending()) | 27 if (local_services.is_pending()) |
30 local_binding_.Bind(local_services.Pass()); | 28 local_binding_.Bind(local_services.Pass()); |
31 } | 29 } |
32 | 30 |
33 ServiceRegistry::ServiceRegistry() | 31 ServiceRegistry::ServiceRegistry() |
34 : application_impl_(nullptr), | 32 : local_binding_(this), |
35 local_binding_(this), | |
36 allow_all_interfaces_(true) { | 33 allow_all_interfaces_(true) { |
37 } | 34 } |
38 | 35 |
39 void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) { | 36 void ServiceRegistry::SetServiceConnector(ServiceConnector* connector) { |
40 service_connector_registry_.set_service_connector(connector); | 37 service_connector_registry_.set_service_connector(connector); |
41 } | 38 } |
42 | 39 |
43 bool ServiceRegistry::SetServiceConnectorForName( | 40 bool ServiceRegistry::SetServiceConnectorForName( |
44 ServiceConnector* service_connector, | 41 ServiceConnector* service_connector, |
45 const std::string& interface_name) { | 42 const std::string& interface_name) { |
(...skipping 29 matching lines...) Expand all Loading... | |
75 } | 72 } |
76 | 73 |
77 const std::string& ServiceRegistry::GetRemoteApplicationURL() { | 74 const std::string& ServiceRegistry::GetRemoteApplicationURL() { |
78 return remote_url_; | 75 return remote_url_; |
79 } | 76 } |
80 | 77 |
81 ServiceProvider* ServiceRegistry::GetServiceProvider() { | 78 ServiceProvider* ServiceRegistry::GetServiceProvider() { |
82 return remote_service_provider_.get(); | 79 return remote_service_provider_.get(); |
83 } | 80 } |
84 | 81 |
85 ServiceRegistry::~ServiceRegistry() { | 82 ServiceRegistry::~ServiceRegistry() { |
sky
2015/08/11 18:28:04
Move to match new position in header.
| |
86 } | 83 } |
87 | 84 |
88 void ServiceRegistry::OnCloseConnection() { | |
89 if (application_impl_) | |
90 application_impl_->CloseConnection(this); | |
91 } | |
92 | |
93 void ServiceRegistry::ConnectToService(const mojo::String& service_name, | 85 void ServiceRegistry::ConnectToService(const mojo::String& service_name, |
94 ScopedMessagePipeHandle client_handle) { | 86 ScopedMessagePipeHandle client_handle) { |
95 service_connector_registry_.ConnectToService(this, service_name, | 87 service_connector_registry_.ConnectToService(this, service_name, |
96 client_handle.Pass()); | 88 client_handle.Pass()); |
97 } | 89 } |
98 | 90 |
99 } // namespace internal | 91 } // namespace internal |
100 } // namespace mojo | 92 } // namespace mojo |
OLD | NEW |