Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: net/quic/quic_server_session.cc

Issue 693943003: Update from https://crrev.com/302630 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/quic_server_session.h ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 : QuicSession(connection, config),
20 visitor_(visitor), 20 visitor_(visitor),
21 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()), 21 bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()),
22 last_server_config_update_time_(QuicTime::Zero()) {} 22 last_scup_time_(QuicTime::Zero()),
23 last_scup_sequence_number_(0) {}
23 24
24 QuicServerSession::~QuicServerSession() {} 25 QuicServerSession::~QuicServerSession() {}
25 26
26 void QuicServerSession::InitializeSession( 27 void QuicServerSession::InitializeSession(
27 const QuicCryptoServerConfig& crypto_config) { 28 const QuicCryptoServerConfig& crypto_config) {
28 QuicSession::InitializeSession(); 29 QuicSession::InitializeSession();
29 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config)); 30 crypto_stream_.reset(CreateQuicCryptoServerStream(crypto_config));
30 } 31 }
31 32
32 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream( 33 QuicCryptoServerStream* QuicServerSession::CreateQuicCryptoServerStream(
(...skipping 28 matching lines...) Expand all
61 QuicSession::OnWriteBlocked(); 62 QuicSession::OnWriteBlocked();
62 visitor_->OnWriteBlocked(connection()); 63 visitor_->OnWriteBlocked(connection());
63 } 64 }
64 65
65 void QuicServerSession::OnCongestionWindowChange(QuicTime now) { 66 void QuicServerSession::OnCongestionWindowChange(QuicTime now) {
66 if (connection()->version() <= QUIC_VERSION_21) { 67 if (connection()->version() <= QUIC_VERSION_21) {
67 return; 68 return;
68 } 69 }
69 70
70 // If not enough time has passed since the last time we sent an update to the 71 // If not enough time has passed since the last time we sent an update to the
71 // client, then return early. 72 // client, or not enough packets have been sent, then return early.
72 const QuicSentPacketManager& sent_packet_manager = 73 const QuicSentPacketManager& sent_packet_manager =
73 connection()->sent_packet_manager(); 74 connection()->sent_packet_manager();
74 int64 srtt_ms = 75 int64 srtt_ms =
75 sent_packet_manager.GetRttStats()->SmoothedRtt().ToMilliseconds(); 76 sent_packet_manager.GetRttStats()->SmoothedRtt().ToMilliseconds();
76 int64 now_ms = now.Subtract(last_server_config_update_time_).ToMilliseconds(); 77 int64 now_ms = now.Subtract(last_scup_time_).ToMilliseconds();
78 int64 packets_since_last_scup =
79 connection()->sequence_number_of_last_sent_packet() -
80 last_scup_sequence_number_;
77 if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) || 81 if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) ||
78 now_ms < kMinIntervalBetweenServerConfigUpdatesMs) { 82 now_ms < kMinIntervalBetweenServerConfigUpdatesMs ||
83 packets_since_last_scup < kMinPacketsBetweenServerConfigUpdates) {
79 return; 84 return;
80 } 85 }
81 86
82 // If the bandwidth recorder does not have a valid estimate, return early. 87 // If the bandwidth recorder does not have a valid estimate, return early.
83 const QuicSustainedBandwidthRecorder& bandwidth_recorder = 88 const QuicSustainedBandwidthRecorder& bandwidth_recorder =
84 sent_packet_manager.SustainedBandwidthRecorder(); 89 sent_packet_manager.SustainedBandwidthRecorder();
85 if (!bandwidth_recorder.HasEstimate()) { 90 if (!bandwidth_recorder.HasEstimate()) {
86 return; 91 return;
87 } 92 }
88 93
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 bandwidth_recorder.EstimateRecordedDuringSlowStart() 132 bandwidth_recorder.EstimateRecordedDuringSlowStart()
128 ? CachedNetworkParameters::SLOW_START 133 ? CachedNetworkParameters::SLOW_START
129 : CachedNetworkParameters::CONGESTION_AVOIDANCE); 134 : CachedNetworkParameters::CONGESTION_AVOIDANCE);
130 cached_network_params.set_timestamp( 135 cached_network_params.set_timestamp(
131 connection()->clock()->WallNow().ToUNIXSeconds()); 136 connection()->clock()->WallNow().ToUNIXSeconds());
132 if (!serving_region_.empty()) { 137 if (!serving_region_.empty()) {
133 cached_network_params.set_serving_region(serving_region_); 138 cached_network_params.set_serving_region(serving_region_);
134 } 139 }
135 140
136 crypto_stream_->SendServerConfigUpdate(&cached_network_params); 141 crypto_stream_->SendServerConfigUpdate(&cached_network_params);
137 last_server_config_update_time_ = now; 142 last_scup_time_ = now;
143 last_scup_sequence_number_ =
144 connection()->sequence_number_of_last_sent_packet();
138 } 145 }
139 146
140 bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) { 147 bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) {
141 if (id % 2 == 0) { 148 if (id % 2 == 0) {
142 DVLOG(1) << "Invalid incoming even stream_id:" << id; 149 DVLOG(1) << "Invalid incoming even stream_id:" << id;
143 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID); 150 connection()->SendConnectionClose(QUIC_INVALID_STREAM_ID);
144 return false; 151 return false;
145 } 152 }
146 if (GetNumOpenStreams() >= get_max_open_streams()) { 153 if (GetNumOpenStreams() >= get_max_open_streams()) {
147 DVLOG(1) << "Failed to create a new incoming stream with id:" << id 154 DVLOG(1) << "Failed to create a new incoming stream with id:" << id
(...skipping 17 matching lines...) Expand all
165 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() { 172 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() {
166 DLOG(ERROR) << "Server push not yet supported"; 173 DLOG(ERROR) << "Server push not yet supported";
167 return nullptr; 174 return nullptr;
168 } 175 }
169 176
170 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() { 177 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() {
171 return crypto_stream_.get(); 178 return crypto_stream_.get();
172 } 179 }
173 180
174 } // namespace net 181 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_server_session.h ('k') | net/quic/quic_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698