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_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ |
6 #define CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ | 6 #define CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "base/sequenced_task_runner.h" | 11 #include "base/sequenced_task_runner.h" |
12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
13 #include "content/public/common/service_info.h" | 13 #include "content/public/common/service_info.h" |
14 #include "services/service_manager/public/cpp/identity.h" | 14 #include "services/service_manager/public/cpp/identity.h" |
15 #include "services/service_manager/public/interfaces/service.mojom.h" | 15 #include "services/service_manager/public/interfaces/service.mojom.h" |
16 | 16 |
17 namespace service_manager { | 17 namespace service_manager { |
| 18 class Connection; |
18 class Connector; | 19 class Connector; |
| 20 class InterfaceProvider; |
| 21 class InterfaceRegistry; |
19 } | 22 } |
20 | 23 |
21 namespace content { | 24 namespace content { |
22 | 25 |
23 class ConnectionFilter; | 26 class ConnectionFilter; |
24 | 27 |
25 // Encapsulates a connection to a //services/service_manager. | 28 // Encapsulates a connection to a //services/service_manager. |
26 // Access a global instance on the thread the ServiceContext was bound by | 29 // Access a global instance on the thread the ServiceContext was bound by |
27 // calling Holder::Get(). | 30 // calling Holder::Get(). |
28 // Clients can add service_manager::Service implementations whose exposed | 31 // Clients can add service_manager::Service implementations whose exposed |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // Returns the service_manager::ServiceInfo for the current service and the | 85 // Returns the service_manager::ServiceInfo for the current service and the |
83 // browser service (if this is not the browser service). | 86 // browser service (if this is not the browser service). |
84 virtual const service_manager::ServiceInfo& GetLocalInfo() const = 0; | 87 virtual const service_manager::ServiceInfo& GetLocalInfo() const = 0; |
85 virtual const service_manager::ServiceInfo& GetBrowserInfo() const = 0; | 88 virtual const service_manager::ServiceInfo& GetBrowserInfo() const = 0; |
86 | 89 |
87 // Sets a closure that is called when the connection is lost. Note that | 90 // Sets a closure that is called when the connection is lost. Note that |
88 // connection may already have been closed, in which case |closure| will be | 91 // connection may already have been closed, in which case |closure| will be |
89 // run immediately before returning from this function. | 92 // run immediately before returning from this function. |
90 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; | 93 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; |
91 | 94 |
| 95 // Provides an InterfaceRegistry to forward incoming interface requests to |
| 96 // on the ServiceManagerConnection's own thread if they aren't bound by the |
| 97 // connection's internal InterfaceRegistry on the IO thread. |
| 98 // |
| 99 // Also configures |interface_provider| to forward all of its outgoing |
| 100 // interface requests to the connection's internal remote interface provider. |
| 101 // |
| 102 // Note that neither |interface_registry| or |interface_provider| is owned |
| 103 // and both MUST outlive the ServiceManagerConnection. |
| 104 // |
| 105 // TODO(rockot): Remove this. It's a temporary solution to avoid porting all |
| 106 // relevant code to ConnectionFilters at once. |
| 107 virtual void SetupInterfaceRequestProxies( |
| 108 service_manager::InterfaceRegistry* registry, |
| 109 service_manager::InterfaceProvider* provider) = 0; |
| 110 |
92 static const int kInvalidConnectionFilterId = 0; | 111 static const int kInvalidConnectionFilterId = 0; |
93 | 112 |
94 // Allows the caller to filter inbound connections and/or expose interfaces | 113 // Allows the caller to filter inbound connections and/or expose interfaces |
95 // on them. |filter| may be created on any thread, but will be used and | 114 // on them. |filter| may be created on any thread, but will be used and |
96 // destroyed exclusively on the IO thread (the thread corresponding to | 115 // destroyed exclusively on the IO thread (the thread corresponding to |
97 // |io_task_runner| passed to Create() above.) | 116 // |io_task_runner| passed to Create() above.) |
98 // | 117 // |
99 // Connection filters MUST be added before calling Start() in order to avoid | 118 // Connection filters MUST be added before calling Start() in order to avoid |
100 // races. | 119 // races. |
101 // | 120 // |
(...skipping 25 matching lines...) Expand all Loading... |
127 // Registers a callback to be run when the service_manager::Service | 146 // Registers a callback to be run when the service_manager::Service |
128 // implementation on the IO thread receives OnConnect(). Returns an id that | 147 // implementation on the IO thread receives OnConnect(). Returns an id that |
129 // can be passed to RemoveOnConnectHandler(), starting at 1. | 148 // can be passed to RemoveOnConnectHandler(), starting at 1. |
130 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; | 149 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; |
131 virtual void RemoveOnConnectHandler(int id) = 0; | 150 virtual void RemoveOnConnectHandler(int id) = 0; |
132 }; | 151 }; |
133 | 152 |
134 } // namespace content | 153 } // namespace content |
135 | 154 |
136 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ | 155 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ |
OLD | NEW |