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/common/content_export.h" | |
15 #include "content/public/common/service_manager_connection.h" | 14 #include "content/public/common/service_manager_connection.h" |
16 #include "mojo/public/cpp/system/message_pipe.h" | 15 #include "mojo/public/cpp/system/message_pipe.h" |
17 #include "services/service_manager/public/cpp/identity.h" | 16 #include "services/service_manager/public/cpp/identity.h" |
18 #include "services/service_manager/public/interfaces/service.mojom.h" | 17 #include "services/service_manager/public/interfaces/service.mojom.h" |
19 | 18 |
20 namespace service_manager { | 19 namespace service_manager { |
21 class Connector; | 20 class Connector; |
22 } | 21 } |
23 | 22 |
24 namespace content { | 23 namespace content { |
25 | 24 |
26 class CONTENT_EXPORT ServiceManagerConnectionImpl | 25 class EmbeddedServiceRunner; |
27 : public ServiceManagerConnection { | 26 |
| 27 class ServiceManagerConnectionImpl : public ServiceManagerConnection { |
28 public: | 28 public: |
29 explicit ServiceManagerConnectionImpl( | 29 explicit ServiceManagerConnectionImpl( |
30 service_manager::mojom::ServiceRequest request, | 30 service_manager::mojom::ServiceRequest request, |
31 scoped_refptr<base::SequencedTaskRunner> io_task_runner); | 31 scoped_refptr<base::SequencedTaskRunner> io_task_runner); |
32 ~ServiceManagerConnectionImpl() override; | 32 ~ServiceManagerConnectionImpl() override; |
33 | 33 |
34 private: | 34 private: |
35 class IOThreadContext; | 35 class IOThreadContext; |
36 | 36 |
37 // ServiceManagerConnection: | 37 // ServiceManagerConnection: |
(...skipping 11 matching lines...) Expand all Loading... |
49 void AddServiceRequestHandler( | 49 void AddServiceRequestHandler( |
50 const std::string& name, | 50 const std::string& name, |
51 const ServiceRequestHandler& handler) override; | 51 const ServiceRequestHandler& handler) override; |
52 int AddOnConnectHandler(const OnConnectHandler& handler) override; | 52 int AddOnConnectHandler(const OnConnectHandler& handler) override; |
53 void RemoveOnConnectHandler(int id) override; | 53 void RemoveOnConnectHandler(int id) override; |
54 | 54 |
55 void OnContextInitialized(const service_manager::Identity& identity); | 55 void OnContextInitialized(const service_manager::Identity& identity); |
56 void OnConnectionLost(); | 56 void OnConnectionLost(); |
57 void OnConnect(const service_manager::ServiceInfo& local_info, | 57 void OnConnect(const service_manager::ServiceInfo& local_info, |
58 const service_manager::ServiceInfo& remote_info); | 58 const service_manager::ServiceInfo& remote_info); |
| 59 void CreateService(service_manager::mojom::ServiceRequest request, |
| 60 const std::string& name); |
59 void GetInterface(service_manager::mojom::InterfaceProvider* provider, | 61 void GetInterface(service_manager::mojom::InterfaceProvider* provider, |
60 const std::string& interface_name, | 62 const std::string& interface_name, |
61 mojo::ScopedMessagePipeHandle request_handle); | 63 mojo::ScopedMessagePipeHandle request_handle); |
62 | 64 |
63 service_manager::Identity identity_; | 65 service_manager::Identity identity_; |
64 service_manager::ServiceInfo local_info_; | 66 service_manager::ServiceInfo local_info_; |
65 service_manager::ServiceInfo last_remote_info_; | 67 service_manager::ServiceInfo last_remote_info_; |
66 | 68 |
67 std::unique_ptr<service_manager::Connector> connector_; | 69 std::unique_ptr<service_manager::Connector> connector_; |
68 scoped_refptr<IOThreadContext> context_; | 70 scoped_refptr<IOThreadContext> context_; |
69 | 71 |
70 base::Closure connection_lost_handler_; | 72 base::Closure connection_lost_handler_; |
71 | 73 |
| 74 std::unordered_map<std::string, std::unique_ptr<EmbeddedServiceRunner>> |
| 75 embedded_services_; |
| 76 std::unordered_map<std::string, ServiceRequestHandler> request_handlers_; |
72 int next_on_connect_handler_id_ = 0; | 77 int next_on_connect_handler_id_ = 0; |
73 std::map<int, OnConnectHandler> on_connect_handlers_; | 78 std::map<int, OnConnectHandler> on_connect_handlers_; |
74 | 79 |
75 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_; | 80 base::WeakPtrFactory<ServiceManagerConnectionImpl> weak_factory_; |
76 | 81 |
77 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl); | 82 DISALLOW_COPY_AND_ASSIGN(ServiceManagerConnectionImpl); |
78 }; | 83 }; |
79 | 84 |
80 } // namespace content | 85 } // namespace content |
81 | 86 |
82 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ | 87 #endif // CONTENT_COMMON_SERVICE_MANAGER_SERVICE_MANAGER_CONNECTION_IMPL_H_ |
OLD | NEW |