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

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

Issue 1678923003: Rename ServiceConnector to InterfaceBinder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@connection
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
« no previous file with comments | « mojo/shell/public/cpp/interface_binder.h ('k') | mojo/shell/public/cpp/lib/connection_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_CONNECTION_IMPL_H_ 5 #ifndef MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
6 #define MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ 6 #define MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 10 matching lines...) Expand all
21 // A ConnectionImpl represents each half of a connection between two 21 // A ConnectionImpl represents each half of a connection between two
22 // applications, allowing customization of which services are published to the 22 // applications, allowing customization of which services are published to the
23 // other. 23 // other.
24 class ConnectionImpl : public Connection, public ServiceProvider { 24 class ConnectionImpl : public Connection, public ServiceProvider {
25 public: 25 public:
26 class TestApi { 26 class TestApi {
27 public: 27 public:
28 explicit TestApi(ConnectionImpl* impl) : impl_(impl) {} 28 explicit TestApi(ConnectionImpl* impl) : impl_(impl) {}
29 ~TestApi() {} 29 ~TestApi() {}
30 30
31 void SetServiceConnectorForName(ServiceConnector* connector, 31 void SetInterfaceBinderForName(InterfaceBinder* binder,
32 const std::string& interface_name) { 32 const std::string& interface_name) {
33 impl_->SetServiceConnectorForName(connector, interface_name); 33 impl_->SetInterfaceBinderForName(binder, interface_name);
34 } 34 }
35 void RemoveServiceConnectorForName(const std::string& interface_name) { 35 void RemoveInterfaceBinderForName(const std::string& interface_name) {
36 impl_->RemoveServiceConnectorForName(interface_name); 36 impl_->RemoveInterfaceBinderForName(interface_name);
37 } 37 }
38 38
39 private: 39 private:
40 ConnectionImpl* impl_; 40 ConnectionImpl* impl_;
41 DISALLOW_COPY_AND_ASSIGN(TestApi); 41 DISALLOW_COPY_AND_ASSIGN(TestApi);
42 }; 42 };
43 43
44 ConnectionImpl(); 44 ConnectionImpl();
45 // |allowed_interfaces| are the set of interfaces that the shell has allowed 45 // |allowed_interfaces| are the set of interfaces that the shell has allowed
46 // an application to expose to another application. If this set contains only 46 // an application to expose to another application. If this set contains only
47 // the string value "*" all interfaces may be exposed. 47 // the string value "*" all interfaces may be exposed.
48 ConnectionImpl(const std::string& connection_url, 48 ConnectionImpl(const std::string& connection_url,
49 const std::string& remote_url, 49 const std::string& remote_url,
50 uint32_t remote_id, 50 uint32_t remote_id,
51 ServiceProviderPtr remote_services, 51 ServiceProviderPtr remote_services,
52 InterfaceRequest<ServiceProvider> local_services, 52 InterfaceRequest<ServiceProvider> local_services,
53 const std::set<std::string>& allowed_interfaces); 53 const std::set<std::string>& allowed_interfaces);
54 ~ConnectionImpl() override; 54 ~ConnectionImpl() override;
55 55
56 shell::mojom::Shell::ConnectToApplicationCallback 56 shell::mojom::Shell::ConnectToApplicationCallback
57 GetConnectToApplicationCallback(); 57 GetConnectToApplicationCallback();
58 58
59 private: 59 private:
60 using NameToServiceConnectorMap = std::map<std::string, ServiceConnector*>; 60 using NameToInterfaceBinderMap = std::map<std::string, InterfaceBinder*>;
61 61
62 // Connection overrides. 62 // Connection overrides.
63 void SetServiceConnector(ServiceConnector* service_connector) override; 63 void SetDefaultInterfaceBinder(InterfaceBinder* binder) override;
64 bool SetServiceConnectorForName(ServiceConnector* service_connector, 64 bool SetInterfaceBinderForName(InterfaceBinder* binder,
65 const std::string& interface_name) override; 65 const std::string& interface_name) override;
66 const std::string& GetConnectionURL() override; 66 const std::string& GetConnectionURL() override;
67 const std::string& GetRemoteApplicationURL() override; 67 const std::string& GetRemoteApplicationURL() override;
68 ServiceProvider* GetServiceProvider() override; 68 ServiceProvider* GetServiceProvider() override;
69 ServiceProvider* GetLocalServiceProvider() override; 69 ServiceProvider* GetLocalServiceProvider() override;
70 void SetRemoteServiceProviderConnectionErrorHandler( 70 void SetRemoteServiceProviderConnectionErrorHandler(
71 const Closure& handler) override; 71 const Closure& handler) override;
72 bool GetRemoteApplicationID(uint32_t* remote_id) const override; 72 bool GetRemoteApplicationID(uint32_t* remote_id) const override;
73 bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override; 73 bool GetRemoteContentHandlerID(uint32_t* content_handler_id) const override;
74 void AddRemoteIDCallback(const Closure& callback) override; 74 void AddRemoteIDCallback(const Closure& callback) override;
75 base::WeakPtr<Connection> GetWeakPtr() override; 75 base::WeakPtr<Connection> GetWeakPtr() override;
76 76
77 // ServiceProvider method. 77 // ServiceProvider method.
78 void ConnectToService(const mojo::String& service_name, 78 void ConnectToService(const mojo::String& service_name,
79 ScopedMessagePipeHandle client_handle) override; 79 ScopedMessagePipeHandle handle) override;
80 80
81 void RemoveServiceConnectorForName(const std::string& interface_name); 81 void RemoveInterfaceBinderForName(const std::string& interface_name);
82 void OnGotRemoteIDs(uint32_t target_application_id, 82 void OnGotRemoteIDs(uint32_t target_application_id,
83 uint32_t content_handler_id); 83 uint32_t content_handler_id);
84 84
85 const std::string connection_url_; 85 const std::string connection_url_;
86 const std::string remote_url_; 86 const std::string remote_url_;
87 87
88 uint32_t remote_id_; 88 uint32_t remote_id_;
89 // The id of the content_handler is only available once the callback from 89 // The id of the content_handler is only available once the callback from
90 // establishing the connection is made. 90 // establishing the connection is made.
91 uint32_t content_handler_id_; 91 uint32_t content_handler_id_;
92 bool remote_ids_valid_; 92 bool remote_ids_valid_;
93 std::vector<Closure> remote_id_callbacks_; 93 std::vector<Closure> remote_id_callbacks_;
94 94
95 Binding<ServiceProvider> local_binding_; 95 Binding<ServiceProvider> local_binding_;
96 ServiceProviderPtr remote_service_provider_; 96 ServiceProviderPtr remote_service_provider_;
97 97
98 const std::set<std::string> allowed_interfaces_; 98 const std::set<std::string> allowed_interfaces_;
99 const bool allow_all_interfaces_; 99 const bool allow_all_interfaces_;
100 100
101 ServiceConnector* default_connector_; 101 InterfaceBinder* default_binder_;
102 NameToServiceConnectorMap name_to_service_connector_; 102 NameToInterfaceBinderMap name_to_binder_;
103 103
104 base::WeakPtrFactory<ConnectionImpl> weak_factory_; 104 base::WeakPtrFactory<ConnectionImpl> weak_factory_;
105 105
106 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionImpl); 106 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionImpl);
107 }; 107 };
108 108
109 } // namespace internal 109 } // namespace internal
110 } // namespace mojo 110 } // namespace mojo
111 111
112 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_ 112 #endif // MOJO_SHELL_PUBLIC_CPP_LIB_CONNECTION_IMPL_H_
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/interface_binder.h ('k') | mojo/shell/public/cpp/lib/connection_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698