| 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_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ | 5 #ifndef SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ |
| 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ | 6 #define SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/memory/weak_ptr.h" |
| 14 #include "mojo/public/cpp/system/message_pipe.h" | 15 #include "mojo/public/cpp/system/message_pipe.h" |
| 15 #include "services/service_manager/public/cpp/interface_factory.h" | 16 #include "services/service_manager/public/cpp/interface_factory.h" |
| 16 #include "services/service_manager/public/cpp/lib/callback_binder.h" | 17 #include "services/service_manager/public/cpp/lib/callback_binder.h" |
| 17 #include "services/service_manager/public/cpp/lib/interface_factory_binder.h" | 18 #include "services/service_manager/public/cpp/lib/interface_factory_binder.h" |
| 18 | 19 |
| 19 namespace service_manager { | 20 namespace service_manager { |
| 20 | 21 |
| 21 class Identity; | 22 class Identity; |
| 22 class InterfaceBinder; | 23 class InterfaceBinder; |
| 23 | 24 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 | 66 |
| 66 // Returns true if an InterfaceBinder is registered for |interface_name|. | 67 // Returns true if an InterfaceBinder is registered for |interface_name|. |
| 67 bool CanBindInterface(const std::string& interface_name) const; | 68 bool CanBindInterface(const std::string& interface_name) const; |
| 68 | 69 |
| 69 // Completes binding the request for |interface_name| on |interface_pipe|, by | 70 // Completes binding the request for |interface_name| on |interface_pipe|, by |
| 70 // invoking the corresponding InterfaceBinder. | 71 // invoking the corresponding InterfaceBinder. |
| 71 void BindInterface(const Identity& remote_identity, | 72 void BindInterface(const Identity& remote_identity, |
| 72 const std::string& interface_name, | 73 const std::string& interface_name, |
| 73 mojo::ScopedMessagePipeHandle interface_pipe); | 74 mojo::ScopedMessagePipeHandle interface_pipe); |
| 74 | 75 |
| 76 base::WeakPtr<BinderRegistry> GetWeakPtr(); |
| 77 |
| 75 private: | 78 private: |
| 76 using InterfaceNameToBinderMap = | 79 using InterfaceNameToBinderMap = |
| 77 std::map<std::string, std::unique_ptr<InterfaceBinder>>; | 80 std::map<std::string, std::unique_ptr<InterfaceBinder>>; |
| 78 | 81 |
| 79 // Adds |binder| to the internal map. | 82 // Adds |binder| to the internal map. |
| 80 void SetInterfaceBinder(const std::string& interface_name, | 83 void SetInterfaceBinder(const std::string& interface_name, |
| 81 std::unique_ptr<InterfaceBinder> binder); | 84 std::unique_ptr<InterfaceBinder> binder); |
| 82 | 85 |
| 83 InterfaceNameToBinderMap binders_; | 86 InterfaceNameToBinderMap binders_; |
| 84 | 87 |
| 88 base::WeakPtrFactory<BinderRegistry> weak_factory_; |
| 89 |
| 85 DISALLOW_COPY_AND_ASSIGN(BinderRegistry); | 90 DISALLOW_COPY_AND_ASSIGN(BinderRegistry); |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 | 93 |
| 89 } // namespace service_manager | 94 } // namespace service_manager |
| 90 | 95 |
| 91 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ | 96 #endif // SERVICES_SERVICE_MANAGER_PUBLIC_CPP_BINDER_REGISTRY_H_ |
| OLD | NEW |