Reland "Take out listen support from AsyncPacketSocket"
This is a reland of b141c162ee2ef88a7498ba8cb8bc852287f93ad2 Original change's description: > Take out listen support from AsyncPacketSocket > > Moved to new interface class AsyncListenSocket. > > Bug: webrtc:13065 > Change-Id: Ib96ce154ba19979360ecd8144981d947ff5b8b18 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232607 > Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Commit-Queue: Niels Moller <nisse@webrtc.org> > Cr-Commit-Position: refs/heads/main@{#35234} Bug: webrtc:13065 Change-Id: I88bebdd80ebe6bcf6ac635023924d79fbfb76813 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235960 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35260}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
b62ee8ce94
commit
d30ece1804
@ -28,7 +28,7 @@ namespace rtc {
|
||||
// buffer them in user space.
|
||||
class AsyncTCPSocketBase : public AsyncPacketSocket {
|
||||
public:
|
||||
AsyncTCPSocketBase(Socket* socket, bool listen, size_t max_packet_size);
|
||||
AsyncTCPSocketBase(Socket* socket, size_t max_packet_size);
|
||||
~AsyncTCPSocketBase() override;
|
||||
|
||||
// Pure virtual methods to send and recv data.
|
||||
@ -36,8 +36,6 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
|
||||
size_t cb,
|
||||
const rtc::PacketOptions& options) override = 0;
|
||||
virtual void ProcessInput(char* data, size_t* len) = 0;
|
||||
// Signals incoming connection.
|
||||
virtual void HandleIncomingConnection(Socket* socket) = 0;
|
||||
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
SocketAddress GetRemoteAddress() const override;
|
||||
@ -76,7 +74,6 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
|
||||
void OnCloseEvent(Socket* socket, int error);
|
||||
|
||||
std::unique_ptr<Socket> socket_;
|
||||
bool listen_;
|
||||
Buffer inbuf_;
|
||||
Buffer outbuf_;
|
||||
size_t max_insize_;
|
||||
@ -93,19 +90,37 @@ class AsyncTCPSocket : public AsyncTCPSocketBase {
|
||||
static AsyncTCPSocket* Create(Socket* socket,
|
||||
const SocketAddress& bind_address,
|
||||
const SocketAddress& remote_address);
|
||||
AsyncTCPSocket(Socket* socket, bool listen);
|
||||
explicit AsyncTCPSocket(Socket* socket);
|
||||
~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(Socket* socket) override;
|
||||
|
||||
private:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(AsyncTCPSocket);
|
||||
};
|
||||
|
||||
class AsyncTcpListenSocket : public AsyncListenSocket {
|
||||
public:
|
||||
explicit AsyncTcpListenSocket(std::unique_ptr<Socket> socket);
|
||||
|
||||
State GetState() const override;
|
||||
SocketAddress GetLocalAddress() const override;
|
||||
|
||||
int GetOption(Socket::Option opt, int* value) override;
|
||||
int SetOption(Socket::Option opt, int value) override;
|
||||
|
||||
virtual void HandleIncomingConnection(rtc::Socket* socket);
|
||||
|
||||
private:
|
||||
// Called by the underlying socket
|
||||
void OnReadEvent(Socket* socket);
|
||||
|
||||
std::unique_ptr<Socket> socket_;
|
||||
};
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
#endif // RTC_BASE_ASYNC_TCP_SOCKET_H_
|
||||
|
Reference in New Issue
Block a user