aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbraham Corea Diaz <abrahamcd@google.com>2021-07-09 23:35:39 +0000
committerOpenscreen LUCI CQ <openscreen-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-07-14 01:27:13 +0000
commitbffb5c2247c5705401499ff13b686b119d9918b6 (patch)
tree37035bdd2216518204b6e52d7ba353368258febf
parent7e167e2bc4c8c0c650f00b995e1e20cb1ae1f479 (diff)
downloadopenscreen-bffb5c2247c5705401499ff13b686b119d9918b6.tar.gz
Define virtual destructors in Client interfaces.
This patch adds virtual destructors to all Client and Delegate interfaces that did not have one. Bug: b/156129407 Change-Id: I8b7365ab8a38b9e76a45ced08dd94d1aa595209b Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/3011415 Commit-Queue: Jordan Bayles <jophba@chromium.org> Reviewed-by: Jordan Bayles <jophba@chromium.org> Reviewed-by: mark a. foltz <mfoltz@chromium.org>
-rw-r--r--cast/common/channel/cast_socket.cc2
-rw-r--r--cast/common/public/cast_socket.h4
-rw-r--r--cast/common/public/message_port.h4
-rw-r--r--cast/receiver/channel/receiver_socket_factory.cc2
-rw-r--r--cast/receiver/public/receiver_socket_factory.h4
-rw-r--r--cast/sender/channel/sender_socket_factory.cc2
-rw-r--r--cast/sender/public/sender_socket_factory.h4
-rw-r--r--cast/standalone_receiver/decoder.h2
-rw-r--r--cast/standalone_receiver/streaming_playback_controller.cc2
-rw-r--r--cast/standalone_receiver/streaming_playback_controller.h3
-rw-r--r--cast/streaming/compound_rtcp_parser.h4
-rw-r--r--cast/streaming/compound_rtcp_parser_fuzzer.cc7
-rw-r--r--discovery/dnssd/public/dns_sd_publisher.h4
-rw-r--r--osp/impl/quic/quic_connection.h8
-rw-r--r--osp/impl/service_listener_impl.h2
-rw-r--r--osp/impl/service_publisher_impl.h3
-rw-r--r--osp/public/presentation/presentation_connection.h4
-rw-r--r--osp/public/request_response_handler.h4
-rw-r--r--platform/api/tls_connection.cc2
-rw-r--r--platform/api/tls_connection.h2
-rw-r--r--platform/api/tls_connection_factory.cc2
-rw-r--r--platform/api/tls_connection_factory.h3
-rw-r--r--platform/api/udp_socket.cc2
-rw-r--r--platform/api/udp_socket.h4
24 files changed, 66 insertions, 14 deletions
diff --git a/cast/common/channel/cast_socket.cc b/cast/common/channel/cast_socket.cc
index 0479c997..e06cde46 100644
--- a/cast/common/channel/cast_socket.cc
+++ b/cast/common/channel/cast_socket.cc
@@ -14,6 +14,8 @@ namespace cast {
using ::cast::channel::CastMessage;
using message_serialization::DeserializeResult;
+CastSocket::Client::~Client() = default;
+
CastSocket::CastSocket(std::unique_ptr<TlsConnection> connection,
Client* client)
: connection_(std::move(connection)),
diff --git a/cast/common/public/cast_socket.h b/cast/common/public/cast_socket.h
index 5c0b8775..330b1962 100644
--- a/cast/common/public/cast_socket.h
+++ b/cast/common/public/cast_socket.h
@@ -28,13 +28,15 @@ class CastSocket : public TlsConnection::Client {
public:
class Client {
public:
- virtual ~Client() = default;
// Called when a terminal error on |socket| has occurred.
virtual void OnError(CastSocket* socket, Error error) = 0;
virtual void OnMessage(CastSocket* socket,
::cast::channel::CastMessage message) = 0;
+
+ protected:
+ virtual ~Client();
};
CastSocket(std::unique_ptr<TlsConnection> connection, Client* client);
diff --git a/cast/common/public/message_port.h b/cast/common/public/message_port.h
index 23094740..91eabcd1 100644
--- a/cast/common/public/message_port.h
+++ b/cast/common/public/message_port.h
@@ -20,11 +20,13 @@ class MessagePort {
public:
class Client {
public:
- virtual ~Client() = default;
virtual void OnMessage(const std::string& source_sender_id,
const std::string& message_namespace,
const std::string& message) = 0;
virtual void OnError(Error error) = 0;
+
+ protected:
+ virtual ~Client() = default;
};
virtual ~MessagePort() = default;
diff --git a/cast/receiver/channel/receiver_socket_factory.cc b/cast/receiver/channel/receiver_socket_factory.cc
index e5ba479c..5645bbda 100644
--- a/cast/receiver/channel/receiver_socket_factory.cc
+++ b/cast/receiver/channel/receiver_socket_factory.cc
@@ -9,6 +9,8 @@
namespace openscreen {
namespace cast {
+ReceiverSocketFactory::Client::~Client() = default;
+
ReceiverSocketFactory::ReceiverSocketFactory(Client* client,
CastSocket::Client* socket_client)
: client_(client), socket_client_(socket_client) {
diff --git a/cast/receiver/public/receiver_socket_factory.h b/cast/receiver/public/receiver_socket_factory.h
index 0e2e4e1c..612ffc47 100644
--- a/cast/receiver/public/receiver_socket_factory.h
+++ b/cast/receiver/public/receiver_socket_factory.h
@@ -5,6 +5,7 @@
#ifndef CAST_RECEIVER_PUBLIC_RECEIVER_SOCKET_FACTORY_H_
#define CAST_RECEIVER_PUBLIC_RECEIVER_SOCKET_FACTORY_H_
+#include <memory>
#include <vector>
#include "cast/common/public/cast_socket.h"
@@ -22,6 +23,9 @@ class ReceiverSocketFactory final : public TlsConnectionFactory::Client {
const IPEndpoint& endpoint,
std::unique_ptr<CastSocket> socket) = 0;
virtual void OnError(ReceiverSocketFactory* factory, Error error) = 0;
+
+ protected:
+ virtual ~Client();
};
// |client| and |socket_client| must outlive |this|.
diff --git a/cast/sender/channel/sender_socket_factory.cc b/cast/sender/channel/sender_socket_factory.cc
index abbabfd6..c0924836 100644
--- a/cast/sender/channel/sender_socket_factory.cc
+++ b/cast/sender/channel/sender_socket_factory.cc
@@ -16,6 +16,8 @@ using ::cast::channel::CastMessage;
namespace openscreen {
namespace cast {
+SenderSocketFactory::Client::~Client() = default;
+
bool operator<(const std::unique_ptr<SenderSocketFactory::PendingAuth>& a,
int b) {
return a && a->socket->socket_id() < b;
diff --git a/cast/sender/public/sender_socket_factory.h b/cast/sender/public/sender_socket_factory.h
index f0247a28..0b9b05aa 100644
--- a/cast/sender/public/sender_socket_factory.h
+++ b/cast/sender/public/sender_socket_factory.h
@@ -7,6 +7,7 @@
#include <openssl/x509.h>
+#include <memory>
#include <set>
#include <utility>
#include <vector>
@@ -33,6 +34,9 @@ class SenderSocketFactory final : public TlsConnectionFactory::Client,
virtual void OnError(SenderSocketFactory* factory,
const IPEndpoint& endpoint,
Error error) = 0;
+
+ protected:
+ virtual ~Client();
};
enum class DeviceMediaPolicy {
diff --git a/cast/standalone_receiver/decoder.h b/cast/standalone_receiver/decoder.h
index 1d4d0791..30e56553 100644
--- a/cast/standalone_receiver/decoder.h
+++ b/cast/standalone_receiver/decoder.h
@@ -38,7 +38,6 @@ class Decoder {
// Interface for receiving decoded frames and/or errors.
class Client {
public:
- virtual ~Client();
virtual void OnFrameDecoded(FrameId frame_id, const AVFrame& frame) = 0;
virtual void OnDecodeError(FrameId frame_id, std::string message) = 0;
@@ -46,6 +45,7 @@ class Decoder {
protected:
Client();
+ virtual ~Client();
};
// |codec_name| should be the codec_name field from an OFFER message.
diff --git a/cast/standalone_receiver/streaming_playback_controller.cc b/cast/standalone_receiver/streaming_playback_controller.cc
index 46ee0bbb..8c931273 100644
--- a/cast/standalone_receiver/streaming_playback_controller.cc
+++ b/cast/standalone_receiver/streaming_playback_controller.cc
@@ -19,6 +19,8 @@
namespace openscreen {
namespace cast {
+StreamingPlaybackController::Client::~Client() = default;
+
#if defined(CAST_STANDALONE_RECEIVER_HAVE_EXTERNAL_LIBS)
StreamingPlaybackController::StreamingPlaybackController(
TaskRunner* task_runner,
diff --git a/cast/standalone_receiver/streaming_playback_controller.h b/cast/standalone_receiver/streaming_playback_controller.h
index 65a233e5..68f3068d 100644
--- a/cast/standalone_receiver/streaming_playback_controller.h
+++ b/cast/standalone_receiver/streaming_playback_controller.h
@@ -28,6 +28,9 @@ class StreamingPlaybackController final : public ReceiverSession::Client {
public:
virtual void OnPlaybackError(StreamingPlaybackController* controller,
Error error) = 0;
+
+ protected:
+ virtual ~Client();
};
StreamingPlaybackController(TaskRunner* task_runner,
diff --git a/cast/streaming/compound_rtcp_parser.h b/cast/streaming/compound_rtcp_parser.h
index c74bb3ec..a8bb2e39 100644
--- a/cast/streaming/compound_rtcp_parser.h
+++ b/cast/streaming/compound_rtcp_parser.h
@@ -37,7 +37,6 @@ class CompoundRtcpParser {
class Client {
public:
Client();
- virtual ~Client();
// Called when a Receiver Reference Time Report has been parsed.
virtual void OnReceiverReferenceTimeAdvanced(
@@ -70,6 +69,9 @@ class CompoundRtcpParser {
// kAllPacketsLost indicates that all the packets are missing for a frame.
// The argument's elements are in monotonically increasing order.
virtual void OnReceiverIsMissingPackets(std::vector<PacketNack> nacks);
+
+ protected:
+ virtual ~Client();
};
// |session| and |client| must be non-null and must outlive the
diff --git a/cast/streaming/compound_rtcp_parser_fuzzer.cc b/cast/streaming/compound_rtcp_parser_fuzzer.cc
index bb3dd179..05994a3a 100644
--- a/cast/streaming/compound_rtcp_parser_fuzzer.cc
+++ b/cast/streaming/compound_rtcp_parser_fuzzer.cc
@@ -17,6 +17,11 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
constexpr Ssrc kSenderSsrcInSeedCorpus = 1;
constexpr Ssrc kReceiverSsrcInSeedCorpus = 2;
+ class ClientThatIgnoresEverything : public CompoundRtcpParser::Client {
+ public:
+ ClientThatIgnoresEverything() = default;
+ ~ClientThatIgnoresEverything() override = default;
+ };
// Allocate the RtcpSession and CompoundRtcpParser statically (i.e., one-time
// init) to improve the fuzzer's execution rate. This is because RtcpSession
// also contains a NtpTimeConverter, which samples the system clock at
@@ -26,7 +31,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
#pragma clang diagnostic ignored "-Wexit-time-destructors"
static RtcpSession session(kSenderSsrcInSeedCorpus, kReceiverSsrcInSeedCorpus,
openscreen::Clock::time_point{});
- static CompoundRtcpParser::Client client_that_ignores_everything;
+ static ClientThatIgnoresEverything client_that_ignores_everything;
static CompoundRtcpParser parser(&session, &client_that_ignores_everything);
#pragma clang diagnostic pop
diff --git a/discovery/dnssd/public/dns_sd_publisher.h b/discovery/dnssd/public/dns_sd_publisher.h
index 3c139b4e..10eb03ad 100644
--- a/discovery/dnssd/public/dns_sd_publisher.h
+++ b/discovery/dnssd/public/dns_sd_publisher.h
@@ -19,7 +19,6 @@ class DnsSdPublisher {
public:
class Client {
public:
- virtual ~Client() = default;
// Callback called when an endpoint is successfully claimed and published
// via the Register() method. These values are expected to only differ in
@@ -29,6 +28,9 @@ class DnsSdPublisher {
virtual void OnEndpointClaimed(
const DnsSdInstance& requested_instance,
const DnsSdInstanceEndpoint& claimed_endpoint) = 0;
+
+ protected:
+ virtual ~Client() = default;
};
virtual ~DnsSdPublisher() = default;
diff --git a/osp/impl/quic/quic_connection.h b/osp/impl/quic/quic_connection.h
index e00e25a0..6fbc81af 100644
--- a/osp/impl/quic/quic_connection.h
+++ b/osp/impl/quic/quic_connection.h
@@ -17,12 +17,14 @@ class QuicStream {
public:
class Delegate {
public:
- virtual ~Delegate() = default;
virtual void OnReceived(QuicStream* stream,
const char* data,
size_t data_size) = 0;
virtual void OnClose(uint64_t stream_id) = 0;
+
+ protected:
+ virtual ~Delegate() = default;
};
QuicStream(Delegate* delegate, uint64_t id) : delegate_(delegate), id_(id) {}
@@ -41,7 +43,6 @@ class QuicConnection : public UdpSocket::Client {
public:
class Delegate {
public:
- virtual ~Delegate() = default;
// Called when the QUIC handshake has successfully completed.
virtual void OnCryptoHandshakeComplete(uint64_t connection_id) = 0;
@@ -63,6 +64,9 @@ class QuicConnection : public UdpSocket::Client {
// will be returned via OnIncomingStream immediately after this call.
virtual QuicStream::Delegate* NextStreamDelegate(uint64_t connection_id,
uint64_t stream_id) = 0;
+
+ protected:
+ virtual ~Delegate() = default;
};
explicit QuicConnection(Delegate* delegate) : delegate_(delegate) {}
diff --git a/osp/impl/service_listener_impl.h b/osp/impl/service_listener_impl.h
index b94dcdb1..9516ff18 100644
--- a/osp/impl/service_listener_impl.h
+++ b/osp/impl/service_listener_impl.h
@@ -22,7 +22,6 @@ class ServiceListenerImpl final : public ServiceListener,
class Delegate {
public:
Delegate();
- virtual ~Delegate();
void SetListenerImpl(ServiceListenerImpl* listener);
@@ -34,6 +33,7 @@ class ServiceListenerImpl final : public ServiceListener,
virtual void SearchNow(State from) = 0;
protected:
+ virtual ~Delegate();
void SetState(State state) { listener_->SetState(state); }
ServiceListenerImpl* listener_ = nullptr;
diff --git a/osp/impl/service_publisher_impl.h b/osp/impl/service_publisher_impl.h
index 1817ab1f..d15e4dc9 100644
--- a/osp/impl/service_publisher_impl.h
+++ b/osp/impl/service_publisher_impl.h
@@ -18,7 +18,6 @@ class ServicePublisherImpl final : public ServicePublisher,
class Delegate {
public:
Delegate();
- virtual ~Delegate();
void SetPublisherImpl(ServicePublisherImpl* publisher);
@@ -29,6 +28,8 @@ class ServicePublisherImpl final : public ServicePublisher,
virtual void ResumePublisher() = 0;
protected:
+ virtual ~Delegate();
+
void SetState(State state) { publisher_->SetState(state); }
ServicePublisherImpl* publisher_ = nullptr;
diff --git a/osp/public/presentation/presentation_connection.h b/osp/public/presentation/presentation_connection.h
index ee0cff1b..4ea37ce7 100644
--- a/osp/public/presentation/presentation_connection.h
+++ b/osp/public/presentation/presentation_connection.h
@@ -62,7 +62,6 @@ class Connection {
class Delegate {
public:
Delegate() = default;
- virtual ~Delegate() = default;
// State changes.
virtual void OnConnected() = 0;
@@ -85,6 +84,9 @@ class Connection {
// A binary message was received.
virtual void OnBinaryMessage(const std::vector<uint8_t>& data) = 0;
+ protected:
+ virtual ~Delegate() = default;
+
private:
OSP_DISALLOW_COPY_AND_ASSIGN(Delegate);
};
diff --git a/osp/public/request_response_handler.h b/osp/public/request_response_handler.h
index de783efc..0ae97f88 100644
--- a/osp/public/request_response_handler.h
+++ b/osp/public/request_response_handler.h
@@ -59,12 +59,14 @@ class RequestResponseHandler : public MessageDemuxer::MessageCallback {
public:
class Delegate {
public:
- virtual ~Delegate() = default;
virtual void OnMatchedResponse(RequestT* request,
typename RequestT::ResponseMsgType* response,
uint64_t endpoint_id) = 0;
virtual void OnError(RequestT* request, Error error) = 0;
+
+ protected:
+ virtual ~Delegate() = default;
};
explicit RequestResponseHandler(Delegate* delegate) : delegate_(delegate) {}
diff --git a/platform/api/tls_connection.cc b/platform/api/tls_connection.cc
index 9668c114..12fdc5cd 100644
--- a/platform/api/tls_connection.cc
+++ b/platform/api/tls_connection.cc
@@ -9,4 +9,6 @@ namespace openscreen {
TlsConnection::TlsConnection() = default;
TlsConnection::~TlsConnection() = default;
+TlsConnection::Client::~Client() = default;
+
} // namespace openscreen
diff --git a/platform/api/tls_connection.h b/platform/api/tls_connection.h
index 3da1e7e6..1f47bce6 100644
--- a/platform/api/tls_connection.h
+++ b/platform/api/tls_connection.h
@@ -26,7 +26,7 @@ class TlsConnection {
std::vector<uint8_t> block) = 0;
protected:
- virtual ~Client() = default;
+ virtual ~Client();
};
virtual ~TlsConnection();
diff --git a/platform/api/tls_connection_factory.cc b/platform/api/tls_connection_factory.cc
index e64078f1..c23c9e7e 100644
--- a/platform/api/tls_connection_factory.cc
+++ b/platform/api/tls_connection_factory.cc
@@ -9,4 +9,6 @@ namespace openscreen {
TlsConnectionFactory::TlsConnectionFactory() = default;
TlsConnectionFactory::~TlsConnectionFactory() = default;
+TlsConnectionFactory::Client::~Client() = default;
+
} // namespace openscreen
diff --git a/platform/api/tls_connection_factory.h b/platform/api/tls_connection_factory.h
index 80dc8ac6..b9d1e2f5 100644
--- a/platform/api/tls_connection_factory.h
+++ b/platform/api/tls_connection_factory.h
@@ -46,6 +46,9 @@ class TlsConnectionFactory {
// Called when a non-recoverable error occurs.
virtual void OnError(TlsConnectionFactory* factory, Error error) = 0;
+
+ protected:
+ virtual ~Client();
};
// The connection factory requires a client for yielding creation results
diff --git a/platform/api/udp_socket.cc b/platform/api/udp_socket.cc
index 47eba8bd..d895cf04 100644
--- a/platform/api/udp_socket.cc
+++ b/platform/api/udp_socket.cc
@@ -9,4 +9,6 @@ namespace openscreen {
UdpSocket::UdpSocket() = default;
UdpSocket::~UdpSocket() = default;
+UdpSocket::Client::~Client() = default;
+
} // namespace openscreen
diff --git a/platform/api/udp_socket.h b/platform/api/udp_socket.h
index 3baf4119..d77d95f9 100644
--- a/platform/api/udp_socket.h
+++ b/platform/api/udp_socket.h
@@ -30,7 +30,6 @@ class UdpSocket {
// Client for the UdpSocket class.
class Client {
public:
- virtual ~Client() = default;
// Method called when the UDP socket is bound. Default implementation
// does nothing, as clients may not care about the socket bind state.
@@ -49,6 +48,9 @@ class UdpSocket {
// Method called when a packet is read.
virtual void OnRead(UdpSocket* socket, ErrorOr<UdpPacket> packet) = 0;
+
+ protected:
+ virtual ~Client();
};
// Constants used to specify how we want packets sent from this socket.