Chromium Code Reviews| Index: mojo/public/cpp/application/lib/service_registry.cc |
| diff --git a/mojo/public/cpp/application/lib/application.cc b/mojo/public/cpp/application/lib/service_registry.cc |
| similarity index 52% |
| copy from mojo/public/cpp/application/lib/application.cc |
| copy to mojo/public/cpp/application/lib/service_registry.cc |
| index fb2a897a906f2f1335a95d2db6c3594c56d48f7f..0295ac4513320890a9a03a95b0c07f55ff699a8f 100644 |
| --- a/mojo/public/cpp/application/lib/application.cc |
| +++ b/mojo/public/cpp/application/lib/service_registry.cc |
| @@ -2,22 +2,27 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include "mojo/public/cpp/application/lib/service_registry.h" |
| + |
| #include "mojo/public/cpp/application/application.h" |
| +#include "mojo/public/cpp/application/lib/service_connector.h" |
| namespace mojo { |
| +namespace internal { |
| -Application::Application() {} |
| - |
| -Application::Application(ScopedMessagePipeHandle service_provider_handle) |
| - : internal::ServiceConnectorBase::Owner(service_provider_handle.Pass()) { |
| +ServiceRegistry::ServiceRegistry(Application* application) |
| + : application_(application) { |
| } |
| -Application::Application(MojoHandle service_provider_handle) |
| - : internal::ServiceConnectorBase::Owner( |
| - mojo::MakeScopedHandle( |
| - MessagePipeHandle(service_provider_handle)).Pass()) {} |
| +ServiceRegistry::ServiceRegistry( |
| + Application* application, |
| + ScopedMessagePipeHandle service_provider_handle) |
| + : application_(application) { |
| + service_provider_.Bind(service_provider_handle.Pass()); |
| + service_provider_.set_client(this); |
| +} |
| -Application::~Application() { |
| +ServiceRegistry::~ServiceRegistry() { |
| for (NameToServiceConnectorMap::iterator i = |
| name_to_service_connector_.begin(); |
| i != name_to_service_connector_.end(); ++i) { |
| @@ -26,16 +31,14 @@ Application::~Application() { |
| name_to_service_connector_.clear(); |
| } |
| -void Application::Initialize() {} |
| - |
| -void Application::AddServiceConnector( |
| - internal::ServiceConnectorBase* service_connector) { |
| +void ServiceRegistry::AddServiceConnector( |
| + ServiceConnectorBase* service_connector) { |
| name_to_service_connector_[service_connector->name()] = service_connector; |
| - set_service_connector_owner(service_connector, this); |
| + service_connector->set_registry(this); |
| } |
| -void Application::RemoveServiceConnector( |
| - internal::ServiceConnectorBase* service_connector) { |
| +void ServiceRegistry::RemoveServiceConnector( |
| + ServiceConnectorBase* service_connector) { |
| NameToServiceConnectorMap::iterator it = |
| name_to_service_connector_.find(service_connector->name()); |
| assert(it != name_to_service_connector_.end()); |
| @@ -45,16 +48,21 @@ void Application::RemoveServiceConnector( |
| service_provider_.reset(); |
| } |
| -void Application::BindServiceProvider( |
| +void ServiceRegistry::BindServiceProvider( |
| ScopedMessagePipeHandle service_provider_handle) { |
| service_provider_.Bind(service_provider_handle.Pass()); |
| service_provider_.set_client(this); |
| } |
| -void Application::ConnectToService(const mojo::String& service_url, |
| - const mojo::String& service_name, |
| - ScopedMessagePipeHandle client_handle, |
| - const mojo::String& requestor_url) { |
| +void ServiceRegistry::ConnectToService(const mojo::String& service_url, |
| + const mojo::String& service_name, |
| + ScopedMessagePipeHandle client_handle, |
| + const mojo::String& requestor_url) { |
| + if (!application_->IsConnectionValid(service_name, requestor_url)) { |
|
darin (slow to review)
2014/06/12 16:11:51
I see... I think this method should be renamed. It
DaveMoore
2014/06/12 16:28:14
Done.
|
| + client_handle.reset(); |
| + return; |
| + } |
| + |
| internal::ServiceConnectorBase* service_connector = |
| name_to_service_connector_[service_name]; |
| assert(service_connector); |
| @@ -64,4 +72,5 @@ void Application::ConnectToService(const mojo::String& service_url, |
| service_url, service_name, client_handle.Pass()); |
| } |
| +} // namespace internal |
| } // namespace mojo |