| 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 CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ | 5 #ifndef CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ |
| 6 #define CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ | 6 #define CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 14 #include "content/public/common/service_manager_connection.h" | 14 #include "content/public/common/service_manager_connection.h" |
| 15 #include "mojo/public/cpp/bindings/string.h" | 15 #include "mojo/public/cpp/bindings/string.h" |
| 16 #include "mojo/public/cpp/system/message_pipe.h" | 16 #include "mojo/public/cpp/system/message_pipe.h" |
| 17 #include "services/service_manager/public/cpp/identity.h" | 17 #include "services/service_manager/public/cpp/identity.h" |
| 18 #include "services/service_manager/public/interfaces/service.mojom.h" | 18 #include "services/service_manager/public/interfaces/service.mojom.h" |
| 19 | 19 |
| 20 namespace shell { | 20 namespace service_manager { |
| 21 class Connector; | 21 class Connector; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 class EmbeddedServiceRunner; | 26 class EmbeddedServiceRunner; |
| 27 | 27 |
| 28 class ServiceManagerConnectionImpl : public ServiceManagerConnection { | 28 class ServiceManagerConnectionImpl : public ServiceManagerConnection { |
| 29 public: | 29 public: |
| 30 explicit ServiceManagerConnectionImpl( | 30 explicit ServiceManagerConnectionImpl( |
| 31 shell::mojom::ServiceRequest request, | 31 service_manager::mojom::ServiceRequest request, |
| 32 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 32 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
| 33 ~ServiceManagerConnectionImpl() override; | 33 ~ServiceManagerConnectionImpl() override; |
| 34 | 34 |
| 35 private: | 35 private: |
| 36 class IOThreadContext; | 36 class IOThreadContext; |
| 37 | 37 |
| 38 // ServiceManagerConnection: | 38 // ServiceManagerConnection: |
| 39 void Start() override; | 39 void Start() override; |
| 40 void SetInitializeHandler(const base::Closure& handler) override; | 40 void SetInitializeHandler(const base::Closure& handler) override; |
| 41 shell::Connector* GetConnector() override; | 41 service_manager::Connector* GetConnector() override; |
| 42 const shell::Identity& GetIdentity() const override; | 42 const service_manager::Identity& GetIdentity() const override; |
| 43 void SetConnectionLostClosure(const base::Closure& closure) override; | 43 void SetConnectionLostClosure(const base::Closure& closure) override; |
| 44 void SetupInterfaceRequestProxies( | 44 void SetupInterfaceRequestProxies( |
| 45 shell::InterfaceRegistry* registry, | 45 service_manager::InterfaceRegistry* registry, |
| 46 shell::InterfaceProvider* provider) override; | 46 service_manager::InterfaceProvider* provider) override; |
| 47 int AddConnectionFilter(std::unique_ptr<ConnectionFilter> filter) override; | 47 int AddConnectionFilter(std::unique_ptr<ConnectionFilter> filter) override; |
| 48 void RemoveConnectionFilter(int filter_id) override; | 48 void RemoveConnectionFilter(int filter_id) override; |
| 49 void AddEmbeddedService(const std::string& name, | 49 void AddEmbeddedService(const std::string& name, |
| 50 const ServiceInfo& info) override; | 50 const ServiceInfo& info) override; |
| 51 void AddServiceRequestHandler( | 51 void AddServiceRequestHandler( |
| 52 const std::string& name, | 52 const std::string& name, |
| 53 const ServiceRequestHandler& handler) override; | 53 const ServiceRequestHandler& handler) override; |
| 54 | 54 |
| 55 void OnContextInitialized(const shell::Identity& identity); | 55 void OnContextInitialized(const service_manager::Identity& identity); |
| 56 void OnConnectionLost(); | 56 void OnConnectionLost(); |
| 57 void CreateService(shell::mojom::ServiceRequest request, | 57 void CreateService(service_manager::mojom::ServiceRequest request, |
| 58 const std::string& name); | 58 const std::string& name); |
| 59 void GetInterface(shell::mojom::InterfaceProvider* provider, | 59 void GetInterface(service_manager::mojom::InterfaceProvider* provider, |
| 60 const std::string& interface_name, | 60 const std::string& interface_name, |
| 61 mojo::ScopedMessagePipeHandle request_handle); | 61 mojo::ScopedMessagePipeHandle request_handle); |
| 62 | 62 |
| 63 shell::Identity identity_; | 63 service_manager::Identity identity_; |
| 64 | 64 |
| 65 std::unique_ptr<shell::Connector> connector_; | 65 std::unique_ptr<service_manager::Connector> connector_; |
| 66 scoped_refptr<IOThreadContext> context_; | 66 scoped_refptr<IOThreadContext> context_; |
| 67 | 67 |
| 68 base::Closure initialize_handler_; | 68 base::Closure initialize_handler_; |
| 69 base::Closure connection_lost_handler_; | 69 base::Closure connection_lost_handler_; |
| 70 | 70 |
| 71 std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>> | 71 std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>> |
| 72 embedded_services_; | 72 embedded_services_; |
| 73 std::unordered_map<std::string, ServiceRequestHandler> request_handlers_; | 73 std::unordered_map<std::string, ServiceRequestHandler> request_handlers_; |
| 74 | 74 |
| 75 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_; | 75 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_; |
| 76 | 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl); | 77 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 } // namespace content | 80 } // namespace content |
| 81 | 81 |
| 82 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ | 82 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ |
| OLD | NEW |