| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 5 #ifndef CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| 6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 6 #define CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 public: | 25 public: |
| 26 using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>; | 26 using ServiceFactory = base::Callback<void(mojo::ScopedMessagePipeHandle)>; |
| 27 | 27 |
| 28 ServiceRegistryImpl(); | 28 ServiceRegistryImpl(); |
| 29 ~ServiceRegistryImpl() override; | 29 ~ServiceRegistryImpl() override; |
| 30 | 30 |
| 31 // ServiceRegistry overrides. | 31 // ServiceRegistry overrides. |
| 32 void Bind(shell::mojom::InterfaceProviderRequest request) override; | 32 void Bind(shell::mojom::InterfaceProviderRequest request) override; |
| 33 void BindRemoteServiceProvider( | 33 void BindRemoteServiceProvider( |
| 34 shell::mojom::InterfaceProviderPtr service_provider) override; | 34 shell::mojom::InterfaceProviderPtr service_provider) override; |
| 35 void AddService(const std::string& service_name, | 35 void AddService( |
| 36 const ServiceFactory& service_factory) override; | 36 const std::string& service_name, |
| 37 const ServiceFactory& service_factory, |
| 38 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner) override; |
| 37 void RemoveService(const std::string& service_name) override; | 39 void RemoveService(const std::string& service_name) override; |
| 38 void ConnectToRemoteService(base::StringPiece service_name, | 40 void ConnectToRemoteService(base::StringPiece service_name, |
| 39 mojo::ScopedMessagePipeHandle handle) override; | 41 mojo::ScopedMessagePipeHandle handle) override; |
| 40 void AddServiceOverrideForTesting( | 42 void AddServiceOverrideForTesting( |
| 41 const std::string& service_name, | 43 const std::string& service_name, |
| 42 const ServiceFactory& service_factory) override; | 44 const ServiceFactory& service_factory) override; |
| 43 void ClearServiceOverridesForTesting() override; | 45 void ClearServiceOverridesForTesting() override; |
| 44 | 46 |
| 45 bool IsBound() const; | 47 bool IsBound() const; |
| 46 | 48 |
| 47 base::WeakPtr<ServiceRegistry> GetWeakPtr(); | 49 base::WeakPtr<ServiceRegistry> GetWeakPtr(); |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 // mojo::InterfaceProvider overrides. | 52 // mojo::InterfaceProvider overrides. |
| 51 void GetInterface(const mojo::String& name, | 53 void GetInterface(const mojo::String& name, |
| 52 mojo::ScopedMessagePipeHandle client_handle) override; | 54 mojo::ScopedMessagePipeHandle client_handle) override; |
| 53 | 55 |
| 56 static void RunServiceFactoryOnTaskRunner( |
| 57 const ServiceFactory& factory, |
| 58 mojo::ScopedMessagePipeHandle handle); |
| 59 |
| 54 void OnConnectionError(); | 60 void OnConnectionError(); |
| 55 | 61 |
| 56 mojo::Binding<shell::mojom::InterfaceProvider> binding_; | 62 mojo::Binding<shell::mojom::InterfaceProvider> binding_; |
| 57 shell::mojom::InterfaceProviderPtr remote_provider_; | 63 shell::mojom::InterfaceProviderPtr remote_provider_; |
| 58 | 64 |
| 59 std::map<std::string, ServiceFactory> service_factories_; | 65 std::map< |
| 66 std::string, |
| 67 std::pair<ServiceFactory, scoped_refptr<base::SingleThreadTaskRunner>>> |
| 68 service_factories_; |
| 60 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > | 69 std::queue<std::pair<std::string, mojo::MessagePipeHandle> > |
| 61 pending_connects_; | 70 pending_connects_; |
| 62 | 71 |
| 63 std::map<std::string, ServiceFactory> service_overrides_; | 72 std::map<std::string, ServiceFactory> service_overrides_; |
| 64 | 73 |
| 65 base::WeakPtrFactory<ServiceRegistry> weak_factory_; | 74 base::WeakPtrFactory<ServiceRegistry> weak_factory_; |
| 66 }; | 75 }; |
| 67 | 76 |
| 68 } // namespace content | 77 } // namespace content |
| 69 | 78 |
| 70 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ | 79 #endif // CONTENT_COMMON_MOJO_SERVICE_REGISTRY_IMPL_H_ |
| OLD | NEW |