| 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/cpu.h" | 9 #include "base/cpu.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 enum CreateSessionFailure { | 49 enum CreateSessionFailure { |
| 50 CREATION_ERROR_CONNECTING_SOCKET, | 50 CREATION_ERROR_CONNECTING_SOCKET, |
| 51 CREATION_ERROR_SETTING_RECEIVE_BUFFER, | 51 CREATION_ERROR_SETTING_RECEIVE_BUFFER, |
| 52 CREATION_ERROR_SETTING_SEND_BUFFER, | 52 CREATION_ERROR_SETTING_SEND_BUFFER, |
| 53 CREATION_ERROR_MAX | 53 CREATION_ERROR_MAX |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 // The initial receive window size for both streams and sessions. | 56 // The initial receive window size for both streams and sessions. |
| 57 const int32 kInitialReceiveWindowSize = 10 * 1024 * 1024; // 10MB | 57 const int32 kInitialReceiveWindowSize = 10 * 1024 * 1024; // 10MB |
| 58 | 58 |
| 59 // The suggested initial congestion windows for a server to use. |
| 60 // TODO: This should be tested and optimized, and even better, suggest a window |
| 61 // that corresponds to historical bandwidth and min-RTT. |
| 62 // Larger initial congestion windows can, if we don't overshoot, reduce latency |
| 63 // by avoiding the RTT needed for slow start to double (and re-double) from a |
| 64 // default of 10. |
| 65 // We match SPDY's use of 32 when secure (since we'd compete with SPDY). |
| 66 const int32 kServerSecureInitialCongestionWindow = 32; |
| 67 // Be conservative, and just use double a typical TCP ICWND for HTTP. |
| 68 const int32 kServerInecureInitialCongestionWindow = 20; |
| 69 |
| 59 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { | 70 void HistogramCreateSessionFailure(enum CreateSessionFailure error) { |
| 60 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, | 71 UMA_HISTOGRAM_ENUMERATION("Net.QuicSession.CreationError", error, |
| 61 CREATION_ERROR_MAX); | 72 CREATION_ERROR_MAX); |
| 62 } | 73 } |
| 63 | 74 |
| 64 bool IsEcdsaSupported() { | 75 bool IsEcdsaSupported() { |
| 65 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 66 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 77 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 67 return false; | 78 return false; |
| 68 #endif | 79 #endif |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 | 747 |
| 737 QuicConnection* connection = | 748 QuicConnection* connection = |
| 738 new QuicConnection(connection_id, addr, helper_.get(), writer.get(), | 749 new QuicConnection(connection_id, addr, helper_.get(), writer.get(), |
| 739 false, supported_versions_, kInitialReceiveWindowSize); | 750 false, supported_versions_, kInitialReceiveWindowSize); |
| 740 writer->SetConnection(connection); | 751 writer->SetConnection(connection); |
| 741 connection->options()->max_packet_length = max_packet_length_; | 752 connection->options()->max_packet_length = max_packet_length_; |
| 742 | 753 |
| 743 InitializeCachedStateInCryptoConfig(server_id, server_info); | 754 InitializeCachedStateInCryptoConfig(server_id, server_info); |
| 744 | 755 |
| 745 QuicConfig config = config_; | 756 QuicConfig config = config_; |
| 757 config_.SetInitialCongestionWindowToSend( |
| 758 server_id.is_https() ? kServerSecureInitialCongestionWindow |
| 759 : kServerInecureInitialCongestionWindow); |
| 746 if (http_server_properties_) { | 760 if (http_server_properties_) { |
| 747 const HttpServerProperties::NetworkStats* stats = | 761 const HttpServerProperties::NetworkStats* stats = |
| 748 http_server_properties_->GetServerNetworkStats( | 762 http_server_properties_->GetServerNetworkStats( |
| 749 server_id.host_port_pair()); | 763 server_id.host_port_pair()); |
| 750 if (stats != NULL) { | 764 if (stats != NULL) { |
| 751 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); | 765 config.SetInitialRoundTripTimeUsToSend(stats->srtt.InMicroseconds()); |
| 752 } | 766 } |
| 753 } | 767 } |
| 754 | 768 |
| 755 *session = new QuicClientSession( | 769 *session = new QuicClientSession( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 } | 836 } |
| 823 | 837 |
| 824 HttpServerProperties::NetworkStats network_stats; | 838 HttpServerProperties::NetworkStats network_stats; |
| 825 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); | 839 network_stats.srtt = base::TimeDelta::FromMicroseconds(stats.srtt_us); |
| 826 network_stats.bandwidth_estimate = stats.estimated_bandwidth; | 840 network_stats.bandwidth_estimate = stats.estimated_bandwidth; |
| 827 http_server_properties_->SetServerNetworkStats(server_id.host_port_pair(), | 841 http_server_properties_->SetServerNetworkStats(server_id.host_port_pair(), |
| 828 network_stats); | 842 network_stats); |
| 829 } | 843 } |
| 830 | 844 |
| 831 } // namespace net | 845 } // namespace net |
| OLD | NEW |