| 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_CONNECTION_FILTER_H_ | 5 #ifndef CONTENT_PUBLIC_COMMON_CONNECTION_FILTER_H_ |
| 6 #define CONTENT_PUBLIC_COMMON_CONNECTION_FILTER_H_ | 6 #define CONTENT_PUBLIC_COMMON_CONNECTION_FILTER_H_ |
| 7 | 7 |
| 8 #include "content/common/content_export.h" | 8 #include "content/common/content_export.h" |
| 9 #include "mojo/public/cpp/system/message_pipe.h" |
| 9 | 10 |
| 10 namespace service_manager { | 11 namespace service_manager { |
| 11 class Connector; | 12 class Connector; |
| 12 class Identity; | 13 struct ServiceInfo; |
| 13 class InterfaceRegistry; | |
| 14 } | 14 } |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // A ConnectionFilter may be used to conditionally expose interfaces on inbound | 18 // TODO(beng): Rename to InterfaceBinder? |
| 19 // connections accepted by ServiceManagerConnection. ConnectionFilters are used | 19 // See ServiceManagerConnection::AddConnectionFilter(). |
| 20 // exclusively on the IO thread. See | |
| 21 // ServiceManagerConnection::AddConnectionFilter for details. | |
| 22 class CONTENT_EXPORT ConnectionFilter { | 20 class CONTENT_EXPORT ConnectionFilter { |
| 23 public: | 21 public: |
| 24 virtual ~ConnectionFilter() {} | 22 virtual ~ConnectionFilter() {} |
| 25 | 23 |
| 26 // Called for every new connection accepted. Implementations may add | 24 // Provides the ConnectionFilter with the option of binding an interface |
| 27 // interfaces to |registry|, in which case they should return |true|. | 25 // request from a remote service. The interface request is in |
| 28 // |connector| is a corresponding outgoing Connector that may be used by any | 26 // |interface_pipe|, which is taken by the binding action. If the interface |
| 29 // interfaces added to the connection. Note that references to |connector| | 27 // request is bound, subsequent ConnectionFilters are not consulted. |
| 30 // must not be retained, but an owned copy may be obtained by calling | 28 virtual void OnBindInterface(const service_manager::ServiceInfo& source_info, |
| 31 // |connector->Clone()|. | 29 const std::string& interface_name, |
| 32 // | 30 mojo::ScopedMessagePipeHandle* interface_pipe, |
| 33 // If a ConnectionFilter is not interested in an incoming connection, it | 31 service_manager::Connector* connector) = 0; |
| 34 // should return |false|. | |
| 35 // | |
| 36 // NOTE: This ConnectionFilter is NOT guaranteed to outlive |registry|, so you | |
| 37 // must not attach unsafe references to |this|, e.g., via AddInterface(). | |
| 38 virtual bool OnConnect(const service_manager::Identity& remote_identity, | |
| 39 service_manager::InterfaceRegistry* registry, | |
| 40 service_manager::Connector* connector) = 0; | |
| 41 }; | 32 }; |
| 42 | 33 |
| 43 } // namespace content | 34 } // namespace content |
| 44 | 35 |
| 45 #endif // CONTENT_PUBLIC_COMMON_CONNECTION_FILTER_H_ | 36 #endif // CONTENT_PUBLIC_COMMON_CONNECTION_FILTER_H_ |
| OLD | NEW |