| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright 2016 gRPC authors. |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
* |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H |
| 20 |
#define GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H |
| 21 |
|
| 22 |
#include <grpc/support/port_platform.h> |
| 23 |
|
| 24 |
#include <memory> |
| 25 |
#include <vector> |
| 26 |
|
| 27 |
#include "src/core/lib/channel/channel_args.h" |
| 28 |
#include "src/core/lib/iomgr/iomgr_fwd.h" |
| 29 |
#include "src/core/lib/transport/handshaker_factory.h" |
| 30 |
|
| 31 |
namespace grpc_core { |
| 32 |
|
| 33 |
typedef enum { |
| 34 |
HANDSHAKER_CLIENT = 0, |
| 35 |
HANDSHAKER_SERVER, |
| 36 |
NUM_HANDSHAKER_TYPES, // Must be last. |
| 37 |
} HandshakerType; |
| 38 |
|
| 39 |
class HandshakerRegistry { |
| 40 |
public: |
| 41 |
class Builder { |
| 42 |
public: |
| 43 |
/// Registers a new handshaker factory. Takes ownership. |
| 44 |
/// The priority of the handshaker will be used to order the handshakers |
| 45 |
/// in the list. |
| 46 |
void RegisterHandshakerFactory(HandshakerType handshaker_type, |
| 47 |
std::unique_ptr<HandshakerFactory> factory); |
| 48 |
|
| 49 |
HandshakerRegistry Build(); |
| 50 |
|
| 51 |
private: |
| 52 |
std::vector<std::unique_ptr<HandshakerFactory>> |
| 53 |
factories_[NUM_HANDSHAKER_TYPES]; |
| 54 |
}; |
| 55 |
|
| 56 |
void AddHandshakers(HandshakerType handshaker_type, const ChannelArgs& args, |
| 57 |
grpc_pollset_set* interested_parties, |
| 58 |
HandshakeManager* handshake_mgr) const; |
| 59 |
|
| 60 |
private: |
| 61 |
HandshakerRegistry() = default; |
| 62 |
|
| 63 |
std::vector<std::unique_ptr<HandshakerFactory>> |
| 64 |
factories_[NUM_HANDSHAKER_TYPES]; |
| 65 |
}; |
| 66 |
|
| 67 |
} // namespace grpc_core |
| 68 |
|
| 69 |
#endif /* GRPC_CORE_LIB_TRANSPORT_HANDSHAKER_REGISTRY_H */ |