OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ | 5 #ifndef SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ |
6 #define SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ | 6 #define SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 private: | 74 private: |
75 InterfaceRegistry* registry_; | 75 InterfaceRegistry* registry_; |
76 DISALLOW_COPY_AND_ASSIGN(TestApi); | 76 DISALLOW_COPY_AND_ASSIGN(TestApi); |
77 }; | 77 }; |
78 | 78 |
79 // Construct an InterfaceRegistry with no filtering rules applied. | 79 // Construct an InterfaceRegistry with no filtering rules applied. |
80 InterfaceRegistry(); | 80 InterfaceRegistry(); |
81 | 81 |
82 // Construct an InterfaceRegistry with filtering rules as specified in | 82 // Construct an InterfaceRegistry with filtering rules as specified in |
83 // |capability_request| applied. | 83 // |capability_request| applied. |
84 InterfaceRegistry(const Identity& remote_identity, | 84 InterfaceRegistry(const Identity& local_identity, |
| 85 const Identity& remote_identity, |
85 const CapabilityRequest& capability_request); | 86 const CapabilityRequest& capability_request); |
86 ~InterfaceRegistry() override; | 87 ~InterfaceRegistry() override; |
87 | 88 |
88 // Sets a default handler for incoming interface requests which are allowed by | 89 // Sets a default handler for incoming interface requests which are allowed by |
89 // capability filters but have no registered handler in this registry. | 90 // capability filters but have no registered handler in this registry. |
90 void set_default_binder(const Binder& binder) { default_binder_ = binder; } | 91 void set_default_binder(const Binder& binder) { default_binder_ = binder; } |
91 | 92 |
92 void Bind(mojom::InterfaceProviderRequest local_interfaces_request); | 93 void Bind(mojom::InterfaceProviderRequest local_interfaces_request); |
93 | 94 |
94 base::WeakPtr<InterfaceRegistry> GetWeakPtr(); | 95 base::WeakPtr<InterfaceRegistry> GetWeakPtr(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder, | 156 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder, |
156 const std::string& name); | 157 const std::string& name); |
157 | 158 |
158 // Returns true if |remote_identity_| is allowed to bind |interface_name|, | 159 // Returns true if |remote_identity_| is allowed to bind |interface_name|, |
159 // according to capability policy. | 160 // according to capability policy. |
160 bool CanBindRequestForInterface(const std::string& interface_name) const; | 161 bool CanBindRequestForInterface(const std::string& interface_name) const; |
161 | 162 |
162 mojom::InterfaceProviderRequest pending_request_; | 163 mojom::InterfaceProviderRequest pending_request_; |
163 | 164 |
164 mojo::Binding<mojom::InterfaceProvider> binding_; | 165 mojo::Binding<mojom::InterfaceProvider> binding_; |
| 166 const Identity local_identity_; |
165 const Identity remote_identity_; | 167 const Identity remote_identity_; |
166 const CapabilityRequest capability_request_; | 168 const CapabilityRequest capability_request_; |
167 const bool allow_all_interfaces_; | 169 const bool allow_all_interfaces_; |
168 | 170 |
169 NameToInterfaceBinderMap name_to_binder_; | 171 NameToInterfaceBinderMap name_to_binder_; |
170 Binder default_binder_; | 172 Binder default_binder_; |
171 | 173 |
172 bool is_paused_ = false; | 174 bool is_paused_ = false; |
173 | 175 |
174 // Pending interface requests which can accumulate if GetInterface() is called | 176 // Pending interface requests which can accumulate if GetInterface() is called |
175 // while binding is paused. | 177 // while binding is paused. |
176 std::queue<std::pair<std::string, mojo::ScopedMessagePipeHandle>> | 178 std::queue<std::pair<std::string, mojo::ScopedMessagePipeHandle>> |
177 pending_interface_requests_; | 179 pending_interface_requests_; |
178 | 180 |
179 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; | 181 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; |
180 | 182 |
181 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); | 183 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); |
182 }; | 184 }; |
183 | 185 |
184 } // namespace shell | 186 } // namespace shell |
185 | 187 |
186 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ | 188 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ |
OLD | NEW |