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

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

Issue 1578473002: Pass application ids via AcceptConnection & ConnectToApplication callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 10 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_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 12 matching lines...) Expand all
23 // applications, allowing customization of which services are published to the 23 // applications, allowing customization of which services are published to the
24 // other. 24 // other.
25 class ServiceRegistry : public ServiceProvider, public ApplicationConnection { 25 class ServiceRegistry : public ServiceProvider, public ApplicationConnection {
26 public: 26 public:
27 ServiceRegistry(); 27 ServiceRegistry();
28 // |allowed_interfaces| are the set of interfaces that the shell has allowed 28 // |allowed_interfaces| are the set of interfaces that the shell has allowed
29 // an application to expose to another application. If this set contains only 29 // an application to expose to another application. If this set contains only
30 // the string value "*" all interfaces may be exposed. 30 // the string value "*" all interfaces may be exposed.
31 ServiceRegistry(const std::string& connection_url, 31 ServiceRegistry(const std::string& connection_url,
32 const std::string& remote_url, 32 const std::string& remote_url,
33 uint32_t remote_id,
33 ServiceProviderPtr remote_services, 34 ServiceProviderPtr remote_services,
34 InterfaceRequest<ServiceProvider> local_services, 35 InterfaceRequest<ServiceProvider> local_services,
35 const std::set<std::string>& allowed_interfaces); 36 const std::set<std::string>& allowed_interfaces);
36 ~ServiceRegistry() override; 37 ~ServiceRegistry() override;
37 38
38 Shell::ConnectToApplicationCallback GetConnectToApplicationCallback(); 39 Shell::ConnectToApplicationCallback GetConnectToApplicationCallback();
39 40
40 // ApplicationConnection overrides. 41 // ApplicationConnection overrides.
41 void SetServiceConnector(ServiceConnector* service_connector) override; 42 void SetServiceConnector(ServiceConnector* service_connector) override;
42 bool SetServiceConnectorForName(ServiceConnector* service_connector, 43 bool SetServiceConnectorForName(ServiceConnector* service_connector,
43 const std::string& interface_name) override; 44 const std::string& interface_name) override;
44 const std::string& GetConnectionURL() override; 45 const std::string& GetConnectionURL() override;
45 const std::string& GetRemoteApplicationURL() override; 46 const std::string& GetRemoteApplicationURL() override;
46 ServiceProvider* GetServiceProvider() override; 47 ServiceProvider* GetServiceProvider() override;
47 ServiceProvider* GetLocalServiceProvider() override; 48 ServiceProvider* GetLocalServiceProvider() override;
48 void SetRemoteServiceProviderConnectionErrorHandler( 49 void SetRemoteServiceProviderConnectionErrorHandler(
49 const Closure& handler) override; 50 const Closure& handler) override;
50 bool GetContentHandlerID(uint32_t* target_id) override; 51 bool GetRemoteApplicationID(uint32_t* remote_id) const override;
51 void AddContentHandlerIDCallback(const Closure& callback) override; 52 bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override;
53 void AddRemoteIDCallback(const Closure& callback) override;
52 base::WeakPtr<ApplicationConnection> GetWeakPtr() override; 54 base::WeakPtr<ApplicationConnection> GetWeakPtr() override;
53 55
54 void RemoveServiceConnectorForName(const std::string& interface_name); 56 void RemoveServiceConnectorForName(const std::string& interface_name);
55 57
56 private: 58 private:
57 void OnGotContentHandlerID(uint32_t content_handler_id); 59 void OnGotRemoteIDs(uint32_t target_application_id,
60 uint32_t content_handler_id);
58 61
59 // ServiceProvider method. 62 // ServiceProvider method.
60 void ConnectToService(const mojo::String& service_name, 63 void ConnectToService(const mojo::String& service_name,
61 ScopedMessagePipeHandle client_handle) override; 64 ScopedMessagePipeHandle client_handle) override;
62 65
63 const std::string connection_url_; 66 const std::string connection_url_;
64 const std::string remote_url_; 67 const std::string remote_url_;
65 Binding<ServiceProvider> local_binding_; 68 Binding<ServiceProvider> local_binding_;
66 ServiceProviderPtr remote_service_provider_; 69 ServiceProviderPtr remote_service_provider_;
67 ServiceConnectorRegistry service_connector_registry_; 70 ServiceConnectorRegistry service_connector_registry_;
68 const std::set<std::string> allowed_interfaces_; 71 const std::set<std::string> allowed_interfaces_;
69 const bool allow_all_interfaces_; 72 const bool allow_all_interfaces_;
73 uint32_t remote_id_;
70 // The id of the content_handler is only available once the callback from 74 // The id of the content_handler is only available once the callback from
71 // establishing the connection is made. 75 // establishing the connection is made.
72 uint32_t content_handler_id_; 76 uint32_t content_handler_id_;
73 bool is_content_handler_id_valid_; 77 bool remote_ids_valid_;
74 std::vector<Closure> content_handler_id_callbacks_; 78 std::vector<Closure> remote_id_callbacks_;
75 base::WeakPtrFactory<ServiceRegistry> weak_factory_; 79 base::WeakPtrFactory<ServiceRegistry> weak_factory_;
76 80
77 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry); 81 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceRegistry);
78 }; 82 };
79 83
80 } // namespace internal 84 } // namespace internal
81 } // namespace mojo 85 } // namespace mojo
82 86
83 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_ 87 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_SERVICE_REGISTRY_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/application_test_base.cc ('k') | mojo/shell/public/cpp/lib/service_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698