Delete BasicPacketSocketFactory constructor with thread argument

In callers where it's non-trivial to explicitly pass the right
SocketFactory, pull the call to rtc::Thread::socketserver() into the
caller, with a TODO comment.

Bug: webrtc:13145
Change-Id: I029d3adca385d822180e089f016c3778e0d4fd0c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/231227
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35063}
This commit is contained in:
Niels Möller
2021-09-07 09:16:49 +02:00
committed by WebRTC LUCI CQ
parent 070dbe13d1
commit 9def99487e
11 changed files with 26 additions and 33 deletions

View File

@ -25,16 +25,12 @@
#include "rtc_base/socket_adapters.h"
#include "rtc_base/socket_server.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/thread.h"
namespace rtc {
BasicPacketSocketFactory::BasicPacketSocketFactory(Thread* thread)
: thread_(thread), socket_factory_(NULL) {}
BasicPacketSocketFactory::BasicPacketSocketFactory(
SocketFactory* socket_factory)
: thread_(NULL), socket_factory_(socket_factory) {}
: socket_factory_(socket_factory) {}
BasicPacketSocketFactory::~BasicPacketSocketFactory() {}
@ -43,7 +39,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateUdpSocket(
uint16_t min_port,
uint16_t max_port) {
// UDP sockets are simple.
Socket* socket = socket_factory()->CreateSocket(address.family(), SOCK_DGRAM);
Socket* socket = socket_factory_->CreateSocket(address.family(), SOCK_DGRAM);
if (!socket) {
return NULL;
}
@ -67,7 +63,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateServerTcpSocket(
}
Socket* socket =
socket_factory()->CreateSocket(local_address.family(), SOCK_STREAM);
socket_factory_->CreateSocket(local_address.family(), SOCK_STREAM);
if (!socket) {
return NULL;
}
@ -104,7 +100,7 @@ AsyncPacketSocket* BasicPacketSocketFactory::CreateClientTcpSocket(
const std::string& user_agent,
const PacketSocketTcpOptions& tcp_options) {
Socket* socket =
socket_factory()->CreateSocket(local_address.family(), SOCK_STREAM);
socket_factory_->CreateSocket(local_address.family(), SOCK_STREAM);
if (!socket) {
return NULL;
}
@ -215,13 +211,4 @@ int BasicPacketSocketFactory::BindSocket(Socket* socket,
return ret;
}
SocketFactory* BasicPacketSocketFactory::socket_factory() {
if (thread_) {
RTC_DCHECK(thread_ == Thread::Current());
return thread_->socketserver();
} else {
return socket_factory_;
}
}
} // namespace rtc