Introduce (Un)SubscribeDtlsTransportState methods.

WebRTC is going to remove cricket::DtlsTransportState and switch to
webrtc::DtlsTransportState. This CL introduces a set of new methods to
allow to subscribe to DTLS transport state updates while WebRTC
internally migrates away from cricket::DtlsTransportState.

No-Try: True
Bug: webrtc:12762
Change-Id: I79cf48e2f7122cc76fde6e4fd1541382fd096d53
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/218607
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34075}
This commit is contained in:
Mirko Bonadei 2021-05-13 16:50:45 +02:00 committed by WebRTC LUCI CQ
parent 95f1e5192c
commit edc347c4e5

View File

@ -132,9 +132,27 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal {
dtls_state_callback_list_.RemoveReceivers(id);
}
// F: void(DtlsTransportInternal*, const webrtc::DtlsTransportState)
template <typename F>
void SubscribeDtlsTransportState(F&& callback) {
dtls_transport_state_callback_list_.AddReceiver(std::forward<F>(callback));
}
template <typename F>
void SubscribeDtlsTransportState(const void* id, F&& callback) {
dtls_transport_state_callback_list_.AddReceiver(id,
std::forward<F>(callback));
}
// Unsubscribe the subscription with given id.
void UnsubscribeDtlsTransportState(const void* id) {
dtls_transport_state_callback_list_.RemoveReceivers(id);
}
void SendDtlsState(DtlsTransportInternal* transport,
DtlsTransportState state) {
dtls_state_callback_list_.Send(transport, state);
dtls_transport_state_callback_list_.Send(transport,
ConvertDtlsTransportState(state));
}
// Emitted whenever the Dtls handshake failed on some transport channel.
@ -155,8 +173,12 @@ class DtlsTransportInternal : public rtc::PacketTransportInternal {
RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportInternal);
webrtc::CallbackList<const rtc::SSLHandshakeError>
dtls_handshake_error_callback_list_;
// TODO(bugs.webrtc.org/12762): Remove in favor of
// dtls_transport_state_callback_list_.
webrtc::CallbackList<DtlsTransportInternal*, const DtlsTransportState>
dtls_state_callback_list_;
webrtc::CallbackList<DtlsTransportInternal*, const webrtc::DtlsTransportState>
dtls_transport_state_callback_list_;
};
} // namespace cricket