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

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

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 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ 5 #ifndef MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ 6 #define MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
7 7
8 #include "mojo/public/cpp/application/application_connection.h" 8 #include "mojo/public/cpp/application/application_connection.h"
9 #include "mojo/public/interfaces/application/service_provider.mojom.h" 9 #include "mojo/public/interfaces/application/service_provider.mojom.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 12
13 class Application; 13 class Application;
14 class ApplicationImpl; 14 class ApplicationImpl;
15 15
16 namespace internal { 16 namespace internal {
17 17
18 class ServiceConnectorBase; 18 class ServiceConnectorBase;
19 19
20 // A ServiceRegistry represents each half of a connection between two 20 // A ServiceRegistry represents each half of a connection between two
21 // applications, allowing customization of which services are published to the 21 // applications, allowing customization of which services are published to the
22 // other. 22 // other.
23 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { 23 class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
24 public: 24 public:
25 ServiceRegistry(); 25 ServiceRegistry();
26 ServiceRegistry(ApplicationImpl* application_impl, 26 ServiceRegistry(ApplicationImpl* application_impl,
27 const std::string& url, 27 const std::string& connection_url,
28 const std::string& remote_url,
28 ServiceProviderPtr remote_services, 29 ServiceProviderPtr remote_services,
29 InterfaceRequest<ServiceProvider> local_services); 30 InterfaceRequest<ServiceProvider> local_services);
30 ~ServiceRegistry() override; 31 ~ServiceRegistry() override;
31 32
32 // ApplicationConnection overrides. 33 // ApplicationConnection overrides.
33 void AddServiceConnector(ServiceConnectorBase* service_connector) override; 34 void AddServiceConnector(ServiceConnectorBase* service_connector) override;
35 const std::string& GetConnectionURL() override;
34 const std::string& GetRemoteApplicationURL() override; 36 const std::string& GetRemoteApplicationURL() override;
35 ServiceProvider* GetServiceProvider() override; 37 ServiceProvider* GetServiceProvider() override;
36 38
37 virtual void RemoveServiceConnector(ServiceConnectorBase* service_connector); 39 virtual void RemoveServiceConnector(ServiceConnectorBase* service_connector);
38 40
39 private: 41 private:
40 // ServiceProvider method. 42 // ServiceProvider method.
41 void ConnectToService(const mojo::String& service_name, 43 void ConnectToService(const mojo::String& service_name,
42 ScopedMessagePipeHandle client_handle) override; 44 ScopedMessagePipeHandle client_handle) override;
43 45
44 ApplicationImpl* application_impl_; 46 ApplicationImpl* application_impl_;
45 const std::string url_; 47 const std::string connection_url_;
48 const std::string remote_url_;
46 49
47 private: 50 private:
48 bool RemoveServiceConnectorInternal(ServiceConnectorBase* service_connector); 51 bool RemoveServiceConnectorInternal(ServiceConnectorBase* service_connector);
49 52
50 Application* application_; 53 Application* application_;
51 typedef std::map<std::string, ServiceConnectorBase*> 54 typedef std::map<std::string, ServiceConnectorBase*>
52 NameToServiceConnectorMap; 55 NameToServiceConnectorMap;
53 NameToServiceConnectorMap name_to_service_connector_; 56 NameToServiceConnectorMap name_to_service_connector_;
54 Binding<ServiceProvider> local_binding_; 57 Binding<ServiceProvider> local_binding_;
55 ServiceProviderPtr remote_service_provider_; 58 ServiceProviderPtr remote_service_provider_;
56 59
57 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); 60 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
58 }; 61 };
59 62
60 } // namespace internal 63 } // namespace internal
61 } // namespace mojo 64 } // namespace mojo
62 65
63 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_ 66 #endif // MOJO_PUBLIC_CPP_APPLICATION_LIB_SERVICE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698