| 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 MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ | 5 #ifndef MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ |
| 6 #define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ | 6 #define MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ |
| 7 | 7 |
| 8 #include "mojo/public/cpp/application/lib/service_connector.h" | 8 #include "mojo/public/cpp/application/lib/service_connector.h" |
| 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" | 9 #include "mojo/public/interfaces/application/service_provider.mojom.h" |
| 10 | 10 |
| 11 namespace mojo { | 11 namespace mojo { |
| 12 namespace internal { | 12 namespace internal { |
| 13 class WeakServiceProvider; | 13 class WeakServiceProvider; |
| 14 class ServiceConnectorBase; | 14 class ServiceConnectorBase; |
| 15 } | 15 } |
| 16 | 16 |
| 17 // Implements a registry that can be used to expose services to another app. | 17 // Implements a registry that can be used to expose services to another app. |
| 18 class ServiceProviderImpl : public InterfaceImpl<ServiceProvider> { | 18 class ServiceProviderImpl : public InterfaceImpl<ServiceProvider> { |
| 19 public: | 19 public: |
| 20 ServiceProviderImpl(); | 20 ServiceProviderImpl(); |
| 21 ServiceProviderImpl(ApplicationConnection* application_connection); |
| 21 virtual ~ServiceProviderImpl(); | 22 virtual ~ServiceProviderImpl(); |
| 22 | 23 |
| 23 template <typename Interface> | 24 template <typename Interface> |
| 24 void AddService(InterfaceFactory<Interface>* factory) { | 25 void AddService(InterfaceFactory<Interface>* factory) { |
| 25 AddServiceConnector( | 26 AddServiceConnector( |
| 26 new internal::InterfaceFactoryConnector<Interface>(factory)); | 27 new internal::InterfaceFactoryConnector<Interface>(factory)); |
| 27 } | 28 } |
| 28 | 29 |
| 29 // Returns an instance of a ServiceProvider that weakly wraps this impl's | 30 // Returns an instance of a ServiceProvider that weakly wraps this impl's |
| 30 // connection to some other app. Whereas the lifetime of an instance of | 31 // connection to some other app. Whereas the lifetime of an instance of |
| (...skipping 20 matching lines...) Expand all Loading... |
| 51 | 52 |
| 52 void AddServiceConnector( | 53 void AddServiceConnector( |
| 53 internal::ServiceConnectorBase* service_connector); | 54 internal::ServiceConnectorBase* service_connector); |
| 54 void RemoveServiceConnector( | 55 void RemoveServiceConnector( |
| 55 internal::ServiceConnectorBase* service_connector); | 56 internal::ServiceConnectorBase* service_connector); |
| 56 | 57 |
| 57 void ClearRemote(); | 58 void ClearRemote(); |
| 58 | 59 |
| 59 NameToServiceConnectorMap service_connectors_; | 60 NameToServiceConnectorMap service_connectors_; |
| 60 | 61 |
| 62 ApplicationConnection* application_connection_; |
| 61 internal::WeakServiceProvider* remote_; | 63 internal::WeakServiceProvider* remote_; |
| 62 | 64 |
| 63 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl); | 65 MOJO_DISALLOW_COPY_AND_ASSIGN(ServiceProviderImpl); |
| 64 }; | 66 }; |
| 65 | 67 |
| 66 } // namespace mojo | 68 } // namespace mojo |
| 67 | 69 |
| 68 #endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ | 70 #endif // MOJO_PUBLIC_APPLICATION_SERVICE_PROVIDER_IMPL_H_ |
| OLD | NEW |