| 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 | 9 |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, | 97 const base::Callback<void(mojo::ScopedMessagePipeHandle)>& callback, |
| 98 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = | 98 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner = |
| 99 nullptr); | 99 nullptr); |
| 100 | 100 |
| 101 template <typename Interface> | 101 template <typename Interface> |
| 102 void RemoveInterface() { | 102 void RemoveInterface() { |
| 103 RemoveInterface(Interface::Name_); | 103 RemoveInterface(Interface::Name_); |
| 104 } | 104 } |
| 105 void RemoveInterface(const std::string& name); | 105 void RemoveInterface(const std::string& name); |
| 106 | 106 |
| 107 // Temporarily prevent incoming interface requests from being bound. Incoming |
| 108 // requests will be queued internally and dispatched once UnpauseBinding() is |
| 109 // called. |
| 110 void PauseBinding(); |
| 111 |
| 112 // Resumes incoming interface request binding. |
| 113 void ResumeBinding(); |
| 114 |
| 107 private: | 115 private: |
| 108 using NameToInterfaceBinderMap = | 116 using NameToInterfaceBinderMap = |
| 109 std::map<std::string, std::unique_ptr<InterfaceBinder>>; | 117 std::map<std::string, std::unique_ptr<InterfaceBinder>>; |
| 110 | 118 |
| 111 // mojom::InterfaceProvider: | 119 // mojom::InterfaceProvider: |
| 112 void GetInterface(const mojo::String& interface_name, | 120 void GetInterface(const mojo::String& interface_name, |
| 113 mojo::ScopedMessagePipeHandle handle) override; | 121 mojo::ScopedMessagePipeHandle handle) override; |
| 114 | 122 |
| 115 // Returns true if the binder was set, false if it was not set (e.g. by | 123 // Returns true if the binder was set, false if it was not set (e.g. by |
| 116 // some filtering policy preventing this interface from being exposed). | 124 // some filtering policy preventing this interface from being exposed). |
| 117 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder, | 125 bool SetInterfaceBinderForName(std::unique_ptr<InterfaceBinder> binder, |
| 118 const std::string& name); | 126 const std::string& name); |
| 119 | 127 |
| 128 mojom::InterfaceProviderRequest pending_request_; |
| 129 |
| 120 mojo::Binding<mojom::InterfaceProvider> binding_; | 130 mojo::Binding<mojom::InterfaceProvider> binding_; |
| 121 Connection* connection_; | 131 Connection* connection_; |
| 122 | 132 |
| 123 NameToInterfaceBinderMap name_to_binder_; | 133 NameToInterfaceBinderMap name_to_binder_; |
| 124 | 134 |
| 125 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; | 135 base::WeakPtrFactory<InterfaceRegistry> weak_factory_; |
| 126 | 136 |
| 127 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); | 137 DISALLOW_COPY_AND_ASSIGN(InterfaceRegistry); |
| 128 }; | 138 }; |
| 129 | 139 |
| 130 } // namespace shell | 140 } // namespace shell |
| 131 | 141 |
| 132 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ | 142 #endif // SERVICES_SHELL_PUBLIC_CPP_INTERFACE_REGISTRY_H_ |
| OLD | NEW |