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

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

Issue 943053003: Simple multi-url support for mojo apps (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebase + fix android Created 5 years, 9 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/lib/service_registry.h" 5 #include "mojo/public/cpp/application/lib/service_registry.h"
6 6
7 #include "mojo/public/cpp/application/application_connection.h" 7 #include "mojo/public/cpp/application/application_connection.h"
8 #include "mojo/public/cpp/application/application_impl.h" 8 #include "mojo/public/cpp/application/application_impl.h"
9 #include "mojo/public/cpp/application/lib/service_connector.h" 9 #include "mojo/public/cpp/application/lib/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, 15 ApplicationImpl* application_impl,
16 const std::string& url, 16 const std::string& connection_url,
17 const std::string& remote_url,
17 ServiceProviderPtr remote_services, 18 ServiceProviderPtr remote_services,
18 InterfaceRequest<ServiceProvider> local_services) 19 InterfaceRequest<ServiceProvider> local_services)
19 : application_impl_(application_impl), 20 : application_impl_(application_impl),
20 url_(url), 21 connection_url_(connection_url),
22 remote_url_(remote_url),
21 local_binding_(this), 23 local_binding_(this),
22 remote_service_provider_(remote_services.Pass()) { 24 remote_service_provider_(remote_services.Pass()) {
23 if (local_services.is_pending()) 25 if (local_services.is_pending())
24 local_binding_.Bind(local_services.Pass()); 26 local_binding_.Bind(local_services.Pass());
25 } 27 }
26 28
27 ServiceRegistry::ServiceRegistry() 29 ServiceRegistry::ServiceRegistry()
28 : application_impl_(nullptr), local_binding_(this) { 30 : application_impl_(nullptr), local_binding_(this) {
29 } 31 }
30 32
(...skipping 25 matching lines...) Expand all
56 ServiceConnectorBase* service_connector) { 58 ServiceConnectorBase* service_connector) {
57 NameToServiceConnectorMap::iterator it = 59 NameToServiceConnectorMap::iterator it =
58 name_to_service_connector_.find(service_connector->name()); 60 name_to_service_connector_.find(service_connector->name());
59 if (it == name_to_service_connector_.end()) 61 if (it == name_to_service_connector_.end())
60 return false; 62 return false;
61 delete it->second; 63 delete it->second;
62 name_to_service_connector_.erase(it); 64 name_to_service_connector_.erase(it);
63 return true; 65 return true;
64 } 66 }
65 67
68 const std::string& ServiceRegistry::GetConnectionURL() {
69 return connection_url_;
70 }
71
66 const std::string& ServiceRegistry::GetRemoteApplicationURL() { 72 const std::string& ServiceRegistry::GetRemoteApplicationURL() {
67 return url_; 73 return remote_url_;
68 } 74 }
69 75
70 ServiceProvider* ServiceRegistry::GetServiceProvider() { 76 ServiceProvider* ServiceRegistry::GetServiceProvider() {
71 return remote_service_provider_.get(); 77 return remote_service_provider_.get();
72 } 78 }
73 79
74 void ServiceRegistry::ConnectToService(const mojo::String& service_name, 80 void ServiceRegistry::ConnectToService(const mojo::String& service_name,
75 ScopedMessagePipeHandle client_handle) { 81 ScopedMessagePipeHandle client_handle) {
76 if (name_to_service_connector_.find(service_name) == 82 if (name_to_service_connector_.find(service_name) ==
77 name_to_service_connector_.end()) { 83 name_to_service_connector_.end()) {
78 client_handle.reset(); 84 client_handle.reset();
79 return; 85 return;
80 } 86 }
81 internal::ServiceConnectorBase* service_connector = 87 internal::ServiceConnectorBase* service_connector =
82 name_to_service_connector_[service_name]; 88 name_to_service_connector_[service_name];
83 return service_connector->ConnectToService(service_name, 89 return service_connector->ConnectToService(service_name,
84 client_handle.Pass()); 90 client_handle.Pass());
85 } 91 }
86 92
87 } // namespace internal 93 } // namespace internal
88 } // namespace mojo 94 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698