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

Side by Side Diff: services/service_manager/public/cpp/interface_registry.h

Issue 2478653003: Clean up dead InterfaceRegistry instances in ServiceContext (Closed)
Patch Set: . Created 4 years, 1 month 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 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_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_ 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_
6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_ 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_
7 7
8 #include <list>
8 #include <memory> 9 #include <memory>
9 #include <queue> 10 #include <queue>
10 #include <set> 11 #include <set>
11 #include <utility> 12 #include <utility>
12 13
13 #include "base/callback.h" 14 #include "base/callback.h"
14 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
15 #include "mojo/public/cpp/bindings/binding.h" 16 #include "mojo/public/cpp/bindings/binding.h"
16 #include "services/service_manager/public/cpp/identity.h" 17 #include "services/service_manager/public/cpp/identity.h"
17 #include "services/service_manager/public/cpp/interface_provider_spec.h" 18 #include "services/service_manager/public/cpp/interface_provider_spec.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // called. 144 // called.
144 void PauseBinding(); 145 void PauseBinding();
145 146
146 // Resumes incoming interface request binding. 147 // Resumes incoming interface request binding.
147 void ResumeBinding(); 148 void ResumeBinding();
148 149
149 // Populates a set with the interface names this registry can bind. 150 // Populates a set with the interface names this registry can bind.
150 void GetInterfaceNames(std::set<std::string>* interface_names); 151 void GetInterfaceNames(std::set<std::string>* interface_names);
151 152
152 // Sets a closure to be run when the InterfaceProvider pipe is closed. 153 // Sets a closure to be run when the InterfaceProvider pipe is closed.
153 void SetConnectionLostClosure(const base::Closure& connection_lost_closure); 154 void AddConnectionLostClosure(const base::Closure& connection_lost_closure);
154 155
155 private: 156 private:
156 using InterfaceNameToBinderMap = 157 using InterfaceNameToBinderMap =
157 std::map<std::string, std::unique_ptr<InterfaceBinder>>; 158 std::map<std::string, std::unique_ptr<InterfaceBinder>>;
158 159
159 // mojom::InterfaceProvider: 160 // mojom::InterfaceProvider:
160 void GetInterface(const std::string& interface_name, 161 void GetInterface(const std::string& interface_name,
161 mojo::ScopedMessagePipeHandle handle) override; 162 mojo::ScopedMessagePipeHandle handle) override;
162 163
163 // Returns true if the binder was set, false if it was not set (e.g. by 164 // Returns true if the binder was set, false if it was not set (e.g. by
164 // some filtering policy preventing this interface from being exposed). 165 // some filtering policy preventing this interface from being exposed).
165 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder, 166 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder,
166 const std::string& name); 167 const std::string& name);
167 168
168 // Returns true if |remote_identity_| is allowed to bind |interface_name|, 169 // Returns true if |remote_identity_| is allowed to bind |interface_name|,
169 // according to capability policy. 170 // according to capability policy.
170 bool CanBindRequestForInterface(const std::string& interface_name) const; 171 bool CanBindRequestForInterface(const std::string& interface_name) const;
171 172
172 // Called whenever |remote_interface_provider_spec_| changes to rebuild the 173 // Called whenever |remote_interface_provider_spec_| changes to rebuild the
173 // contents of |exposed_interfaces_| and |expose_all_interfaces_|. 174 // contents of |exposed_interfaces_| and |expose_all_interfaces_|.
174 void RebuildExposedInterfaces(); 175 void RebuildExposedInterfaces();
175 176
177 void OnConnectionError();
178
176 mojom::InterfaceProviderRequest pending_request_; 179 mojom::InterfaceProviderRequest pending_request_;
177 180
178 mojo::Binding<mojom::InterfaceProvider> binding_; 181 mojo::Binding<mojom::InterfaceProvider> binding_;
179 182
180 std::string name_; 183 std::string name_;
181 184
182 // Initialized from static metadata in the host service's manifest. 185 // Initialized from static metadata in the host service's manifest.
183 Identity local_identity_; 186 Identity local_identity_;
184 InterfaceProviderSpec local_interface_provider_spec_; 187 InterfaceProviderSpec local_interface_provider_spec_;
185 188
(...skipping 16 matching lines...) Expand all
202 InterfaceNameToBinderMap name_to_binder_; 205 InterfaceNameToBinderMap name_to_binder_;
203 Binder default_binder_; 206 Binder default_binder_;
204 207
205 bool is_paused_ = false; 208 bool is_paused_ = false;
206 209
207 // Pending interface requests which can accumulate if GetInterface() is called 210 // Pending interface requests which can accumulate if GetInterface() is called
208 // while binding is paused. 211 // while binding is paused.
209 std::queue<std::pair<std::string, mojo::ScopedMessagePipeHandle>> 212 std::queue<std::pair<std::string, mojo::ScopedMessagePipeHandle>>
210 pending_interface_requests_; 213 pending_interface_requests_;
211 214
215 std::list<base::Closure> connection_lost_closures_;
216
212 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; 217 base::WeakPtrFactory<InterfaceRegistry> weak_factory_;
213 218
214 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); 219 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry);
215 }; 220 };
216 221
217 } // namespace service_manager 222 } // namespace service_manager
218 223
219 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_ 224 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_INTERFACE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698