Delete AsyncSocket class, merge into Socket class

Bug: webrtc:13065
Change-Id: I13afee2386ea9c4de0e4fa95133f0c4d3ec826e8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227031
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34787}
This commit is contained in:
Niels Möller
2021-08-12 10:32:30 +02:00
committed by WebRTC LUCI CQ
parent 45b3e530cb
commit d0b8879770
73 changed files with 570 additions and 685 deletions

View File

@ -16,7 +16,6 @@
#include <memory>
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/async_socket.h"
#include "rtc_base/buffer.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/socket.h"
@ -29,7 +28,7 @@ namespace rtc {
// buffer them in user space.
class AsyncTCPSocketBase : public AsyncPacketSocket {
public:
AsyncTCPSocketBase(AsyncSocket* socket, bool listen, size_t max_packet_size);
AsyncTCPSocketBase(Socket* socket, bool listen, size_t max_packet_size);
~AsyncTCPSocketBase() override;
// Pure virtual methods to send and recv data.
@ -38,7 +37,7 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
const rtc::PacketOptions& options) override = 0;
virtual void ProcessInput(char* data, size_t* len) = 0;
// Signals incoming connection.
virtual void HandleIncomingConnection(AsyncSocket* socket) = 0;
virtual void HandleIncomingConnection(Socket* socket) = 0;
SocketAddress GetLocalAddress() const override;
SocketAddress GetRemoteAddress() const override;
@ -58,9 +57,9 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
// Binds and connects `socket` and creates AsyncTCPSocket for
// it. Takes ownership of `socket`. Returns null if bind() or
// connect() fail (`socket` is destroyed in that case).
static AsyncSocket* ConnectSocket(AsyncSocket* socket,
const SocketAddress& bind_address,
const SocketAddress& remote_address);
static Socket* ConnectSocket(Socket* socket,
const SocketAddress& bind_address,
const SocketAddress& remote_address);
int FlushOutBuffer();
// Add data to `outbuf_`.
void AppendToOutBuffer(const void* pv, size_t cb);
@ -71,12 +70,12 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
private:
// Called by the underlying socket
void OnConnectEvent(AsyncSocket* socket);
void OnReadEvent(AsyncSocket* socket);
void OnWriteEvent(AsyncSocket* socket);
void OnCloseEvent(AsyncSocket* socket, int error);
void OnConnectEvent(Socket* socket);
void OnReadEvent(Socket* socket);
void OnWriteEvent(Socket* socket);
void OnCloseEvent(Socket* socket, int error);
std::unique_ptr<AsyncSocket> socket_;
std::unique_ptr<Socket> socket_;
bool listen_;
Buffer inbuf_;
Buffer outbuf_;
@ -91,17 +90,17 @@ class AsyncTCPSocket : public AsyncTCPSocketBase {
// Binds and connects `socket` and creates AsyncTCPSocket for
// it. Takes ownership of `socket`. Returns null if bind() or
// connect() fail (`socket` is destroyed in that case).
static AsyncTCPSocket* Create(AsyncSocket* socket,
static AsyncTCPSocket* Create(Socket* socket,
const SocketAddress& bind_address,
const SocketAddress& remote_address);
AsyncTCPSocket(AsyncSocket* socket, bool listen);
AsyncTCPSocket(Socket* socket, bool listen);
~AsyncTCPSocket() override {}
int Send(const void* pv,
size_t cb,
const rtc::PacketOptions& options) override;
void ProcessInput(char* data, size_t* len) override;
void HandleIncomingConnection(AsyncSocket* socket) override;
void HandleIncomingConnection(Socket* socket) override;
private:
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocket);