OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_stream_factory.h" | 5 #include "net/quic/quic_stream_factory.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | |
9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
10 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "net/dns/host_resolver.h" | 16 #include "net/dns/host_resolver.h" |
16 #include "net/dns/single_request_host_resolver.h" | 17 #include "net/dns/single_request_host_resolver.h" |
17 #include "net/quic/crypto/quic_random.h" | 18 #include "net/quic/crypto/quic_random.h" |
18 #include "net/quic/quic_client_session.h" | 19 #include "net/quic/quic_client_session.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
367 const AddressList& address_list, | 368 const AddressList& address_list, |
368 const BoundNetLog& net_log) { | 369 const BoundNetLog& net_log) { |
369 QuicGuid guid = random_generator_->RandUint64(); | 370 QuicGuid guid = random_generator_->RandUint64(); |
370 IPEndPoint addr = *address_list.begin(); | 371 IPEndPoint addr = *address_list.begin(); |
371 DatagramClientSocket* socket = | 372 DatagramClientSocket* socket = |
372 client_socket_factory_->CreateDatagramClientSocket( | 373 client_socket_factory_->CreateDatagramClientSocket( |
373 DatagramSocket::DEFAULT_BIND, base::Bind(&base::RandInt), | 374 DatagramSocket::DEFAULT_BIND, base::Bind(&base::RandInt), |
374 net_log.net_log(), net_log.source()); | 375 net_log.net_log(), net_log.source()); |
375 socket->Connect(addr); | 376 socket->Connect(addr); |
376 | 377 |
378 // We should adaptively set this buffer size, but for now, we'll use a size | |
379 // that is more than large enough for a 100 packet congestion window, and yet | |
380 // does not consume "too much" memory. If we see bursty packet loss, we may | |
381 // revisit this setting and test for its impact. | |
382 int32 const kSocketBufferSize(1200 * 100); // Support 100 packets. | |
Ryan Hamilton
2013/06/20 03:42:23
nit: in quic_protocol.h, we have kMaxPacketSize =
jar (doing other things)
2013/06/20 21:45:51
Done.
| |
383 DLOG(INFO) << "QUIC socket receive buffer set to " << kSocketBufferSize; | |
Ryan Hamilton
2013/06/20 03:42:23
super minor nit: Do we really need this log line?
jar (doing other things)
2013/06/20 21:45:51
Mixed feeelings.... but since it bothered you, it
| |
384 socket->SetReceiveBufferSize(kSocketBufferSize); | |
Ryan Hamilton
2013/06/20 03:42:23
I don't think this is worth doing, but for the sak
jar (doing other things)
2013/06/20 21:45:51
Yeah... probably a good idea... I'd rather get thi
| |
385 // What should the send buffer be set to? If the send buffer is too large, | |
Ryan Hamilton
2013/06/20 03:42:23
nit: Add TODO(jar): (or TODO(rch)?) to this comme
jar (doing other things)
2013/06/20 21:45:51
Done.
| |
386 // then we might(?) wastefully queue packets in the OS, when we'd rather | |
387 // construct packets just in time. If this is too small, then we will starve | |
388 // our outgoing link on a fast connection, because we won't respond fast | |
389 // enough to the many async callbacks to get data from us. We also buy a bit | |
390 // of adhoc-pacing by requiring the application to refill this OS buffer | |
391 // (ensuring that we don't blast a pile of packets at the kernel's max egress | |
392 // rate). | |
393 // socket->SetSendBufferSize(kSocketBufferSize?? other??); | |
394 | |
377 QuicConnectionHelper* helper = new QuicConnectionHelper( | 395 QuicConnectionHelper* helper = new QuicConnectionHelper( |
378 base::MessageLoop::current()->message_loop_proxy().get(), | 396 base::MessageLoop::current()->message_loop_proxy().get(), |
379 clock_.get(), | 397 clock_.get(), |
380 random_generator_, | 398 random_generator_, |
381 socket); | 399 socket); |
382 | 400 |
383 QuicConnection* connection = new QuicConnection(guid, addr, helper, false); | 401 QuicConnection* connection = new QuicConnection(guid, addr, helper, false); |
384 | 402 |
385 QuicCryptoClientConfig* crypto_config = | 403 QuicCryptoClientConfig* crypto_config = |
386 GetOrCreateCryptoConfig(host_port_proxy_pair); | 404 GetOrCreateCryptoConfig(host_port_proxy_pair); |
(...skipping 29 matching lines...) Expand all Loading... | |
416 DCHECK(crypto_config); | 434 DCHECK(crypto_config); |
417 } else { | 435 } else { |
418 crypto_config = new QuicCryptoClientConfig(); | 436 crypto_config = new QuicCryptoClientConfig(); |
419 crypto_config->SetDefaults(); | 437 crypto_config->SetDefaults(); |
420 all_crypto_configs_[host_port_proxy_pair] = crypto_config; | 438 all_crypto_configs_[host_port_proxy_pair] = crypto_config; |
421 } | 439 } |
422 return crypto_config; | 440 return crypto_config; |
423 } | 441 } |
424 | 442 |
425 } // namespace net | 443 } // namespace net |
OLD | NEW |