Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: webrtc/base/virtualsocketserver.cc

Issue 2883313003: Remove VirtualSocketServer's dependency on PhysicalSocketServer. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/virtualsocketserver.h ('k') | webrtc/ortc/ortcfactory_integrationtest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/virtualsocketserver.cc
diff --git a/webrtc/base/virtualsocketserver.cc b/webrtc/base/virtualsocketserver.cc
index 9845725da6f573d7031c4ec954bd4c28ec739985..9ba6a2f7fa655a4042f865f1296351a829fdc7db 100644
--- a/webrtc/base/virtualsocketserver.cc
+++ b/webrtc/base/virtualsocketserver.cc
@@ -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() {
« no previous file with comments | « webrtc/base/virtualsocketserver.h ('k') | webrtc/ortc/ortcfactory_integrationtest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698