From 14af7622a7ea040949bfcf56c2a1a042b3a085bb Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Wed, 12 Jan 2022 05:24:58 +0900 Subject: [PATCH] Remove RTC_DISALLOW_COPY_AND_ASSIGN from rtc_base/ Bug: webrtc:13555, webrtc:13082 Change-Id: I406b7f04497562866ea3329e97c5adc96e927b6f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245680 Reviewed-by: Harald Alvestrand Reviewed-by: Artem Titov Commit-Queue: (Daniel.L) Byoungchan Lee Cr-Commit-Position: refs/heads/main@{#35691} --- rtc_base/async_invoker.h | 6 ++-- rtc_base/async_packet_socket.h | 7 ++--- rtc_base/async_tcp_socket.h | 12 +++---- rtc_base/bit_buffer.h | 7 ++--- rtc_base/boringssl_certificate.h | 5 +-- rtc_base/boringssl_identity.h | 6 ++-- rtc_base/buffer_queue.h | 6 ++-- rtc_base/byte_buffer.h | 15 ++++----- .../deprecated/recursive_critical_section.h | 5 +-- rtc_base/file_rotating_stream.h | 12 ++++--- rtc_base/log_sinks.h | 12 ++++--- rtc_base/logging.h | 6 ++-- rtc_base/memory/fifo_buffer.h | 5 ++- rtc_base/message_handler.h | 8 ++--- rtc_base/nat_server.h | 5 +-- rtc_base/nat_socket_factory.h | 9 ++++-- rtc_base/numerics/moving_max_counter.h | 6 ++-- rtc_base/numerics/moving_median_filter.h | 6 ++-- .../numerics/percentile_filter_unittest.cc | 7 ++--- rtc_base/openssl_key_pair.h | 6 ++-- rtc_base/openssl_session_cache.h | 6 ++-- rtc_base/operations_chain.h | 11 ++++--- rtc_base/operations_chain_unittest.cc | 5 +-- rtc_base/proxy_server.h | 14 ++++++--- rtc_base/ref_counted_object.h | 6 ++-- rtc_base/ref_counted_object_unittest.cc | 4 +-- rtc_base/rolling_accumulator.h | 6 ++-- rtc_base/server_socket_adapters.h | 9 ++++-- rtc_base/sigslot_tester.h | 31 +++++++++++-------- rtc_base/socket.h | 7 ++--- rtc_base/socket_adapters.h | 17 +++++++--- rtc_base/socket_stream.h | 6 ++-- rtc_base/ssl_certificate.h | 7 +++-- rtc_base/stream.h | 7 ++--- rtc_base/task_queue.h | 6 ++-- rtc_base/test_client.h | 5 +-- rtc_base/test_echo_server.h | 5 +-- rtc_base/thread.cc | 10 +++--- rtc_base/thread.h | 25 ++++++++------- rtc_base/thread_unittest.cc | 5 ++- rtc_base/timestamp_aligner.h | 5 +-- rtc_base/virtual_socket_server.h | 5 +-- rtc_tools/sanitizers_unittest.cc | 1 + 43 files changed, 203 insertions(+), 151 deletions(-) diff --git a/rtc_base/async_invoker.h b/rtc_base/async_invoker.h index e5a3c15cac..c1f2060134 100644 --- a/rtc_base/async_invoker.h +++ b/rtc_base/async_invoker.h @@ -18,7 +18,6 @@ #include "absl/base/attributes.h" #include "api/scoped_refptr.h" #include "rtc_base/async_invoker_inl.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/event.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -94,6 +93,9 @@ class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup { DEPRECATED_AsyncInvoker(); ~DEPRECATED_AsyncInvoker() override; + DEPRECATED_AsyncInvoker(const DEPRECATED_AsyncInvoker&) = delete; + DEPRECATED_AsyncInvoker& operator=(const DEPRECATED_AsyncInvoker&) = delete; + // Call `functor` asynchronously on `thread`, with no callback upon // completion. Returns immediately. template @@ -159,8 +161,6 @@ class DEPRECATED_AsyncInvoker : public MessageHandlerAutoCleanup { std::atomic destroying_; friend class AsyncClosure; - - RTC_DISALLOW_COPY_AND_ASSIGN(DEPRECATED_AsyncInvoker); }; } // namespace rtc diff --git a/rtc_base/async_packet_socket.h b/rtc_base/async_packet_socket.h index b5fcf8edb7..2e334ec36d 100644 --- a/rtc_base/async_packet_socket.h +++ b/rtc_base/async_packet_socket.h @@ -13,7 +13,6 @@ #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/dscp.h" #include "rtc_base/network/sent_packet.h" #include "rtc_base/socket.h" @@ -69,6 +68,9 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> { AsyncPacketSocket(); ~AsyncPacketSocket() override; + AsyncPacketSocket(const AsyncPacketSocket&) = delete; + AsyncPacketSocket& operator=(const AsyncPacketSocket&) = delete; + // Returns current local address. Address may be set to null if the // socket is not bound yet (GetState() returns STATE_BINDING). virtual SocketAddress GetLocalAddress() const = 0; @@ -127,9 +129,6 @@ class RTC_EXPORT AsyncPacketSocket : public sigslot::has_slots<> { // Emitted for client TCP sockets when state is changed from // CONNECTED to CLOSED. sigslot::signal2 SignalClose; - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncPacketSocket); }; // Listen socket, producing an AsyncPacketSocket when a peer connects. diff --git a/rtc_base/async_tcp_socket.h b/rtc_base/async_tcp_socket.h index ca61b54d78..541080fba7 100644 --- a/rtc_base/async_tcp_socket.h +++ b/rtc_base/async_tcp_socket.h @@ -17,7 +17,6 @@ #include "rtc_base/async_packet_socket.h" #include "rtc_base/buffer.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" @@ -31,6 +30,9 @@ class AsyncTCPSocketBase : public AsyncPacketSocket { AsyncTCPSocketBase(Socket* socket, size_t max_packet_size); ~AsyncTCPSocketBase() override; + AsyncTCPSocketBase(const AsyncTCPSocketBase&) = delete; + AsyncTCPSocketBase& operator=(const AsyncTCPSocketBase&) = delete; + // Pure virtual methods to send and recv data. int Send(const void* pv, size_t cb, @@ -78,8 +80,6 @@ class AsyncTCPSocketBase : public AsyncPacketSocket { Buffer outbuf_; size_t max_insize_; size_t max_outsize_; - - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocketBase); }; class AsyncTCPSocket : public AsyncTCPSocketBase { @@ -93,13 +93,13 @@ class AsyncTCPSocket : public AsyncTCPSocketBase { explicit AsyncTCPSocket(Socket* socket); ~AsyncTCPSocket() override {} + AsyncTCPSocket(const AsyncTCPSocket&) = delete; + AsyncTCPSocket& operator=(const AsyncTCPSocket&) = delete; + int Send(const void* pv, size_t cb, const rtc::PacketOptions& options) override; void ProcessInput(char* data, size_t* len) override; - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocket); }; class AsyncTcpListenSocket : public AsyncListenSocket { diff --git a/rtc_base/bit_buffer.h b/rtc_base/bit_buffer.h index 5375550608..b4991bc724 100644 --- a/rtc_base/bit_buffer.h +++ b/rtc_base/bit_buffer.h @@ -14,8 +14,6 @@ #include // For size_t. #include // For integer types. -#include "rtc_base/constructor_magic.h" - namespace rtc { // A BitBuffer API for write operations. Supports symmetric write APIs to the @@ -27,6 +25,9 @@ class BitBufferWriter { // Constructs a bit buffer for the writable buffer of `bytes`. BitBufferWriter(uint8_t* bytes, size_t byte_count); + BitBufferWriter(const BitBufferWriter&) = delete; + BitBufferWriter& operator=(const BitBufferWriter&) = delete; + // Gets the current offset, in bytes/bits, from the start of the buffer. The // bit offset is the offset into the current byte, in the range [0,7]. void GetCurrentOffset(size_t* out_byte_offset, size_t* out_bit_offset); @@ -80,8 +81,6 @@ class BitBufferWriter { size_t byte_offset_; // The current offset, in bits, into the current byte. size_t bit_offset_; - - RTC_DISALLOW_COPY_AND_ASSIGN(BitBufferWriter); }; } // namespace rtc diff --git a/rtc_base/boringssl_certificate.h b/rtc_base/boringssl_certificate.h index 40a4bd8f38..8b4577a17c 100644 --- a/rtc_base/boringssl_certificate.h +++ b/rtc_base/boringssl_certificate.h @@ -19,7 +19,6 @@ #include #include "rtc_base/buffer.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" @@ -43,6 +42,9 @@ class BoringSSLCertificate final : public SSLCertificate { ~BoringSSLCertificate() override; + BoringSSLCertificate(const BoringSSLCertificate&) = delete; + BoringSSLCertificate& operator=(const BoringSSLCertificate&) = delete; + std::unique_ptr Clone() const override; CRYPTO_BUFFER* cert_buffer() const { return cert_buffer_.get(); } @@ -72,7 +74,6 @@ class BoringSSLCertificate final : public SSLCertificate { private: // A handle to the DER encoded certificate data. bssl::UniquePtr cert_buffer_; - RTC_DISALLOW_COPY_AND_ASSIGN(BoringSSLCertificate); }; } // namespace rtc diff --git a/rtc_base/boringssl_identity.h b/rtc_base/boringssl_identity.h index 71b29b486d..e322afaba0 100644 --- a/rtc_base/boringssl_identity.h +++ b/rtc_base/boringssl_identity.h @@ -18,7 +18,6 @@ #include #include "rtc_base/boringssl_certificate.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/openssl_key_pair.h" #include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_identity.h" @@ -44,6 +43,9 @@ class BoringSSLIdentity final : public SSLIdentity { const std::string& certificate_chain); ~BoringSSLIdentity() override; + BoringSSLIdentity(const BoringSSLIdentity&) = delete; + BoringSSLIdentity& operator=(const BoringSSLIdentity&) = delete; + const BoringSSLCertificate& certificate() const override; const SSLCertChain& cert_chain() const override; @@ -67,8 +69,6 @@ class BoringSSLIdentity final : public SSLIdentity { std::unique_ptr key_pair_; std::unique_ptr cert_chain_; - - RTC_DISALLOW_COPY_AND_ASSIGN(BoringSSLIdentity); }; } // namespace rtc diff --git a/rtc_base/buffer_queue.h b/rtc_base/buffer_queue.h index ee435f4694..b018e160a1 100644 --- a/rtc_base/buffer_queue.h +++ b/rtc_base/buffer_queue.h @@ -18,7 +18,6 @@ #include "api/sequence_checker.h" #include "rtc_base/buffer.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/no_unique_address.h" #include "rtc_base/thread_annotations.h" @@ -30,6 +29,9 @@ class BufferQueue final { BufferQueue(size_t capacity, size_t default_size); ~BufferQueue(); + BufferQueue(const BufferQueue&) = delete; + BufferQueue& operator=(const BufferQueue&) = delete; + // Return number of queued buffers. size_t size() const; @@ -61,8 +63,6 @@ class BufferQueue final { const size_t default_size_; std::deque queue_ RTC_GUARDED_BY(sequence_checker_); std::vector free_list_ RTC_GUARDED_BY(sequence_checker_); - - RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue); }; } // namespace rtc diff --git a/rtc_base/byte_buffer.h b/rtc_base/byte_buffer.h index fc383f0a33..d2dda3c8e1 100644 --- a/rtc_base/byte_buffer.h +++ b/rtc_base/byte_buffer.h @@ -18,7 +18,6 @@ #include "rtc_base/buffer.h" #include "rtc_base/byte_order.h" -#include "rtc_base/constructor_magic.h" // Reads/Writes from/to buffer using network byte order (big endian) namespace rtc { @@ -29,6 +28,9 @@ class ByteBufferWriterT { ByteBufferWriterT() { Construct(nullptr, kDefaultCapacity); } ByteBufferWriterT(const char* bytes, size_t len) { Construct(bytes, len); } + ByteBufferWriterT(const ByteBufferWriterT&) = delete; + ByteBufferWriterT& operator=(const ByteBufferWriterT&) = delete; + const char* Data() const { return buffer_.data(); } size_t Length() const { return buffer_.size(); } size_t Capacity() const { return buffer_.capacity(); } @@ -104,7 +106,6 @@ class ByteBufferWriterT { // There are sensible ways to define these, but they aren't needed in our code // base. - RTC_DISALLOW_COPY_AND_ASSIGN(ByteBufferWriterT); }; class ByteBufferWriter : public ByteBufferWriterT> { @@ -112,8 +113,8 @@ class ByteBufferWriter : public ByteBufferWriterT> { ByteBufferWriter(); ByteBufferWriter(const char* bytes, size_t len); - private: - RTC_DISALLOW_COPY_AND_ASSIGN(ByteBufferWriter); + ByteBufferWriter(const ByteBufferWriter&) = delete; + ByteBufferWriter& operator=(const ByteBufferWriter&) = delete; }; // The ByteBufferReader references the passed data, i.e. the pointer must be @@ -129,6 +130,9 @@ class ByteBufferReader { explicit ByteBufferReader(const ByteBufferWriter& buf); + ByteBufferReader(const ByteBufferReader&) = delete; + ByteBufferReader& operator=(const ByteBufferReader&) = delete; + // Returns start of unprocessed data. const char* Data() const { return bytes_ + start_; } // Returns number of unprocessed bytes. @@ -161,9 +165,6 @@ class ByteBufferReader { size_t size_; size_t start_; size_t end_; - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(ByteBufferReader); }; } // namespace rtc diff --git a/rtc_base/deprecated/recursive_critical_section.h b/rtc_base/deprecated/recursive_critical_section.h index 15b1f97e9f..cc308e45b7 100644 --- a/rtc_base/deprecated/recursive_critical_section.h +++ b/rtc_base/deprecated/recursive_critical_section.h @@ -11,7 +11,6 @@ #ifndef RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ #define RTC_BASE_DEPRECATED_RECURSIVE_CRITICAL_SECTION_H_ -#include "rtc_base/constructor_magic.h" #include "rtc_base/platform_thread_types.h" #include "rtc_base/thread_annotations.h" @@ -94,9 +93,11 @@ class RTC_SCOPED_LOCKABLE CritScope { RTC_EXCLUSIVE_LOCK_FUNCTION(cs); ~CritScope() RTC_UNLOCK_FUNCTION(); + CritScope(const CritScope&) = delete; + CritScope& operator=(const CritScope&) = delete; + private: const RecursiveCriticalSection* const cs_; - RTC_DISALLOW_COPY_AND_ASSIGN(CritScope); }; } // namespace rtc diff --git a/rtc_base/file_rotating_stream.h b/rtc_base/file_rotating_stream.h index beb47c83da..6aaa0bd783 100644 --- a/rtc_base/file_rotating_stream.h +++ b/rtc_base/file_rotating_stream.h @@ -17,7 +17,6 @@ #include #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/file_wrapper.h" namespace rtc { @@ -37,6 +36,9 @@ class FileRotatingStream { virtual ~FileRotatingStream(); + FileRotatingStream(const FileRotatingStream&) = delete; + FileRotatingStream& operator=(const FileRotatingStream&) = delete; + bool IsOpen() const; bool Write(const void* data, size_t data_len); @@ -100,8 +102,6 @@ class FileRotatingStream { // buffering the file size read from disk might not be accurate. size_t current_bytes_written_; bool disable_buffering_; - - RTC_DISALLOW_COPY_AND_ASSIGN(FileRotatingStream); }; // CallSessionFileRotatingStream is meant to be used in situations where we will @@ -130,6 +130,10 @@ class CallSessionFileRotatingStream : public FileRotatingStream { size_t max_total_log_size); ~CallSessionFileRotatingStream() override {} + CallSessionFileRotatingStream(const CallSessionFileRotatingStream&) = delete; + CallSessionFileRotatingStream& operator=( + const CallSessionFileRotatingStream&) = delete; + protected: void OnRotation() override; @@ -140,8 +144,6 @@ class CallSessionFileRotatingStream : public FileRotatingStream { const size_t max_total_log_size_; size_t num_rotations_; - - RTC_DISALLOW_COPY_AND_ASSIGN(CallSessionFileRotatingStream); }; // This is a convenience class, to read all files produced by a diff --git a/rtc_base/log_sinks.h b/rtc_base/log_sinks.h index 87bec6dba8..d2c286a86a 100644 --- a/rtc_base/log_sinks.h +++ b/rtc_base/log_sinks.h @@ -16,7 +16,6 @@ #include #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/file_rotating_stream.h" #include "rtc_base/logging.h" @@ -34,6 +33,9 @@ class FileRotatingLogSink : public LogSink { size_t num_log_files); ~FileRotatingLogSink() override; + FileRotatingLogSink(const FileRotatingLogSink&) = delete; + FileRotatingLogSink& operator=(const FileRotatingLogSink&) = delete; + // Writes the message to the current file. It will spill over to the next // file if needed. void OnLogMessage(const std::string& message) override; @@ -52,8 +54,6 @@ class FileRotatingLogSink : public LogSink { private: std::unique_ptr stream_; - - RTC_DISALLOW_COPY_AND_ASSIGN(FileRotatingLogSink); }; // Log sink that uses a CallSessionFileRotatingStream to write to disk. @@ -64,8 +64,10 @@ class CallSessionFileRotatingLogSink : public FileRotatingLogSink { size_t max_total_log_size); ~CallSessionFileRotatingLogSink() override; - private: - RTC_DISALLOW_COPY_AND_ASSIGN(CallSessionFileRotatingLogSink); + CallSessionFileRotatingLogSink(const CallSessionFileRotatingLogSink&) = + delete; + CallSessionFileRotatingLogSink& operator=( + const CallSessionFileRotatingLogSink&) = delete; }; } // namespace rtc diff --git a/rtc_base/logging.h b/rtc_base/logging.h index 3ac12d7e6f..b981357aae 100644 --- a/rtc_base/logging.h +++ b/rtc_base/logging.h @@ -54,7 +54,6 @@ #include "absl/base/attributes.h" #include "absl/meta/type_traits.h" #include "absl/strings/string_view.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/strings/string_builder.h" #include "rtc_base/system/inline.h" @@ -443,6 +442,9 @@ class LogMessage { const std::string& tag); ~LogMessage(); + LogMessage(const LogMessage&) = delete; + LogMessage& operator=(const LogMessage&) = delete; + void AddTag(const char* tag); rtc::StringBuilder& stream(); // Returns the time at which this function was called for the first time. @@ -602,8 +604,6 @@ class LogMessage { // The stringbuilder that buffers the formatted message before output rtc::StringBuilder print_stream_; - - RTC_DISALLOW_COPY_AND_ASSIGN(LogMessage); }; ////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/memory/fifo_buffer.h b/rtc_base/memory/fifo_buffer.h index 0bc943ac36..e3d29f4b60 100644 --- a/rtc_base/memory/fifo_buffer.h +++ b/rtc_base/memory/fifo_buffer.h @@ -29,6 +29,10 @@ class FifoBuffer final : public StreamInterface { // Creates a FIFO buffer with the specified capacity and owner FifoBuffer(size_t length, Thread* owner); ~FifoBuffer() override; + + FifoBuffer(const FifoBuffer&) = delete; + FifoBuffer& operator=(const FifoBuffer&) = delete; + // Gets the amount of data currently readable from the buffer. bool GetBuffered(size_t* data_len) const; @@ -110,7 +114,6 @@ class FifoBuffer final : public StreamInterface { Thread* const owner_; // object lock mutable webrtc::Mutex mutex_; - RTC_DISALLOW_COPY_AND_ASSIGN(FifoBuffer); }; } // namespace rtc diff --git a/rtc_base/message_handler.h b/rtc_base/message_handler.h index 62c8344e1f..c5e05cad68 100644 --- a/rtc_base/message_handler.h +++ b/rtc_base/message_handler.h @@ -14,7 +14,6 @@ #include #include "api/function_view.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -37,11 +36,12 @@ class RTC_EXPORT MessageHandlerAutoCleanup : public MessageHandler { public: ~MessageHandlerAutoCleanup() override; + MessageHandlerAutoCleanup(const MessageHandlerAutoCleanup&) = delete; + MessageHandlerAutoCleanup& operator=(const MessageHandlerAutoCleanup&) = + delete; + protected: MessageHandlerAutoCleanup(); - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(MessageHandlerAutoCleanup); }; } // namespace rtc diff --git a/rtc_base/nat_server.h b/rtc_base/nat_server.h index 5078fbb2c1..acbd62a092 100644 --- a/rtc_base/nat_server.h +++ b/rtc_base/nat_server.h @@ -15,7 +15,6 @@ #include #include "rtc_base/async_udp_socket.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/nat_types.h" #include "rtc_base/proxy_server.h" #include "rtc_base/socket_address_pair.h" @@ -69,6 +68,9 @@ class NATServer : public sigslot::has_slots<> { const SocketAddress& external_ip); ~NATServer() override; + NATServer(const NATServer&) = delete; + NATServer& operator=(const NATServer&) = delete; + SocketAddress internal_udp_address() const { return udp_server_socket_->GetLocalAddress(); } @@ -122,7 +124,6 @@ class NATServer : public sigslot::has_slots<> { ProxyServer* tcp_proxy_server_; InternalMap* int_map_; ExternalMap* ext_map_; - RTC_DISALLOW_COPY_AND_ASSIGN(NATServer); }; } // namespace rtc diff --git a/rtc_base/nat_socket_factory.h b/rtc_base/nat_socket_factory.h index 9b1d2f09e3..70cb303def 100644 --- a/rtc_base/nat_socket_factory.h +++ b/rtc_base/nat_socket_factory.h @@ -17,7 +17,6 @@ #include #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/nat_server.h" #include "rtc_base/nat_types.h" #include "rtc_base/socket.h" @@ -50,6 +49,9 @@ class NATSocketFactory : public SocketFactory, public NATInternalSocketFactory { const SocketAddress& nat_udp_addr, const SocketAddress& nat_tcp_addr); + NATSocketFactory(const NATSocketFactory&) = delete; + NATSocketFactory& operator=(const NATSocketFactory&) = delete; + // SocketFactory implementation Socket* CreateSocket(int family, int type) override; @@ -63,7 +65,6 @@ class NATSocketFactory : public SocketFactory, public NATInternalSocketFactory { SocketFactory* factory_; SocketAddress nat_udp_addr_; SocketAddress nat_tcp_addr_; - RTC_DISALLOW_COPY_AND_ASSIGN(NATSocketFactory); }; // Creates sockets that will send traffic through a NAT depending on what @@ -135,6 +136,9 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { explicit NATSocketServer(SocketServer* ss); + NATSocketServer(const NATSocketServer&) = delete; + NATSocketServer& operator=(const NATSocketServer&) = delete; + SocketServer* socketserver() { return server_; } Thread* queue() { return msg_queue_; } @@ -161,7 +165,6 @@ class NATSocketServer : public SocketServer, public NATInternalSocketFactory { SocketServer* server_; Thread* msg_queue_; TranslatorMap nats_; - RTC_DISALLOW_COPY_AND_ASSIGN(NATSocketServer); }; // Free-standing NAT helper functions. diff --git a/rtc_base/numerics/moving_max_counter.h b/rtc_base/numerics/moving_max_counter.h index 26dd506d63..5eb45d392b 100644 --- a/rtc_base/numerics/moving_max_counter.h +++ b/rtc_base/numerics/moving_max_counter.h @@ -19,7 +19,6 @@ #include "absl/types/optional.h" #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" namespace rtc { @@ -34,6 +33,10 @@ template class MovingMaxCounter { public: explicit MovingMaxCounter(int64_t window_length_ms); + + MovingMaxCounter(const MovingMaxCounter&) = delete; + MovingMaxCounter& operator=(const MovingMaxCounter&) = delete; + // Advances the current time, and adds a new sample. The new current time must // be at least as large as the old current time. void Add(const T& sample, int64_t current_time_ms); @@ -57,7 +60,6 @@ class MovingMaxCounter { #if RTC_DCHECK_IS_ON int64_t last_call_time_ms_ = std::numeric_limits::min(); #endif - RTC_DISALLOW_COPY_AND_ASSIGN(MovingMaxCounter); }; template diff --git a/rtc_base/numerics/moving_median_filter.h b/rtc_base/numerics/moving_median_filter.h index 157eb152c3..2a8ea7d62a 100644 --- a/rtc_base/numerics/moving_median_filter.h +++ b/rtc_base/numerics/moving_median_filter.h @@ -17,7 +17,6 @@ #include #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/numerics/percentile_filter.h" namespace webrtc { @@ -30,6 +29,9 @@ class MovingMedianFilter { // used to take median. `window_size` must be positive. explicit MovingMedianFilter(size_t window_size); + MovingMedianFilter(const MovingMedianFilter&) = delete; + MovingMedianFilter& operator=(const MovingMedianFilter&) = delete; + // Insert a new sample. void Insert(const T& value); @@ -47,8 +49,6 @@ class MovingMedianFilter { std::list samples_; size_t samples_stored_; const size_t window_size_; - - RTC_DISALLOW_COPY_AND_ASSIGN(MovingMedianFilter); }; template diff --git a/rtc_base/numerics/percentile_filter_unittest.cc b/rtc_base/numerics/percentile_filter_unittest.cc index 0de8be5609..d6baa32001 100644 --- a/rtc_base/numerics/percentile_filter_unittest.cc +++ b/rtc_base/numerics/percentile_filter_unittest.cc @@ -18,7 +18,6 @@ #include #include "absl/algorithm/container.h" -#include "rtc_base/constructor_magic.h" #include "test/gtest.h" namespace webrtc { @@ -30,11 +29,11 @@ class PercentileFilterTest : public ::testing::TestWithParam { srand(42); } + PercentileFilterTest(const PercentileFilterTest&) = delete; + PercentileFilterTest& operator=(const PercentileFilterTest&) = delete; + protected: PercentileFilter filter_; - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(PercentileFilterTest); }; INSTANTIATE_TEST_SUITE_P(PercentileFilterTests, diff --git a/rtc_base/openssl_key_pair.h b/rtc_base/openssl_key_pair.h index a84c43b6bd..d9a4939a7e 100644 --- a/rtc_base/openssl_key_pair.h +++ b/rtc_base/openssl_key_pair.h @@ -17,7 +17,6 @@ #include #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/ssl_identity.h" namespace rtc { @@ -39,6 +38,9 @@ class OpenSSLKeyPair final { ~OpenSSLKeyPair(); + OpenSSLKeyPair(const OpenSSLKeyPair&) = delete; + OpenSSLKeyPair& operator=(const OpenSSLKeyPair&) = delete; + std::unique_ptr Clone(); EVP_PKEY* pkey() const { return pkey_; } @@ -51,8 +53,6 @@ class OpenSSLKeyPair final { void AddReference(); EVP_PKEY* pkey_; - - RTC_DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyPair); }; } // namespace rtc diff --git a/rtc_base/openssl_session_cache.h b/rtc_base/openssl_session_cache.h index b049e64dd6..b801ec7b0b 100644 --- a/rtc_base/openssl_session_cache.h +++ b/rtc_base/openssl_session_cache.h @@ -16,7 +16,6 @@ #include #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/ssl_stream_adapter.h" #ifndef OPENSSL_IS_BORINGSSL @@ -36,6 +35,10 @@ class OpenSSLSessionCache final { OpenSSLSessionCache(SSLMode ssl_mode, SSL_CTX* ssl_ctx); // Frees the cached SSL_SESSIONS and then frees the SSL_CTX. ~OpenSSLSessionCache(); + + OpenSSLSessionCache(const OpenSSLSessionCache&) = delete; + OpenSSLSessionCache& operator=(const OpenSSLSessionCache&) = delete; + // Looks up a session by hostname. The returned SSL_SESSION is not up_refed. SSL_SESSION* LookupSession(const std::string& hostname) const; // Adds a session to the cache, and up_refs it. Any existing session with the @@ -60,7 +63,6 @@ class OpenSSLSessionCache final { // TODO(juberti): Add LRU eviction to keep the cache from growing forever. std::map sessions_; // The cache should never be copied or assigned directly. - RTC_DISALLOW_COPY_AND_ASSIGN(OpenSSLSessionCache); }; } // namespace rtc diff --git a/rtc_base/operations_chain.h b/rtc_base/operations_chain.h index e6fb4f99d3..0e8c0681ba 100644 --- a/rtc_base/operations_chain.h +++ b/rtc_base/operations_chain.h @@ -23,7 +23,6 @@ #include "api/scoped_refptr.h" #include "api/sequence_checker.h" #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/ref_count.h" #include "rtc_base/ref_counted_object.h" #include "rtc_base/system/no_unique_address.h" @@ -119,6 +118,9 @@ class OperationsChain final : public RefCountedNonVirtual { static scoped_refptr Create(); ~OperationsChain(); + OperationsChain(const OperationsChain&) = delete; + OperationsChain& operator=(const OperationsChain&) = delete; + void SetOnChainEmptyCallback(std::function on_chain_empty_callback); bool IsEmpty() const; @@ -169,6 +171,9 @@ class OperationsChain final : public RefCountedNonVirtual { explicit CallbackHandle(scoped_refptr operations_chain); ~CallbackHandle(); + CallbackHandle(const CallbackHandle&) = delete; + CallbackHandle& operator=(const CallbackHandle&) = delete; + void OnOperationComplete(); private: @@ -176,8 +181,6 @@ class OperationsChain final : public RefCountedNonVirtual { #if RTC_DCHECK_IS_ON bool has_run_ = false; #endif // RTC_DCHECK_IS_ON - - RTC_DISALLOW_COPY_AND_ASSIGN(CallbackHandle); }; OperationsChain(); @@ -193,8 +196,6 @@ class OperationsChain final : public RefCountedNonVirtual { chained_operations_ RTC_GUARDED_BY(sequence_checker_); absl::optional> on_chain_empty_callback_ RTC_GUARDED_BY(sequence_checker_); - - RTC_DISALLOW_COPY_AND_ASSIGN(OperationsChain); }; } // namespace rtc diff --git a/rtc_base/operations_chain_unittest.cc b/rtc_base/operations_chain_unittest.cc index f99c05e0db..a66df5bb7a 100644 --- a/rtc_base/operations_chain_unittest.cc +++ b/rtc_base/operations_chain_unittest.cc @@ -219,6 +219,9 @@ class SignalOnDestruction final { } } + SignalOnDestruction(const SignalOnDestruction&) = delete; + SignalOnDestruction& operator=(const SignalOnDestruction&) = delete; + // Move operators. SignalOnDestruction(SignalOnDestruction&& other) : SignalOnDestruction(other.destructor_called_) { @@ -232,8 +235,6 @@ class SignalOnDestruction final { private: bool* destructor_called_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SignalOnDestruction); }; TEST(OperationsChainTest, SynchronousOperation) { diff --git a/rtc_base/proxy_server.h b/rtc_base/proxy_server.h index 6db0e12897..0b9b655a5e 100644 --- a/rtc_base/proxy_server.h +++ b/rtc_base/proxy_server.h @@ -15,7 +15,6 @@ #include #include "absl/memory/memory.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/memory/fifo_buffer.h" #include "rtc_base/server_socket_adapters.h" #include "rtc_base/socket.h" @@ -36,6 +35,10 @@ class ProxyBinding : public sigslot::has_slots<> { public: ProxyBinding(AsyncProxyServerSocket* in_socket, Socket* out_socket); ~ProxyBinding() override; + + ProxyBinding(const ProxyBinding&) = delete; + ProxyBinding& operator=(const ProxyBinding&) = delete; + sigslot::signal1 SignalDestroyed; private: @@ -59,7 +62,6 @@ class ProxyBinding : public sigslot::has_slots<> { bool connected_; FifoBuffer out_buffer_; FifoBuffer in_buffer_; - RTC_DISALLOW_COPY_AND_ASSIGN(ProxyBinding); }; class ProxyServer : public sigslot::has_slots<> { @@ -70,6 +72,9 @@ class ProxyServer : public sigslot::has_slots<> { const SocketAddress& ext_ip); ~ProxyServer() override; + ProxyServer(const ProxyServer&) = delete; + ProxyServer& operator=(const ProxyServer&) = delete; + // Returns the address to which the proxy server is bound SocketAddress GetServerAddress(); @@ -82,7 +87,6 @@ class ProxyServer : public sigslot::has_slots<> { SocketAddress ext_ip_; std::unique_ptr server_socket_; std::vector> bindings_; - RTC_DISALLOW_COPY_AND_ASSIGN(ProxyServer); }; // SocksProxyServer is a simple extension of ProxyServer to implement SOCKS. @@ -94,9 +98,11 @@ class SocksProxyServer : public ProxyServer { const SocketAddress& ext_ip) : ProxyServer(int_factory, int_addr, ext_factory, ext_ip) {} + SocksProxyServer(const SocksProxyServer&) = delete; + SocksProxyServer& operator=(const SocksProxyServer&) = delete; + protected: AsyncProxyServerSocket* WrapSocket(Socket* socket) override; - RTC_DISALLOW_COPY_AND_ASSIGN(SocksProxyServer); }; } // namespace rtc diff --git a/rtc_base/ref_counted_object.h b/rtc_base/ref_counted_object.h index 274eb9e76d..54aac952ce 100644 --- a/rtc_base/ref_counted_object.h +++ b/rtc_base/ref_counted_object.h @@ -14,7 +14,6 @@ #include #include "api/scoped_refptr.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/ref_count.h" #include "rtc_base/ref_counter.h" @@ -42,6 +41,9 @@ class RefCountedObject : public T { public: RefCountedObject() {} + RefCountedObject(const RefCountedObject&) = delete; + RefCountedObject& operator=(const RefCountedObject&) = delete; + template explicit RefCountedObject(P0&& p0) : T(std::forward(p0)) {} @@ -73,8 +75,6 @@ class RefCountedObject : public T { ~RefCountedObject() override {} mutable webrtc::webrtc_impl::RefCounter ref_count_{0}; - - RTC_DISALLOW_COPY_AND_ASSIGN(RefCountedObject); }; template diff --git a/rtc_base/ref_counted_object_unittest.cc b/rtc_base/ref_counted_object_unittest.cc index ab7bb09191..6b794e63f9 100644 --- a/rtc_base/ref_counted_object_unittest.cc +++ b/rtc_base/ref_counted_object_unittest.cc @@ -27,8 +27,8 @@ class A { public: A() {} - private: - RTC_DISALLOW_COPY_AND_ASSIGN(A); + A(const A&) = delete; + A& operator=(const A&) = delete; }; class RefClass : public RefCountInterface { diff --git a/rtc_base/rolling_accumulator.h b/rtc_base/rolling_accumulator.h index 241bd72a11..84d791edd1 100644 --- a/rtc_base/rolling_accumulator.h +++ b/rtc_base/rolling_accumulator.h @@ -17,7 +17,6 @@ #include #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/numerics/running_statistics.h" namespace rtc { @@ -35,6 +34,9 @@ class RollingAccumulator { } ~RollingAccumulator() {} + RollingAccumulator(const RollingAccumulator&) = delete; + RollingAccumulator& operator=(const RollingAccumulator&) = delete; + size_t max_count() const { return samples_.size(); } size_t count() const { return static_cast(stats_.Size()); } @@ -136,8 +138,6 @@ class RollingAccumulator { mutable T min_; mutable bool min_stale_; std::vector samples_; - - RTC_DISALLOW_COPY_AND_ASSIGN(RollingAccumulator); }; } // namespace rtc diff --git a/rtc_base/server_socket_adapters.h b/rtc_base/server_socket_adapters.h index 07e9636756..b18c7a6a65 100644 --- a/rtc_base/server_socket_adapters.h +++ b/rtc_base/server_socket_adapters.h @@ -31,9 +31,11 @@ class AsyncSSLServerSocket : public BufferedReadAdapter { public: explicit AsyncSSLServerSocket(Socket* socket); + AsyncSSLServerSocket(const AsyncSSLServerSocket&) = delete; + AsyncSSLServerSocket& operator=(const AsyncSSLServerSocket&) = delete; + protected: void ProcessInput(char* data, size_t* len) override; - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSSLServerSocket); }; // Implements a proxy server socket for the SOCKS protocol. @@ -41,6 +43,10 @@ class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { public: explicit AsyncSocksProxyServerSocket(Socket* socket); + AsyncSocksProxyServerSocket(const AsyncSocksProxyServerSocket&) = delete; + AsyncSocksProxyServerSocket& operator=(const AsyncSocksProxyServerSocket&) = + delete; + private: void ProcessInput(char* data, size_t* len) override; void DirectSend(const ByteBufferWriter& buf); @@ -64,7 +70,6 @@ class AsyncSocksProxyServerSocket : public AsyncProxyServerSocket { SS_ERROR }; State state_; - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxyServerSocket); }; } // namespace rtc diff --git a/rtc_base/sigslot_tester.h b/rtc_base/sigslot_tester.h index 58be511ef6..92483c0b8d 100644 --- a/rtc_base/sigslot_tester.h +++ b/rtc_base/sigslot_tester.h @@ -38,7 +38,6 @@ // EXPECT_EQ("hello", capture); // /* See unit-tests for more examples */ -#include "rtc_base/constructor_magic.h" #include "rtc_base/third_party/sigslot/sigslot.h" namespace rtc { @@ -50,13 +49,14 @@ class SigslotTester0 : public sigslot::has_slots<> { signal->connect(this, &SigslotTester0::OnSignalCallback); } + SigslotTester0(const SigslotTester0&) = delete; + SigslotTester0& operator=(const SigslotTester0&) = delete; + int callback_count() const { return callback_count_; } private: void OnSignalCallback() { callback_count_++; } int callback_count_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester0); }; // Versions below are for testing signals that pass arguments. For all the @@ -74,6 +74,9 @@ class SigslotTester1 : public sigslot::has_slots<> { signal->connect(this, &SigslotTester1::OnSignalCallback); } + SigslotTester1(const SigslotTester1&) = delete; + SigslotTester1& operator=(const SigslotTester1&) = delete; + int callback_count() const { return callback_count_; } private: @@ -84,8 +87,6 @@ class SigslotTester1 : public sigslot::has_slots<> { int callback_count_; C1* capture1_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester1); }; template @@ -96,6 +97,9 @@ class SigslotTester2 : public sigslot::has_slots<> { signal->connect(this, &SigslotTester2::OnSignalCallback); } + SigslotTester2(const SigslotTester2&) = delete; + SigslotTester2& operator=(const SigslotTester2&) = delete; + int callback_count() const { return callback_count_; } private: @@ -108,8 +112,6 @@ class SigslotTester2 : public sigslot::has_slots<> { int callback_count_; C1* capture1_; C2* capture2_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester2); }; template @@ -126,6 +128,9 @@ class SigslotTester3 : public sigslot::has_slots<> { signal->connect(this, &SigslotTester3::OnSignalCallback); } + SigslotTester3(const SigslotTester3&) = delete; + SigslotTester3& operator=(const SigslotTester3&) = delete; + int callback_count() const { return callback_count_; } private: @@ -140,8 +145,6 @@ class SigslotTester3 : public sigslot::has_slots<> { C1* capture1_; C2* capture2_; C3* capture3_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester3); }; template { signal->connect(this, &SigslotTester4::OnSignalCallback); } + SigslotTester4(const SigslotTester4&) = delete; + SigslotTester4& operator=(const SigslotTester4&) = delete; + int callback_count() const { return callback_count_; } private: @@ -183,8 +189,6 @@ class SigslotTester4 : public sigslot::has_slots<> { C2* capture2_; C3* capture3_; C4* capture4_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester4); }; template { signal->connect(this, &SigslotTester5::OnSignalCallback); } + SigslotTester5(const SigslotTester5&) = delete; + SigslotTester5& operator=(const SigslotTester5&) = delete; + int callback_count() const { return callback_count_; } private: @@ -232,8 +239,6 @@ class SigslotTester5 : public sigslot::has_slots<> { C3* capture3_; C4* capture4_; C5* capture5_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SigslotTester5); }; } // namespace rtc diff --git a/rtc_base/socket.h b/rtc_base/socket.h index 6482117637..0ed3a7fa6a 100644 --- a/rtc_base/socket.h +++ b/rtc_base/socket.h @@ -25,7 +25,6 @@ #include "rtc_base/win32.h" #endif -#include "rtc_base/constructor_magic.h" #include "rtc_base/socket_address.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -83,6 +82,9 @@ class Socket { public: virtual ~Socket() {} + Socket(const Socket&) = delete; + Socket& operator=(const Socket&) = delete; + // Returns the address to which the socket is bound. If the socket is not // bound, then the any-address is returned. virtual SocketAddress GetLocalAddress() const = 0; @@ -138,9 +140,6 @@ class Socket { protected: Socket() {} - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(Socket); }; } // namespace rtc diff --git a/rtc_base/socket_adapters.h b/rtc_base/socket_adapters.h index 67d3bbff7d..55f62115d3 100644 --- a/rtc_base/socket_adapters.h +++ b/rtc_base/socket_adapters.h @@ -15,7 +15,6 @@ #include "api/array_view.h" #include "rtc_base/async_socket.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/crypt_string.h" namespace rtc { @@ -34,6 +33,9 @@ class BufferedReadAdapter : public AsyncSocketAdapter { BufferedReadAdapter(Socket* socket, size_t buffer_size); ~BufferedReadAdapter() override; + BufferedReadAdapter(const BufferedReadAdapter&) = delete; + BufferedReadAdapter& operator=(const BufferedReadAdapter&) = delete; + int Send(const void* pv, size_t cb) override; int Recv(void* pv, size_t cb, int64_t* timestamp) override; @@ -51,7 +53,6 @@ class BufferedReadAdapter : public AsyncSocketAdapter { char* buffer_; size_t buffer_size_, data_len_; bool buffering_; - RTC_DISALLOW_COPY_AND_ASSIGN(BufferedReadAdapter); }; /////////////////////////////////////////////////////////////////////////////// @@ -65,12 +66,14 @@ class AsyncSSLSocket : public BufferedReadAdapter { explicit AsyncSSLSocket(Socket* socket); + AsyncSSLSocket(const AsyncSSLSocket&) = delete; + AsyncSSLSocket& operator=(const AsyncSSLSocket&) = delete; + int Connect(const SocketAddress& addr) override; protected: void OnConnectEvent(Socket* socket) override; void ProcessInput(char* data, size_t* len) override; - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSSLSocket); }; /////////////////////////////////////////////////////////////////////////////// @@ -85,6 +88,9 @@ class AsyncHttpsProxySocket : public BufferedReadAdapter { const CryptString& password); ~AsyncHttpsProxySocket() override; + AsyncHttpsProxySocket(const AsyncHttpsProxySocket&) = delete; + AsyncHttpsProxySocket& operator=(const AsyncHttpsProxySocket&) = delete; + // If connect is forced, the adapter will always issue an HTTP CONNECT to the // target address. Otherwise, it will connect only if the destination port // is not port 80. @@ -128,7 +134,6 @@ class AsyncHttpsProxySocket : public BufferedReadAdapter { } state_; HttpAuthContext* context_; std::string unknown_mechanisms_; - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncHttpsProxySocket); }; /////////////////////////////////////////////////////////////////////////////// @@ -142,6 +147,9 @@ class AsyncSocksProxySocket : public BufferedReadAdapter { const CryptString& password); ~AsyncSocksProxySocket() override; + AsyncSocksProxySocket(const AsyncSocksProxySocket&) = delete; + AsyncSocksProxySocket& operator=(const AsyncSocksProxySocket&) = delete; + int Connect(const SocketAddress& addr) override; SocketAddress GetRemoteAddress() const override; int Close() override; @@ -162,7 +170,6 @@ class AsyncSocksProxySocket : public BufferedReadAdapter { SocketAddress proxy_, dest_; std::string user_; CryptString pass_; - RTC_DISALLOW_COPY_AND_ASSIGN(AsyncSocksProxySocket); }; } // namespace rtc diff --git a/rtc_base/socket_stream.h b/rtc_base/socket_stream.h index 266a6e6fe6..f678f805d7 100644 --- a/rtc_base/socket_stream.h +++ b/rtc_base/socket_stream.h @@ -13,7 +13,6 @@ #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/socket.h" #include "rtc_base/stream.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -27,6 +26,9 @@ class SocketStream : public StreamInterface, public sigslot::has_slots<> { explicit SocketStream(Socket* socket); ~SocketStream() override; + SocketStream(const SocketStream&) = delete; + SocketStream& operator=(const SocketStream&) = delete; + void Attach(Socket* socket); Socket* Detach(); @@ -53,8 +55,6 @@ class SocketStream : public StreamInterface, public sigslot::has_slots<> { void OnCloseEvent(Socket* socket, int err); Socket* socket_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SocketStream); }; /////////////////////////////////////////////////////////////////////////////// diff --git a/rtc_base/ssl_certificate.h b/rtc_base/ssl_certificate.h index 3b3f24fb91..d0e60ee9cc 100644 --- a/rtc_base/ssl_certificate.h +++ b/rtc_base/ssl_certificate.h @@ -17,12 +17,12 @@ #include #include + #include #include #include #include "rtc_base/buffer.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -101,6 +101,9 @@ class RTC_EXPORT SSLCertChain final { ~SSLCertChain(); + SSLCertChain(const SSLCertChain&) = delete; + SSLCertChain& operator=(const SSLCertChain&) = delete; + // Vector access methods. size_t GetSize() const { return certs_.size(); } @@ -118,8 +121,6 @@ class RTC_EXPORT SSLCertChain final { private: std::vector> certs_; - - RTC_DISALLOW_COPY_AND_ASSIGN(SSLCertChain); }; // SSLCertificateVerifier provides a simple interface to allow third parties to diff --git a/rtc_base/stream.h b/rtc_base/stream.h index 70de65a75d..c0ceb4e36d 100644 --- a/rtc_base/stream.h +++ b/rtc_base/stream.h @@ -14,7 +14,6 @@ #include #include "rtc_base/buffer.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/message_handler.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -52,6 +51,9 @@ class RTC_EXPORT StreamInterface { public: virtual ~StreamInterface() {} + StreamInterface(const StreamInterface&) = delete; + StreamInterface& operator=(const StreamInterface&) = delete; + virtual StreamState GetState() const = 0; // Read attempts to fill buffer of size buffer_len. Write attempts to send @@ -110,9 +112,6 @@ class RTC_EXPORT StreamInterface { protected: StreamInterface(); - - private: - RTC_DISALLOW_COPY_AND_ASSIGN(StreamInterface); }; } // namespace rtc diff --git a/rtc_base/task_queue.h b/rtc_base/task_queue.h index 86d35976cb..1798d06b5d 100644 --- a/rtc_base/task_queue.h +++ b/rtc_base/task_queue.h @@ -20,7 +20,6 @@ #include "api/task_queue/queued_task.h" #include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_factory.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/rtc_export.h" #include "rtc_base/task_utils/to_queued_task.h" #include "rtc_base/thread_annotations.h" @@ -83,6 +82,9 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { webrtc::TaskQueueDeleter> task_queue); ~TaskQueue(); + TaskQueue(const TaskQueue&) = delete; + TaskQueue& operator=(const TaskQueue&) = delete; + // Used for DCHECKing the current queue. bool IsCurrent() const; @@ -125,8 +127,6 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue { private: webrtc::TaskQueueBase* const impl_; - - RTC_DISALLOW_COPY_AND_ASSIGN(TaskQueue); }; } // namespace rtc diff --git a/rtc_base/test_client.h b/rtc_base/test_client.h index 6989fe1d57..dd91d37ab9 100644 --- a/rtc_base/test_client.h +++ b/rtc_base/test_client.h @@ -15,7 +15,6 @@ #include #include "rtc_base/async_udp_socket.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/fake_clock.h" #include "rtc_base/synchronization/mutex.h" @@ -53,6 +52,9 @@ class TestClient : public sigslot::has_slots<> { ThreadProcessingFakeClock* fake_clock); ~TestClient() override; + TestClient(const TestClient&) = delete; + TestClient& operator=(const TestClient&) = delete; + SocketAddress address() const { return socket_->GetLocalAddress(); } SocketAddress remote_address() const { return socket_->GetRemoteAddress(); } @@ -110,7 +112,6 @@ class TestClient : public sigslot::has_slots<> { std::vector> packets_; int ready_to_send_count_ = 0; int64_t prev_packet_timestamp_; - RTC_DISALLOW_COPY_AND_ASSIGN(TestClient); }; } // namespace rtc diff --git a/rtc_base/test_echo_server.h b/rtc_base/test_echo_server.h index a061ed0ce7..ba5f997287 100644 --- a/rtc_base/test_echo_server.h +++ b/rtc_base/test_echo_server.h @@ -20,7 +20,6 @@ #include "absl/algorithm/container.h" #include "rtc_base/async_packet_socket.h" #include "rtc_base/async_tcp_socket.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/socket.h" #include "rtc_base/socket_address.h" #include "rtc_base/third_party/sigslot/sigslot.h" @@ -35,6 +34,9 @@ class TestEchoServer : public sigslot::has_slots<> { TestEchoServer(Thread* thread, const SocketAddress& addr); ~TestEchoServer() override; + TestEchoServer(const TestEchoServer&) = delete; + TestEchoServer& operator=(const TestEchoServer&) = delete; + SocketAddress address() const { return server_socket_->GetLocalAddress(); } private: @@ -64,7 +66,6 @@ class TestEchoServer : public sigslot::has_slots<> { typedef std::list ClientList; std::unique_ptr server_socket_; ClientList client_sockets_; - RTC_DISALLOW_COPY_AND_ASSIGN(TestEchoServer); }; } // namespace rtc diff --git a/rtc_base/thread.cc b/rtc_base/thread.cc index 46e082f8ff..2a79d82b06 100644 --- a/rtc_base/thread.cc +++ b/rtc_base/thread.cc @@ -75,6 +75,9 @@ class MessageHandlerWithTask final : public MessageHandler { public: MessageHandlerWithTask() {} + MessageHandlerWithTask(const MessageHandlerWithTask&) = delete; + MessageHandlerWithTask& operator=(const MessageHandlerWithTask&) = delete; + void OnMessage(Message* msg) override { static_cast(msg->pdata)->Run(); delete msg->pdata; @@ -82,8 +85,6 @@ class MessageHandlerWithTask final : public MessageHandler { private: ~MessageHandlerWithTask() override {} - - RTC_DISALLOW_COPY_AND_ASSIGN(MessageHandlerWithTask); }; class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { @@ -100,11 +101,12 @@ class RTC_SCOPED_LOCKABLE MarkProcessingCritScope { cs_->Leave(); } + MarkProcessingCritScope(const MarkProcessingCritScope&) = delete; + MarkProcessingCritScope& operator=(const MarkProcessingCritScope&) = delete; + private: const RecursiveCriticalSection* const cs_; size_t* processing_; - - RTC_DISALLOW_COPY_AND_ASSIGN(MarkProcessingCritScope); }; } // namespace diff --git a/rtc_base/thread.h b/rtc_base/thread.h index 38e9732fbb..70cafe0929 100644 --- a/rtc_base/thread.h +++ b/rtc_base/thread.h @@ -29,7 +29,6 @@ #include "api/task_queue/queued_task.h" #include "api/task_queue/task_queue_base.h" #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/deprecated/recursive_critical_section.h" #include "rtc_base/location.h" #include "rtc_base/message_handler.h" @@ -89,14 +88,15 @@ class MessageWithFunctor final : public MessageLikeTask { explicit MessageWithFunctor(FunctorT&& functor) : functor_(std::forward(functor)) {} + MessageWithFunctor(const MessageWithFunctor&) = delete; + MessageWithFunctor& operator=(const MessageWithFunctor&) = delete; + void Run() override { functor_(); } private: ~MessageWithFunctor() override {} typename std::remove_reference::type functor_; - - RTC_DISALLOW_COPY_AND_ASSIGN(MessageWithFunctor); }; } // namespace rtc_thread_internal @@ -152,6 +152,9 @@ class RTC_EXPORT ThreadManager { ThreadManager(); ~ThreadManager(); + ThreadManager(const ThreadManager&) = delete; + ThreadManager& operator=(const ThreadManager&) = delete; + void SetCurrentThreadInternal(Thread* thread); void AddInternal(Thread* message_queue); void RemoveInternal(Thread* message_queue); @@ -186,8 +189,6 @@ class RTC_EXPORT ThreadManager { // The thread to potentially autowrap. const PlatformThreadRef main_thread_ref_; - - RTC_DISALLOW_COPY_AND_ASSIGN(ThreadManager); }; // WARNING! SUBCLASSES MUST CALL Stop() IN THEIR DESTRUCTORS! See ~Thread(). @@ -221,6 +222,9 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { // calling Clear on the object from a different thread. ~Thread() override; + Thread(const Thread&) = delete; + Thread& operator=(const Thread&) = delete; + static std::unique_ptr CreateWithSocketServer(); static std::unique_ptr Create(); static Thread* Current(); @@ -685,8 +689,6 @@ class RTC_LOCKABLE RTC_EXPORT Thread : public webrtc::TaskQueueBase { friend class ThreadManager; int dispatch_warning_ms_ RTC_GUARDED_BY(this) = kSlowDispatchLoggingThreshold; - - RTC_DISALLOW_COPY_AND_ASSIGN(Thread); }; // AutoThread automatically installs itself at construction @@ -700,8 +702,8 @@ class AutoThread : public Thread { AutoThread(); ~AutoThread() override; - private: - RTC_DISALLOW_COPY_AND_ASSIGN(AutoThread); + AutoThread(const AutoThread&) = delete; + AutoThread& operator=(const AutoThread&) = delete; }; // AutoSocketServerThread automatically installs itself at @@ -714,10 +716,11 @@ class AutoSocketServerThread : public Thread { explicit AutoSocketServerThread(SocketServer* ss); ~AutoSocketServerThread() override; + AutoSocketServerThread(const AutoSocketServerThread&) = delete; + AutoSocketServerThread& operator=(const AutoSocketServerThread&) = delete; + private: rtc::Thread* old_thread_; - - RTC_DISALLOW_COPY_AND_ASSIGN(AutoSocketServerThread); }; } // namespace rtc diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc index 62f00ec772..424210afc4 100644 --- a/rtc_base/thread_unittest.cc +++ b/rtc_base/thread_unittest.cc @@ -204,6 +204,10 @@ struct FunctorD { public: explicit FunctorD(AtomicBool* flag) : flag_(flag) {} FunctorD(FunctorD&&) = default; + + FunctorD(const FunctorD&) = delete; + FunctorD& operator=(const FunctorD&) = delete; + FunctorD& operator=(FunctorD&&) = default; void operator()() { if (flag_) @@ -212,7 +216,6 @@ struct FunctorD { private: AtomicBool* flag_; - RTC_DISALLOW_COPY_AND_ASSIGN(FunctorD); }; // See: https://code.google.com/p/webrtc/issues/detail?id=2409 diff --git a/rtc_base/timestamp_aligner.h b/rtc_base/timestamp_aligner.h index 73af9debf9..138e936af2 100644 --- a/rtc_base/timestamp_aligner.h +++ b/rtc_base/timestamp_aligner.h @@ -13,7 +13,6 @@ #include -#include "rtc_base/constructor_magic.h" #include "rtc_base/system/rtc_export.h" namespace rtc { @@ -35,6 +34,9 @@ class RTC_EXPORT TimestampAligner { TimestampAligner(); ~TimestampAligner(); + TimestampAligner(const TimestampAligner&) = delete; + TimestampAligner& operator=(const TimestampAligner&) = delete; + public: // Translates timestamps of a capture system to the same timescale as is used // by rtc::TimeMicros(). `capturer_time_us` is assumed to be accurate, but @@ -77,7 +79,6 @@ class RTC_EXPORT TimestampAligner { // Offset between `prev_translated_time_us_` and the corresponding capturer // time. int64_t prev_time_offset_us_; - RTC_DISALLOW_COPY_AND_ASSIGN(TimestampAligner); }; } // namespace rtc diff --git a/rtc_base/virtual_socket_server.h b/rtc_base/virtual_socket_server.h index 8873f18dcc..b172567937 100644 --- a/rtc_base/virtual_socket_server.h +++ b/rtc_base/virtual_socket_server.h @@ -16,7 +16,6 @@ #include #include "rtc_base/checks.h" -#include "rtc_base/constructor_magic.h" #include "rtc_base/event.h" #include "rtc_base/fake_clock.h" #include "rtc_base/message_handler.h" @@ -163,6 +162,9 @@ class VirtualSocketServer : public SocketServer { explicit VirtualSocketServer(ThreadProcessingFakeClock* fake_clock); ~VirtualSocketServer() override; + VirtualSocketServer(const VirtualSocketServer&) = delete; + VirtualSocketServer& operator=(const VirtualSocketServer&) = delete; + // The default source address specifies which local address to use when a // socket is bound to the 'any' address, e.g. 0.0.0.0. (If not set, the 'any' // address is used as the source address on outgoing virtual packets, exposed @@ -419,7 +421,6 @@ class VirtualSocketServer : public SocketServer { size_t max_udp_payload_ RTC_GUARDED_BY(mutex_) = 65507; bool sending_blocked_ RTC_GUARDED_BY(mutex_) = false; - RTC_DISALLOW_COPY_AND_ASSIGN(VirtualSocketServer); }; } // namespace rtc diff --git a/rtc_tools/sanitizers_unittest.cc b/rtc_tools/sanitizers_unittest.cc index eec037c940..ee575831af 100644 --- a/rtc_tools/sanitizers_unittest.cc +++ b/rtc_tools/sanitizers_unittest.cc @@ -15,6 +15,7 @@ #include #include "rtc_base/checks.h" +#include "rtc_base/constructor_magic.h" #include "rtc_base/null_socket_server.h" #include "rtc_base/thread.h" #include "test/gtest.h"