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