Remove VirtualSocketServer's dependency on PhysicalSocketServer.

The only thing the physical socket server was used for was
"Wait"/"WakeUp", but it could be replaced by a simple rtc::Event.

So, removing this dependency makes things less confusing; the fact that
VirtualSocketServer takes a PhysicalSocketServer may lead someone to
think it uses real sockets internally, when it doesn't.

BUG=None

Review-Url: https://codereview.webrtc.org/2883313003
Cr-Commit-Position: refs/heads/master@{#18172}
This commit is contained in:
deadbeef 2017-05-16 18:00:06 -07:00 committed by Commit bot
parent 73c1234f6a
commit 98e186c71c
28 changed files with 60 additions and 148 deletions

View File

@ -13,7 +13,6 @@
#include "webrtc/base/asynctcpsocket.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/virtualsocketserver.h"
namespace rtc {
@ -23,8 +22,7 @@ class AsyncTCPSocketTest
public sigslot::has_slots<> {
public:
AsyncTCPSocketTest()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
: vss_(new rtc::VirtualSocketServer()),
socket_(vss_->CreateAsyncSocket(SOCK_STREAM)),
tcp_socket_(new AsyncTCPSocket(socket_, true)),
ready_to_send_(false) {
@ -37,7 +35,6 @@ class AsyncTCPSocketTest
}
protected:
std::unique_ptr<PhysicalSocketServer> pss_;
std::unique_ptr<VirtualSocketServer> vss_;
AsyncSocket* socket_;
std::unique_ptr<AsyncTCPSocket> tcp_socket_;

View File

@ -268,23 +268,17 @@ namespace {
class TestVirtualSocketServer : public VirtualSocketServer {
public:
explicit TestVirtualSocketServer(SocketServer* ss)
: VirtualSocketServer(ss),
ss_(ss) {}
// Expose this publicly
IPAddress GetNextIP(int af) { return VirtualSocketServer::GetNextIP(af); }
private:
std::unique_ptr<SocketServer> ss_;
};
} // namespace
void TestVirtualInternal(int family) {
std::unique_ptr<TestVirtualSocketServer> int_vss(
new TestVirtualSocketServer(new PhysicalSocketServer()));
new TestVirtualSocketServer());
std::unique_ptr<TestVirtualSocketServer> ext_vss(
new TestVirtualSocketServer(new PhysicalSocketServer()));
new TestVirtualSocketServer());
SocketAddress int_addr;
SocketAddress ext_addrs[4];
@ -316,14 +310,16 @@ class NatTcpTest : public testing::Test, public sigslot::has_slots<> {
: int_addr_("192.168.0.1", 0),
ext_addr_("10.0.0.1", 0),
connected_(false),
int_pss_(new PhysicalSocketServer()),
ext_pss_(new PhysicalSocketServer()),
int_vss_(new TestVirtualSocketServer(int_pss_)),
ext_vss_(new TestVirtualSocketServer(ext_pss_)),
int_vss_(new TestVirtualSocketServer()),
ext_vss_(new TestVirtualSocketServer()),
int_thread_(new Thread(int_vss_.get())),
ext_thread_(new Thread(ext_vss_.get())),
nat_(new NATServer(NAT_OPEN_CONE, int_vss_.get(), int_addr_, int_addr_,
ext_vss_.get(), ext_addr_)),
nat_(new NATServer(NAT_OPEN_CONE,
int_vss_.get(),
int_addr_,
int_addr_,
ext_vss_.get(),
ext_addr_)),
natsf_(new NATSocketFactory(int_vss_.get(),
nat_->internal_udp_address(),
nat_->internal_tcp_address())) {
@ -350,8 +346,6 @@ class NatTcpTest : public testing::Test, public sigslot::has_slots<> {
SocketAddress int_addr_;
SocketAddress ext_addr_;
bool connected_;
PhysicalSocketServer* int_pss_;
PhysicalSocketServer* ext_pss_;
std::unique_ptr<TestVirtualSocketServer> int_vss_;
std::unique_ptr<TestVirtualSocketServer> ext_vss_;
std::unique_ptr<Thread> int_thread_;

View File

@ -414,7 +414,7 @@ NATSocketServer::Translator::Translator(
// Create a new private network, and a NATServer running on the private
// network that bridges to the external network. Also tell the private
// network to use the same message queue as us.
VirtualSocketServer* internal_server = new VirtualSocketServer(server_);
VirtualSocketServer* internal_server = new VirtualSocketServer();
internal_server->SetMessageQueue(server_->queue());
internal_factory_.reset(internal_server);
nat_server_.reset(new NATServer(type, internal_server, int_ip, int_ip,

View File

@ -31,7 +31,7 @@ static const SocketAddress kBogusProxyIntAddr("1.2.3.4", 999);
// Sets up a virtual socket server and HTTPS/SOCKS5 proxy servers.
class ProxyTest : public testing::Test {
public:
ProxyTest() : ss_(new rtc::VirtualSocketServer(nullptr)), thread_(ss_.get()) {
ProxyTest() : ss_(new rtc::VirtualSocketServer()), thread_(ss_.get()) {
socks_.reset(new rtc::SocksProxyServer(
ss_.get(), kSocksProxyIntAddr, ss_.get(), kSocksProxyExtAddr));
https_.reset(new rtc::HttpListenServer());

View File

@ -274,7 +274,7 @@ class SSLAdapterTestBase : public testing::Test,
explicit SSLAdapterTestBase(const rtc::SSLMode& ssl_mode,
const rtc::KeyParams& key_params)
: ssl_mode_(ssl_mode),
vss_(new rtc::VirtualSocketServer(nullptr)),
vss_(new rtc::VirtualSocketServer()),
thread_(vss_.get()),
server_(new SSLAdapterTestDummyServer(ssl_mode_, key_params)),
client_(new SSLAdapterTestDummyClient(ssl_mode_)),

View File

@ -146,8 +146,7 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> {
class VirtualSocketServerTest : public testing::Test {
public:
VirtualSocketServerTest()
: ss_(nullptr),
thread_(&ss_),
: thread_(&ss_),
kIPv4AnyAddress(IPAddress(INADDR_ANY), 0),
kIPv6AnyAddress(IPAddress(in6addr_any), 0) {}

View File

@ -515,9 +515,8 @@ void VirtualSocket::OnSocketServerReadyToSend() {
}
}
VirtualSocketServer::VirtualSocketServer(SocketServer* ss)
: server_(ss),
server_owned_(false),
VirtualSocketServer::VirtualSocketServer()
: wakeup_(/*manual_reset=*/false, /*initially_signaled=*/false),
msg_queue_(nullptr),
stop_on_idle_(false),
next_ipv4_(kInitialNextIPv4),
@ -533,19 +532,12 @@ VirtualSocketServer::VirtualSocketServer(SocketServer* ss)
delay_stddev_(0),
delay_samples_(NUM_SAMPLES),
drop_prob_(0.0) {
if (!server_) {
server_ = new PhysicalSocketServer();
server_owned_ = true;
}
UpdateDelayDistribution();
}
VirtualSocketServer::~VirtualSocketServer() {
delete bindings_;
delete connections_;
if (server_owned_) {
delete server_;
}
}
IPAddress VirtualSocketServer::GetNextIP(int family) {
@ -621,11 +613,16 @@ bool VirtualSocketServer::Wait(int cmsWait, bool process_io) {
if (stop_on_idle_ && Thread::Current()->empty()) {
return false;
}
return socketserver()->Wait(cmsWait, process_io);
// Note: we don't need to do anything with |process_io| since we don't have
// any real I/O. Received packets come in the form of queued messages, so
// MessageQueue will ensure WakeUp is called if another thread sends a
// packet.
wakeup_.Wait(cmsWait);
return true;
}
void VirtualSocketServer::WakeUp() {
socketserver()->WakeUp();
wakeup_.Set();
}
bool VirtualSocketServer::ProcessMessagesUntilIdle() {

View File

@ -16,6 +16,7 @@
#include "webrtc/base/checks.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/event.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/socketserver.h"
@ -31,13 +32,9 @@ class SocketAddressPair;
// they are bound to addresses from incompatible families.
class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
public:
// TODO: Add "owned" parameter.
// If "owned" is set, the supplied socketserver will be deleted later.
explicit VirtualSocketServer(SocketServer* ss);
VirtualSocketServer();
~VirtualSocketServer() override;
SocketServer* socketserver() { return server_; }
// The default route indicates which local address to use when a socket is
// bound to the 'any' address, e.g. 0.0.0.0.
IPAddress GetDefaultRoute(int family);
@ -245,8 +242,8 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
typedef std::map<SocketAddress, VirtualSocket*> AddressMap;
typedef std::map<SocketAddressPair, VirtualSocket*> ConnectionMap;
SocketServer* server_;
bool server_owned_;
// Used to implement Wait/WakeUp.
Event wakeup_;
MessageQueue* msg_queue_;
bool stop_on_idle_;
in_addr next_ipv4_;

View File

@ -15,7 +15,6 @@
#include "webrtc/base/criticalsection.h"
#include "webrtc/base/fakenetwork.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/ortc/testrtpparameters.h"
#include "webrtc/p2p/base/udptransport.h"
@ -70,8 +69,7 @@ namespace webrtc {
class OrtcFactoryIntegrationTest : public testing::Test {
public:
OrtcFactoryIntegrationTest()
: virtual_socket_server_(&physical_socket_server_),
network_thread_(&virtual_socket_server_),
: network_thread_(&virtual_socket_server_),
fake_audio_capture_module1_(FakeAudioCaptureModule::Create()),
fake_audio_capture_module2_(FakeAudioCaptureModule::Create()) {
// Sockets are bound to the ANY address, so this is needed to tell the
@ -330,7 +328,6 @@ class OrtcFactoryIntegrationTest : public testing::Test {
}
}
rtc::PhysicalSocketServer physical_socket_server_;
rtc::VirtualSocketServer virtual_socket_server_;
rtc::Thread network_thread_;
rtc::FakeNetworkManager fake_network_manager_;

View File

@ -12,7 +12,6 @@
#include "webrtc/base/fakenetwork.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/media/base/fakemediaengine.h"
#include "webrtc/ortc/ortcfactory.h"
@ -27,8 +26,7 @@ namespace webrtc {
class OrtcFactoryTest : public testing::Test {
public:
OrtcFactoryTest()
: virtual_socket_server_(&physical_socket_server_),
thread_(&virtual_socket_server_),
: thread_(&virtual_socket_server_),
fake_packet_transport_("fake transport") {
ortc_factory_ =
OrtcFactory::Create(nullptr, nullptr, &fake_network_manager_, nullptr,
@ -49,7 +47,6 @@ class OrtcFactoryTest : public testing::Test {
.MoveValue();
}
rtc::PhysicalSocketServer physical_socket_server_;
rtc::VirtualSocketServer virtual_socket_server_;
rtc::AutoSocketServerThread thread_;
rtc::FakeNetworkManager fake_network_manager_;

View File

@ -13,7 +13,6 @@
#include "webrtc/p2p/base/asyncstuntcpsocket.h"
#include "webrtc/base/asyncsocket.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/virtualsocketserver.h"
namespace cricket {
@ -69,8 +68,7 @@ class AsyncStunTCPSocketTest : public testing::Test,
public sigslot::has_slots<> {
protected:
AsyncStunTCPSocketTest()
: vss_(new rtc::VirtualSocketServer(NULL)),
thread_(vss_.get()) {}
: vss_(new rtc::VirtualSocketServer()), thread_(vss_.get()) {}
virtual void SetUp() {
CreateSockets();

View File

@ -22,7 +22,6 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/natsocketfactory.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/proxyserver.h"
#include "webrtc/base/ptr_util.h"
#include "webrtc/base/socketaddress.h"
@ -182,8 +181,7 @@ class P2PTransportChannelTestBase : public testing::Test,
public sigslot::has_slots<> {
public:
P2PTransportChannelTestBase()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
: vss_(new rtc::VirtualSocketServer()),
nss_(new rtc::NATSocketServer(vss_.get())),
ss_(new rtc::FirewallSocketServer(nss_.get())),
main_(ss_.get()),
@ -874,7 +872,6 @@ class P2PTransportChannelTestBase : public testing::Test,
bool nominated() { return nominated_; }
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
std::unique_ptr<rtc::NATSocketServer> nss_;
std::unique_ptr<rtc::FirewallSocketServer> ss_;
@ -2930,9 +2927,7 @@ class P2PTransportChannelPingTest : public testing::Test,
public sigslot::has_slots<> {
public:
P2PTransportChannelPingTest()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
thread_(vss_.get()) {}
: vss_(new rtc::VirtualSocketServer()), thread_(vss_.get()) {}
protected:
void PrepareChannel(P2PTransportChannel* ch) {
@ -3080,7 +3075,6 @@ class P2PTransportChannelPingTest : public testing::Test,
}
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread thread_;
CandidatePairInterface* last_selected_candidate_pair_ = nullptr;

View File

@ -18,7 +18,6 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/natsocketfactory.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ptr_util.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
@ -381,8 +380,7 @@ class TestChannel : public sigslot::has_slots<> {
class PortTest : public testing::Test, public sigslot::has_slots<> {
public:
PortTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
main_(ss_.get()),
network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
socket_factory_(rtc::Thread::Current()),
@ -801,7 +799,6 @@ class PortTest : public testing::Test, public sigslot::has_slots<> {
rtc::VirtualSocketServer* vss() { return ss_.get(); }
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::AutoSocketServerThread main_;
rtc::Network network_;

View File

@ -11,7 +11,6 @@
#include <memory>
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/fakeportallocator.h"
@ -28,9 +27,7 @@ static const char kTurnPassword[] = "test";
class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
public:
PortAllocatorTest()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
main_(vss_.get()) {
: vss_(new rtc::VirtualSocketServer()), main_(vss_.get()) {
allocator_.reset(
new cricket::FakePortAllocator(rtc::Thread::Current(), nullptr));
}
@ -81,7 +78,6 @@ class PortAllocatorTest : public testing::Test, public sigslot::has_slots<> {
return count;
}
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
std::unique_ptr<cricket::FakePortAllocator> allocator_;

View File

@ -16,7 +16,6 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/socketadapters.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
@ -45,20 +44,21 @@ class RelayPortTest : public testing::Test,
public sigslot::has_slots<> {
public:
RelayPortTest()
: physical_socket_server_(new rtc::PhysicalSocketServer),
virtual_socket_server_(new rtc::VirtualSocketServer(
physical_socket_server_.get())),
: virtual_socket_server_(new rtc::VirtualSocketServer()),
main_(virtual_socket_server_.get()),
network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
socket_factory_(rtc::Thread::Current()),
username_(rtc::CreateRandomString(16)),
password_(rtc::CreateRandomString(16)),
relay_port_(cricket::RelayPort::Create(&main_, &socket_factory_,
relay_port_(cricket::RelayPort::Create(&main_,
&socket_factory_,
&network_,
kLocalAddress.ipaddr(),
0, 0, username_, password_)),
relay_server_(new cricket::RelayServer(&main_)) {
}
0,
0,
username_,
password_)),
relay_server_(new cricket::RelayServer(&main_)) {}
void OnReadPacket(rtc::AsyncPacketSocket* socket,
const char* data, size_t size,
@ -246,7 +246,6 @@ class RelayPortTest : public testing::Test,
typedef std::map<rtc::AsyncPacketSocket*, int> PacketMap;
std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_;
std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
rtc::AutoSocketServerThread main_;
rtc::Network network_;

View File

@ -14,7 +14,6 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ptr_util.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
@ -40,8 +39,7 @@ static const char* msg2 = "Lobster Thermidor a Crevette with a mornay sauce...";
class RelayServerTest : public testing::Test {
public:
RelayServerTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
thread_(ss_.get()),
username_(rtc::CreateRandomString(12)),
password_(rtc::CreateRandomString(12)) {}
@ -166,7 +164,6 @@ class RelayServerTest : public testing::Test {
msg->AddAttribute(std::move(attr));
}
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::AutoSocketServerThread thread_;
std::unique_ptr<RelayServer> server_;

View File

@ -15,7 +15,6 @@
#include "webrtc/p2p/base/teststunserver.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/virtualsocketserver.h"
@ -39,13 +38,10 @@ static const int kInfiniteLifetime = -1;
static const int kHighCostPortKeepaliveLifetimeMs = 2 * 60 * 1000;
// Tests connecting a StunPort to a fake STUN server (cricket::StunServer)
// TODO: Use a VirtualSocketServer here. We have to use a
// PhysicalSocketServer right now since DNS is not part of SocketServer yet.
class StunPortTestBase : public testing::Test, public sigslot::has_slots<> {
public:
StunPortTestBase()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
thread_(ss_.get()),
network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
socket_factory_(rtc::Thread::Current()),
@ -156,7 +152,6 @@ class StunPortTestBase : public testing::Test, public sigslot::has_slots<> {
}
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::AutoSocketServerThread thread_;
rtc::Network network_;
@ -204,8 +199,7 @@ TEST_F(StunPortTest, TestPrepareAddress) {
std::string expected_server_url = "stun:127.0.0.1:5000";
EXPECT_EQ(port()->Candidates()[0].url(), expected_server_url);
// TODO: Add IPv6 tests here, once either physicalsocketserver supports
// IPv6, or this test is changed to use VirtualSocketServer.
// TODO(deadbeef): Add IPv6 tests here.
}
// Test that we fail properly if we can't get an address.

View File

@ -13,7 +13,6 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ptr_util.h"
#include "webrtc/base/testclient.h"
#include "webrtc/base/thread.h"
@ -27,11 +26,7 @@ static const rtc::SocketAddress client_addr("1.2.3.4", 1234);
class StunServerTest : public testing::Test {
public:
StunServerTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
network_(ss_.get()) {
}
StunServerTest() : ss_(new rtc::VirtualSocketServer()), network_(ss_.get()) {}
virtual void SetUp() {
server_.reset(new StunServer(
rtc::AsyncUDPSocket::Create(ss_.get(), server_addr)));
@ -63,7 +58,6 @@ class StunServerTest : public testing::Test {
return msg;
}
private:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::Thread network_;
std::unique_ptr<StunServer> server_;

View File

@ -11,7 +11,6 @@
#include <memory>
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
@ -31,8 +30,7 @@ static const SocketAddress kRemoteAddr("22.22.22.22", 2);
class TCPPortTest : public testing::Test, public sigslot::has_slots<> {
public:
TCPPortTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
main_(ss_.get()),
network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
socket_factory_(rtc::Thread::Current()),
@ -63,7 +61,6 @@ class TCPPortTest : public testing::Test, public sigslot::has_slots<> {
}
protected:
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::AutoSocketServerThread main_;
rtc::Network network_;

View File

@ -29,7 +29,6 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/socketadapters.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
@ -107,8 +106,7 @@ namespace cricket {
class TurnPortTestVirtualSocketServer : public rtc::VirtualSocketServer {
public:
explicit TurnPortTestVirtualSocketServer(SocketServer* ss)
: VirtualSocketServer(ss) {
TurnPortTestVirtualSocketServer() {
// This configures the virtual socket server to always add a simulated
// delay of exactly half of kSimulatedRtt.
set_delay_mean(kSimulatedRtt / 2);
@ -143,8 +141,7 @@ class TurnPortTest : public testing::Test,
public rtc::MessageHandler {
public:
TurnPortTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new TurnPortTestVirtualSocketServer(pss_.get())),
: ss_(new TurnPortTestVirtualSocketServer()),
main_(ss_.get()),
network_("unittest", "unittest", rtc::IPAddress(INADDR_ANY), 32),
socket_factory_(rtc::Thread::Current()),
@ -619,7 +616,6 @@ class TurnPortTest : public testing::Test,
protected:
rtc::ScopedFakeClock fake_clock_;
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<TurnPortTestVirtualSocketServer> ss_;
rtc::AutoSocketServerThread main_;
rtc::Network network_;

View File

@ -9,7 +9,6 @@
*/
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
#include "webrtc/p2p/base/turnserver.h"
@ -21,7 +20,7 @@ namespace cricket {
class TurnServerConnectionTest : public testing::Test {
public:
TurnServerConnectionTest() : vss_(&pss_), thread_(&vss_) {}
TurnServerConnectionTest() : thread_(&vss_) {}
void ExpectEqual(const TurnServerConnection& a,
const TurnServerConnection& b) {
@ -39,7 +38,6 @@ class TurnServerConnectionTest : public testing::Test {
}
protected:
rtc::PhysicalSocketServer pss_;
rtc::VirtualSocketServer vss_;
rtc::AutoSocketServerThread thread_;
// Since this is constructed after |thread_|, it will pick up |threads_|'s

View File

@ -18,7 +18,6 @@
#include "webrtc/base/thread.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/ipaddress.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/socketserver.h"
#include "webrtc/base/virtualsocketserver.h"
@ -35,9 +34,7 @@ static const rtc::IPAddress kIPv4LocalHostAddress =
class UdpTransportTest : public testing::Test, public sigslot::has_slots<> {
public:
UdpTransportTest()
: physical_socket_server_(new rtc::PhysicalSocketServer),
virtual_socket_server_(
new rtc::VirtualSocketServer(physical_socket_server_.get())),
: virtual_socket_server_(new rtc::VirtualSocketServer()),
network_thread_(virtual_socket_server_.get()),
ep1_("Name1",
std::unique_ptr<rtc::AsyncPacketSocket>(
@ -120,7 +117,6 @@ class UdpTransportTest : public testing::Test, public sigslot::has_slots<> {
uint32_t num_sig_ready_to_send_ = 0; // Increases on SignalReadyToSend.
};
std::unique_ptr<rtc::PhysicalSocketServer> physical_socket_server_;
std::unique_ptr<rtc::VirtualSocketServer> virtual_socket_server_;
rtc::AutoSocketServerThread network_thread_;
// Uses current thread's socket server, which will be set by ss_scope_.

View File

@ -22,7 +22,6 @@
#include "webrtc/base/natsocketfactory.h"
#include "webrtc/base/nethelpers.h"
#include "webrtc/base/network.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/socketaddress.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/thread.h"
@ -117,8 +116,7 @@ class BasicPortAllocatorTestBase : public testing::Test,
public sigslot::has_slots<> {
public:
BasicPortAllocatorTestBase()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
: vss_(new rtc::VirtualSocketServer()),
fss_(new rtc::FirewallSocketServer(vss_.get())),
thread_(fss_.get()),
// Note that the NAT is not used by default. ResetWithStunServerAndNat
@ -465,7 +463,6 @@ class BasicPortAllocatorTestBase : public testing::Test,
allocator().set_step_delay(kMinimumStepDelay);
}
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
std::unique_ptr<rtc::FirewallSocketServer> fss_;
rtc::AutoSocketServerThread thread_;

View File

@ -16,7 +16,6 @@
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/basicpacketsocketfactory.h"
@ -41,8 +40,7 @@ const rtc::SocketAddress kStunMappedAddr("77.77.77.77", 0);
class StunProberTest : public testing::Test {
public:
StunProberTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
main_(ss_.get()),
result_(StunProber::SUCCESS),
stun_server_1_(cricket::TestStunServer::Create(rtc::Thread::Current(),
@ -119,7 +117,6 @@ class StunProberTest : public testing::Test {
stopped_ = true;
}
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
rtc::AutoSocketServerThread main_;
std::unique_ptr<StunProber> prober;

View File

@ -30,7 +30,6 @@
#include "webrtc/base/fakenetwork.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/thread.h"
@ -937,8 +936,7 @@ class PeerConnectionWrapper : public webrtc::PeerConnectionObserver,
class PeerConnectionIntegrationTest : public testing::Test {
public:
PeerConnectionIntegrationTest()
: pss_(new rtc::PhysicalSocketServer),
ss_(new rtc::VirtualSocketServer(pss_.get())),
: ss_(new rtc::VirtualSocketServer()),
network_thread_(new rtc::Thread(ss_.get())),
worker_thread_(rtc::Thread::Create()) {
RTC_CHECK(network_thread_->Start());
@ -1143,7 +1141,6 @@ class PeerConnectionIntegrationTest : public testing::Test {
private:
// |ss_| is used by |network_thread_| so it must be destroyed later.
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> ss_;
// |network_thread_| and |worker_thread_| are used by both
// |caller_| and |callee_| so they must be destroyed

View File

@ -22,7 +22,6 @@
#include "webrtc/api/rtpsenderinterface.h"
#include "webrtc/api/test/fakeconstraints.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/stringutils.h"
@ -662,9 +661,7 @@ class PeerConnectionFactoryForTest : public webrtc::PeerConnectionFactory {
class PeerConnectionInterfaceTest : public testing::Test {
protected:
PeerConnectionInterfaceTest()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
main_(vss_.get()) {
: vss_(new rtc::VirtualSocketServer()), main_(vss_.get()) {
#ifdef WEBRTC_ANDROID
webrtc::InitializeAndroidObjects();
#endif
@ -1128,7 +1125,6 @@ class PeerConnectionInterfaceTest : public testing::Test {
return audio_desc->streams()[0].cname;
}
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
rtc::AutoSocketServerThread main_;
cricket::FakePortAllocator* port_allocator_ = nullptr;

View File

@ -18,7 +18,6 @@
#include "webrtc/api/stats/rtcstatsreport.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/refcountedobject.h"
#include "webrtc/base/scoped_ref_ptr.h"
#include "webrtc/base/virtualsocketserver.h"
@ -34,10 +33,7 @@ const int64_t kGetStatsTimeoutMs = 10000;
class RTCStatsIntegrationTest : public testing::Test {
public:
RTCStatsIntegrationTest()
: physical_socket_server_(),
virtual_socket_server_(&physical_socket_server_),
network_thread_(&virtual_socket_server_),
worker_thread_() {
: network_thread_(&virtual_socket_server_), worker_thread_() {
RTC_CHECK(network_thread_.Start());
RTC_CHECK(worker_thread_.Start());
@ -96,10 +92,8 @@ class RTCStatsIntegrationTest : public testing::Test {
return stats_obtainer->report();
}
// These objects use each other and must be constructed/destroyed in this
// order. Relationship:
// |physical_socket_server_| <- |virtual_socket_server_| <- |network_thread_|
rtc::PhysicalSocketServer physical_socket_server_;
// |network_thread_| uses |virtual_socket_server_| so they must be
// constructed/destructed in the correct order.
rtc::VirtualSocketServer virtual_socket_server_;
rtc::Thread network_thread_;
rtc::Thread worker_thread_;

View File

@ -21,7 +21,6 @@
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/network.h"
#include "webrtc/base/physicalsocketserver.h"
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/sslidentity.h"
#include "webrtc/base/sslstreamadapter.h"
@ -370,8 +369,7 @@ class WebRtcSessionTest
// TODO Investigate why ChannelManager crashes, if it's created
// after stun_server.
WebRtcSessionTest()
: pss_(new rtc::PhysicalSocketServer),
vss_(new rtc::VirtualSocketServer(pss_.get())),
: vss_(new rtc::VirtualSocketServer()),
fss_(new rtc::FirewallSocketServer(vss_.get())),
thread_(fss_.get()),
media_engine_(new cricket::FakeMediaEngine()),
@ -1503,7 +1501,6 @@ class WebRtcSessionTest
}
webrtc::RtcEventLogNullImpl event_log_;
std::unique_ptr<rtc::PhysicalSocketServer> pss_;
std::unique_ptr<rtc::VirtualSocketServer> vss_;
std::unique_ptr<rtc::FirewallSocketServer> fss_;
rtc::AutoSocketServerThread thread_;