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

Unified Diff: net/quic/quic_stream_factory.cc

Issue 127463003: Completely disable use of bind() with pseudo-random port selection on Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: On Windows, avoid "port selection" in Stable or Beta channels automatically Created 6 years, 11 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 | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_stream_factory.cc
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index a31b5cb15b21c93247a7daad8edb7c06188d50a9..22bb8746c0651ac2f3deb1b63b2102278ab8bba0 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -277,7 +277,8 @@ QuicStreamFactory::QuicStreamFactory(
QuicRandom* random_generator,
QuicClock* clock,
size_t max_packet_length,
- const QuicVersionVector& supported_versions)
+ const QuicVersionVector& supported_versions,
+ bool enable_port_selection)
: require_confirmation_(true),
host_resolver_(host_resolver),
client_socket_factory_(client_socket_factory),
@@ -287,6 +288,7 @@ QuicStreamFactory::QuicStreamFactory(
clock_(clock),
max_packet_length_(max_packet_length),
supported_versions_(supported_versions),
+ enable_port_selection_(enable_port_selection),
port_seed_(random_generator_->RandUint64()),
weak_factory_(this) {
config_.SetDefaults();
@@ -514,9 +516,12 @@ int QuicStreamFactory::CreateSession(
IPEndPoint addr = *address_list.begin();
scoped_refptr<PortSuggester> port_suggester =
new PortSuggester(host_port_proxy_pair.first, port_seed_);
+ DatagramSocket::BindType bind_type = enable_port_selection_ ?
+ DatagramSocket::RANDOM_BIND : // Use our callback.
+ DatagramSocket::DEFAULT_BIND; // Use OS to randomize.
scoped_ptr<DatagramClientSocket> socket(
client_socket_factory_->CreateDatagramClientSocket(
- DatagramSocket::RANDOM_BIND,
+ bind_type,
base::Bind(&PortSuggester::SuggestPort, port_suggester),
net_log.net_log(), net_log.source()));
int rv = socket->Connect(addr);
@@ -524,7 +529,11 @@ int QuicStreamFactory::CreateSession(
return rv;
UMA_HISTOGRAM_COUNTS("Net.QuicEphemeralPortsSuggested",
port_suggester->call_count());
- DCHECK_LE(1u, port_suggester->call_count());
+ if (enable_port_selection_) {
+ DCHECK_LE(1u, port_suggester->call_count());
+ } else {
+ DCHECK_EQ(0u, port_suggester->call_count());
+ }
// We should adaptively set this buffer size, but for now, we'll use a size
// that is more than large enough for a full receive window, and yet
« no previous file with comments | « net/quic/quic_stream_factory.h ('k') | net/quic/quic_stream_factory_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698