| 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" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // will be exposed to inbound connections to this object's Service. | 30 // will be exposed to inbound connections to this object's Service. |
| 31 // Alternatively clients can define named services that will be constructed when | 31 // Alternatively clients can define named services that will be constructed when |
| 32 // requests for those service names are received. | 32 // requests for those service names are received. |
| 33 // Clients must call any of the registration methods when receiving | 33 // Clients must call any of the registration methods when receiving |
| 34 // ContentBrowserClient::RegisterInProcessServices(). | 34 // ContentBrowserClient::RegisterInProcessServices(). |
| 35 class CONTENT_EXPORT ServiceManagerConnection { | 35 class CONTENT_EXPORT ServiceManagerConnection { |
| 36 public: | 36 public: |
| 37 using ServiceRequestHandler = | 37 using ServiceRequestHandler = |
| 38 base::Callback<void(service_manager::mojom::ServiceRequest)>; | 38 base::Callback<void(service_manager::mojom::ServiceRequest)>; |
| 39 using OnConnectHandler = | 39 using OnConnectHandler = |
| 40 base::Callback<void(const service_manager::ServiceInfo&, | 40 base::Callback<void(const service_manager::BindSourceInfo&)>; |
| 41 const service_manager::ServiceInfo&)>; | |
| 42 using Factory = | 41 using Factory = |
| 43 base::Callback<std::unique_ptr<ServiceManagerConnection>(void)>; | 42 base::Callback<std::unique_ptr<ServiceManagerConnection>(void)>; |
| 44 | 43 |
| 45 // Stores an instance of |connection| in TLS for the current process. Must be | 44 // Stores an instance of |connection| in TLS for the current process. Must be |
| 46 // called on the thread the connection was created on. | 45 // called on the thread the connection was created on. |
| 47 static void SetForProcess( | 46 static void SetForProcess( |
| 48 std::unique_ptr<ServiceManagerConnection> connection); | 47 std::unique_ptr<ServiceManagerConnection> connection); |
| 49 | 48 |
| 50 // Returns the per-process instance, or nullptr if the Service Manager | 49 // Returns the per-process instance, or nullptr if the Service Manager |
| 51 // connection has not yet been bound. Must be called on the thread the | 50 // connection has not yet been bound. Must be called on the thread the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 72 // Begins accepting incoming connections. Connection filters MUST be added | 71 // Begins accepting incoming connections. Connection filters MUST be added |
| 73 // before calling this in order to avoid races. See AddConnectionFilter() | 72 // before calling this in order to avoid races. See AddConnectionFilter() |
| 74 // below. | 73 // below. |
| 75 virtual void Start() = 0; | 74 virtual void Start() = 0; |
| 76 | 75 |
| 77 // Returns the service_manager::Connector received via this connection's | 76 // Returns the service_manager::Connector received via this connection's |
| 78 // Service | 77 // Service |
| 79 // implementation. Use this to initiate connections as this object's Identity. | 78 // implementation. Use this to initiate connections as this object's Identity. |
| 80 virtual service_manager::Connector* GetConnector() = 0; | 79 virtual service_manager::Connector* GetConnector() = 0; |
| 81 | 80 |
| 82 // Returns the service_manager::ServiceInfo for the current service and the | 81 // Returns the service_manager::BindSourceInfo for the browser service (if |
| 83 // browser service (if this is not the browser service). | 82 // this is not the browser service). |
| 84 virtual const service_manager::ServiceInfo& GetLocalInfo() const = 0; | 83 virtual const service_manager::BindSourceInfo& GetBrowserInfo() const = 0; |
| 85 virtual const service_manager::ServiceInfo& GetBrowserInfo() const = 0; | |
| 86 | 84 |
| 87 // Sets a closure that is called when the connection is lost. Note that | 85 // 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 | 86 // connection may already have been closed, in which case |closure| will be |
| 89 // run immediately before returning from this function. | 87 // run immediately before returning from this function. |
| 90 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; | 88 virtual void SetConnectionLostClosure(const base::Closure& closure) = 0; |
| 91 | 89 |
| 92 static const int kInvalidConnectionFilterId = 0; | 90 static const int kInvalidConnectionFilterId = 0; |
| 93 | 91 |
| 94 // Allows the caller to filter inbound connections and/or expose interfaces | 92 // 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 | 93 // on them. |filter| may be created on any thread, but will be used and |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // Registers a callback to be run when the service_manager::Service | 125 // Registers a callback to be run when the service_manager::Service |
| 128 // implementation on the IO thread receives OnConnect(). Returns an id that | 126 // implementation on the IO thread receives OnConnect(). Returns an id that |
| 129 // can be passed to RemoveOnConnectHandler(), starting at 1. | 127 // can be passed to RemoveOnConnectHandler(), starting at 1. |
| 130 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; | 128 virtual int AddOnConnectHandler(const OnConnectHandler& handler) = 0; |
| 131 virtual void RemoveOnConnectHandler(int id) = 0; | 129 virtual void RemoveOnConnectHandler(int id) = 0; |
| 132 }; | 130 }; |
| 133 | 131 |
| 134 } // namespace content | 132 } // namespace content |
| 135 | 133 |
| 136 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ | 134 #endif // CONTENT_PUBLIC_COMMON_SERVICE_MANAGER_CONNECTION_H_ |
| OLD | NEW |