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

Unified Diff: net/socket/socket_test_util.cc

Issue 107803002: Consistently suggest ephemeral port for QUIC client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pulled together duplicate code in socket_test_util.cc Created 7 years 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
Index: net/socket/socket_test_util.cc
diff --git a/net/socket/socket_test_util.cc b/net/socket/socket_test_util.cc
index 148b11c5698927c210c7a8b46b7b0224313b3d03..95b1a38f00950c66627886b6c41032ac2d66c988 100644
--- a/net/socket/socket_test_util.cc
+++ b/net/socket/socket_test_util.cc
@@ -123,6 +123,15 @@ void DumpMockReadWrite(const MockReadWrite<type>& r) {
<< "\nTime: " << r.time_stamp.ToInternalValue();
}
+void ExerciseSocketRandomNumberGenerator(const RandIntCallback& rand_int_cb) {
+ // Socket connect is supposed to call for some random suggestions for ports.
+ // We call 3 times so that the quic_stream_factory will know this function
+ // was consulted (it has a DCHECK), but will not actually DCHECK the
+ // resulting ephemeral port (which we don't set).
+ for (int count = 3; count > 0; --count)
+ rand_int_cb.Run(1000, 2000);
+}
+
} // namespace
MockConnect::MockConnect() : mode(ASYNC), result(OK) {
@@ -663,6 +672,7 @@ MockClientSocketFactory::CreateDatagramClientSocket(
const RandIntCallback& rand_int_cb,
net::NetLog* net_log,
const net::NetLog::Source& source) {
+ ExerciseSocketRandomNumberGenerator(rand_int_cb);
Ryan Hamilton 2013/12/08 22:54:15 Instead of invoking the callback simply to work ar
Ryan Hamilton 2013/12/09 04:15:50 I realized that if you make this change, then it s
SocketDataProvider* data_provider = mock_data_.GetNext();
scoped_ptr<MockUDPClientSocket> socket(
new MockUDPClientSocket(data_provider, net_log));
@@ -1803,6 +1813,7 @@ DeterministicMockClientSocketFactory::CreateDatagramClientSocket(
const RandIntCallback& rand_int_cb,
net::NetLog* net_log,
const NetLog::Source& source) {
+ ExerciseSocketRandomNumberGenerator(rand_int_cb);
DeterministicSocketData* data_provider = mock_data().GetNext();
scoped_ptr<DeterministicMockUDPClientSocket> socket(
new DeterministicMockUDPClientSocket(net_log, data_provider));

Powered by Google App Engine
This is Rietveld 408576698