| 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 void Bind(mojom::InterfaceProviderRequest local_interfaces_request); | 82 void Bind(mojom::InterfaceProviderRequest local_interfaces_request); |
| 83 | 83 |
| 84 base::WeakPtr<InterfaceRegistry> GetWeakPtr(); | 84 base::WeakPtr<InterfaceRegistry> GetWeakPtr(); |
| 85 | 85 |
| 86 // Allows |Interface| to be exposed via this registry. Requests to bind will | 86 // Allows |Interface| to be exposed via this registry. Requests to bind will |
| 87 // be handled by |factory|. Returns true if the interface was exposed, false | 87 // be handled by |factory|. Returns true if the interface was exposed, false |
| 88 // if Connection policy prevented exposure. | 88 // if Connection policy prevented exposure. |
| 89 template <typename Interface> | 89 template <typename Interface> |
| 90 bool AddInterface(InterfaceFactory<Interface>* factory) { | 90 bool AddInterface(InterfaceFactory<Interface>* factory) { |
| 91 return SetInterfaceBinderForName( | 91 return SetInterfaceBinderForName( |
| 92 base::WrapUnique( | 92 base::MakeUnique<internal::InterfaceFactoryBinder<Interface>>(factory), |
| 93 new internal::InterfaceFactoryBinder<Interface>(factory)), | |
| 94 Interface::Name_); | 93 Interface::Name_); |
| 95 } | 94 } |
| 96 | 95 |
| 97 // Like AddInterface above, except supplies a callback to bind the MP instead | 96 // Like AddInterface above, except supplies a callback to bind the MP instead |
| 98 // of an InterfaceFactory, and optionally provides a task runner where the | 97 // of an InterfaceFactory, and optionally provides a task runner where the |
| 99 // callback will be run. | 98 // callback will be run. |
| 100 template <typename Interface> | 99 template <typename Interface> |
| 101 bool AddInterface( | 100 bool AddInterface( |
| 102 const base::Callback<void(mojo::InterfaceRequest<Interface>)>& callback, | 101 const base::Callback<void(mojo::InterfaceRequest<Interface>)>& callback, |
| 103 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = | 102 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = |
| 104 nullptr) { | 103 nullptr) { |
| 105 return SetInterfaceBinderForName( | 104 return SetInterfaceBinderForName( |
| 106 base::WrapUnique( | 105 base::MakeUnique<internal::CallbackBinder<Interface>>(callback, |
| 107 new internal::CallbackBinder<Interface>(callback, task_runner)), | 106 task_runner), |
| 108 Interface::Name_); | 107 Interface::Name_); |
| 109 } | 108 } |
| 110 bool AddInterface( | 109 bool AddInterface( |
| 111 const std::string& name, | 110 const std::string& name, |
| 112 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, | 111 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, |
| 113 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = | 112 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = |
| 114 nullptr); | 113 nullptr); |
| 115 | 114 |
| 116 template <typename Interface> | 115 template <typename Interface> |
| 117 void RemoveInterface() { | 116 void RemoveInterface() { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 pending_interface_requests_; | 167 pending_interface_requests_; |
| 169 | 168 |
| 170 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; | 169 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; |
| 171 | 170 |
| 172 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); | 171 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); |
| 173 }; | 172 }; |
| 174 | 173 |
| 175 } // namespace shell | 174 } // namespace shell |
| 176 | 175 |
| 177 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ | 176 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ |
| OLD | NEW |