| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_server_session.h" | 5 #include "net/quic/quic_server_session.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "net/quic/crypto/source_address_token.h" | 8 #include "net/quic/crypto/source_address_token.h" |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| 11 #include "net/quic/quic_spdy_server_stream.h" | 11 #include "net/quic/quic_spdy_server_stream.h" |
| 12 #include "net/quic/reliable_quic_stream.h" | 12 #include "net/quic/reliable_quic_stream.h" |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 | 15 |
| 16 QuicServerSession::QuicServerSession(const QuicConfig& config, | 16 QuicServerSession::QuicServerSession(const QuicConfig& config, |
| 17 QuicConnection* connection, | 17 QuicConnection* connection, |
| 18 QuicServerSessionVisitor* visitor) | 18 QuicServerSessionVisitor* visitor, |
| 19 : QuicSession(connection, config), | 19 bool is_secure) |
| 20 : QuicSession(connection, config, is_secure), |
| 20 visitor_(visitor), | 21 visitor_(visitor), |
| 21 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), | 22 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), |
| 22 last_scup_time_(QuicTime::Zero()), | 23 last_scup_time_(QuicTime::Zero()), |
| 23 last_scup_sequence_number_(0) {} | 24 last_scup_sequence_number_(0) {} |
| 24 | 25 |
| 25 QuicServerSession::~QuicServerSession() {} | 26 QuicServerSession::~QuicServerSession() {} |
| 26 | 27 |
| 27 void QuicServerSession::InitializeSession( | 28 void QuicServerSession::InitializeSession( |
| 28 const QuicCryptoServerConfig& crypto_config) { | 29 const QuicCryptoServerConfig& crypto_config) { |
| 29 QuicSession::InitializeSession(); | 30 QuicSession::InitializeSession(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 void QuicServerSession::OnCongestionWindowChange(QuicTime now) { | 67 void QuicServerSession::OnCongestionWindowChange(QuicTime now) { |
| 67 if (connection()->version() <= QUIC_VERSION_21) { | 68 if (connection()->version() <= QUIC_VERSION_21) { |
| 68 return; | 69 return; |
| 69 } | 70 } |
| 70 | 71 |
| 71 // If not enough time has passed since the last time we sent an update to the | 72 // If not enough time has passed since the last time we sent an update to the |
| 72 // client, or not enough packets have been sent, then return early. | 73 // client, or not enough packets have been sent, then return early. |
| 73 const QuicSentPacketManager& sent_packet_manager = | 74 const QuicSentPacketManager& sent_packet_manager = |
| 74 connection()->sent_packet_manager(); | 75 connection()->sent_packet_manager(); |
| 75 int64 srtt_ms = | 76 int64 srtt_ms = |
| 76 sent_packet_manager.GetRttStats()->SmoothedRtt().ToMilliseconds(); | 77 sent_packet_manager.GetRttStats()->smoothed_rtt().ToMilliseconds(); |
| 77 int64 now_ms = now.Subtract(last_scup_time_).ToMilliseconds(); | 78 int64 now_ms = now.Subtract(last_scup_time_).ToMilliseconds(); |
| 78 int64 packets_since_last_scup = | 79 int64 packets_since_last_scup = |
| 79 connection()->sequence_number_of_last_sent_packet() - | 80 connection()->sequence_number_of_last_sent_packet() - |
| 80 last_scup_sequence_number_; | 81 last_scup_sequence_number_; |
| 81 if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) || | 82 if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) || |
| 82 now_ms < kMinIntervalBetweenServerConfigUpdatesMs || | 83 now_ms < kMinIntervalBetweenServerConfigUpdatesMs || |
| 83 packets_since_last_scup < kMinPacketsBetweenServerConfigUpdates) { | 84 packets_since_last_scup < kMinPacketsBetweenServerConfigUpdates) { |
| 84 return; | 85 return; |
| 85 } | 86 } |
| 86 | 87 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 121 |
| 121 // Fill the proto before passing it to the crypto stream to send. | 122 // Fill the proto before passing it to the crypto stream to send. |
| 122 CachedNetworkParameters cached_network_params; | 123 CachedNetworkParameters cached_network_params; |
| 123 cached_network_params.set_bandwidth_estimate_bytes_per_second( | 124 cached_network_params.set_bandwidth_estimate_bytes_per_second( |
| 124 bandwidth_estimate_sent_to_client_.ToBytesPerSecond()); | 125 bandwidth_estimate_sent_to_client_.ToBytesPerSecond()); |
| 125 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( | 126 cached_network_params.set_max_bandwidth_estimate_bytes_per_second( |
| 126 max_bandwidth_estimate.ToBytesPerSecond()); | 127 max_bandwidth_estimate.ToBytesPerSecond()); |
| 127 cached_network_params.set_max_bandwidth_timestamp_seconds( | 128 cached_network_params.set_max_bandwidth_timestamp_seconds( |
| 128 max_bandwidth_timestamp); | 129 max_bandwidth_timestamp); |
| 129 cached_network_params.set_min_rtt_ms( | 130 cached_network_params.set_min_rtt_ms( |
| 130 sent_packet_manager.GetRttStats()->MinRtt().ToMilliseconds()); | 131 sent_packet_manager.GetRttStats()->min_rtt().ToMilliseconds()); |
| 131 cached_network_params.set_previous_connection_state( | 132 cached_network_params.set_previous_connection_state( |
| 132 bandwidth_recorder.EstimateRecordedDuringSlowStart() | 133 bandwidth_recorder.EstimateRecordedDuringSlowStart() |
| 133 ? CachedNetworkParameters::SLOW_START | 134 ? CachedNetworkParameters::SLOW_START |
| 134 : CachedNetworkParameters::CONGESTION_AVOIDANCE); | 135 : CachedNetworkParameters::CONGESTION_AVOIDANCE); |
| 135 cached_network_params.set_timestamp( | 136 cached_network_params.set_timestamp( |
| 136 connection()->clock()->WallNow().ToUNIXSeconds()); | 137 connection()->clock()->WallNow().ToUNIXSeconds()); |
| 137 if (!serving_region_.empty()) { | 138 if (!serving_region_.empty()) { |
| 138 cached_network_params.set_serving_region(serving_region_); | 139 cached_network_params.set_serving_region(serving_region_); |
| 139 } | 140 } |
| 140 | 141 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() { | 173 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() { |
| 173 DLOG(ERROR) << "Server push not yet supported"; | 174 DLOG(ERROR) << "Server push not yet supported"; |
| 174 return nullptr; | 175 return nullptr; |
| 175 } | 176 } |
| 176 | 177 |
| 177 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { | 178 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { |
| 178 return crypto_stream_.get(); | 179 return crypto_stream_.get(); |
| 179 } | 180 } |
| 180 | 181 |
| 181 } // namespace net | 182 } // namespace net |
| OLD | NEW |