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 const int32 kSocketBufferSize(kMaxPacketSize * 100); // Support 100 packets. |
| 383 socket->SetReceiveBufferSize(kSocketBufferSize); |
| 384 // TODO(jar): What should the UDP send buffer be set to? If the send buffer |
| 385 // is too large, then we might(?) wastefully queue packets in the OS, when |
| 386 // we'd rather construct packets just in time. We do however expect that the |
| 387 // calculated send rate (paced, or ack clocked), will be well below the egress |
| 388 // rate of the local machine, so that *shouldn't* be a problem. |
| 389 // If the buffer setting is too small, then we will starve our outgoing link |
| 390 // on a fast connection, because we won't respond fast enough to the many |
| 391 // async callbacks to get data from us. On the other hand, until we have real |
| 392 // pacing support (beyond ack-clocked pacing), we get a bit of adhoc-pacing by |
| 393 // requiring the application to refill this OS buffer (ensuring that we don't |
| 394 // blast a pile of packets at the kernel's max egress rate). |
| 395 // socket->SetSendBufferSize(????); |
| 396 |
377 QuicConnectionHelper* helper = new QuicConnectionHelper( | 397 QuicConnectionHelper* helper = new QuicConnectionHelper( |
378 base::MessageLoop::current()->message_loop_proxy().get(), | 398 base::MessageLoop::current()->message_loop_proxy().get(), |
379 clock_.get(), | 399 clock_.get(), |
380 random_generator_, | 400 random_generator_, |
381 socket); | 401 socket); |
382 | 402 |
383 QuicConnection* connection = new QuicConnection(guid, addr, helper, false); | 403 QuicConnection* connection = new QuicConnection(guid, addr, helper, false); |
384 | 404 |
385 QuicCryptoClientConfig* crypto_config = | 405 QuicCryptoClientConfig* crypto_config = |
386 GetOrCreateCryptoConfig(host_port_proxy_pair); | 406 GetOrCreateCryptoConfig(host_port_proxy_pair); |
(...skipping 29 matching lines...) Expand all Loading... |
416 DCHECK(crypto_config); | 436 DCHECK(crypto_config); |
417 } else { | 437 } else { |
418 crypto_config = new QuicCryptoClientConfig(); | 438 crypto_config = new QuicCryptoClientConfig(); |
419 crypto_config->SetDefaults(); | 439 crypto_config->SetDefaults(); |
420 all_crypto_configs_[host_port_proxy_pair] = crypto_config; | 440 all_crypto_configs_[host_port_proxy_pair] = crypto_config; |
421 } | 441 } |
422 return crypto_config; | 442 return crypto_config; |
423 } | 443 } |
424 | 444 |
425 } // namespace net | 445 } // namespace net |
OLD | NEW |