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; | |
19 class Connector; | 18 class Connector; |
20 class InterfaceProvider; | |
21 class InterfaceRegistry; | |
22 } | 19 } |
23 | 20 |
24 namespace content { | 21 namespace content { |
25 | 22 |
26 class ConnectionFilter; | 23 class ConnectionFilter; |
27 | 24 |
28 // Encapsulates a connection to a //services/service_manager. | 25 // Encapsulates a connection to a //services/service_manager. |
29 // Access a global instance on the thread the ServiceContext was bound by | 26 // Access a global instance on the thread the ServiceContext was bound by |
30 // calling Holder::Get(). | 27 // calling Holder::Get(). |
31 // Clients can add service_manager::Service implementations whose exposed | 28 // Clients can add service_manager::Service implementations whose exposed |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 // Returns the service_manager::ServiceInfo for the current service and the | 82 // Returns the service_manager::ServiceInfo for the current service and the |
86 // browser service (if this is not the browser service). | 83 // browser service (if this is not the browser service). |
87 virtual const service_manager::ServiceInfo& GetLocalInfo() const = 0; | 84 virtual const service_manager::ServiceInfo& GetLocalInfo() const = 0; |
88 virtual const service_manager::ServiceInfo& GetBrowserInfo() const = 0; | 85 virtual const service_manager::ServiceInfo& GetBrowserInfo() const = 0; |
89 | 86 |
90 // Sets a closure that is called when the connection is lost. Note that | 87 // Sets a closure that is called when the connection is lost. Note that |
91 // connection may already have been closed, in which case |closure| will be | 88 // connection may already have been closed, in which case |closure| will be |
92 // run immediately before returning from this function. | 89 // run immediately before returning from this function. |
93 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; | 90 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; |
94 | 91 |
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 | |
111 static const int kInvalidConnectionFilterId = 0; | 92 static const int kInvalidConnectionFilterId = 0; |
112 | 93 |
113 // Allows the caller to filter inbound connections and/or expose interfaces | 94 // Allows the caller to filter inbound connections and/or expose interfaces |
114 // on them. |filter| may be created on any thread, but will be used and | 95 // on them. |filter| may be created on any thread, but will be used and |
115 // destroyed exclusively on the IO thread (the thread corresponding to | 96 // destroyed exclusively on the IO thread (the thread corresponding to |
116 // |io_task_runner| passed to Create() above.) | 97 // |io_task_runner| passed to Create() above.) |
117 // | 98 // |
118 // Connection filters MUST be added before calling Start() in order to avoid | 99 // Connection filters MUST be added before calling Start() in order to avoid |
119 // races. | 100 // races. |
120 // | 101 // |
(...skipping 25 matching lines...) Expand all Loading... |
146 // Registers a callback to be run when the service_manager::Service | 127 // Registers a callback to be run when the service_manager::Service |
147 // implementation on the IO thread receives OnConnect(). Returns an id that | 128 // implementation on the IO thread receives OnConnect(). Returns an id that |
148 // can be passed to RemoveOnConnectHandler(), starting at 1. | 129 // can be passed to RemoveOnConnectHandler(), starting at 1. |
149 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; | 130 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; |
150 virtual void RemoveOnConnectHandler(int id) = 0; | 131 virtual void RemoveOnConnectHandler(int id) = 0; |
151 }; | 132 }; |
152 | 133 |
153 } // namespace content | 134 } // namespace content |
154 | 135 |
155 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ | 136 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ |
OLD | NEW |