Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / net / quic / quic_server_session.cc
index aefb021..7fab509 100644 (file)
 
 namespace net {
 
-QuicServerSession::QuicServerSession(
-    const QuicConfig& config,
-    QuicConnection* connection,
-    QuicServerSessionVisitor* visitor)
-    : QuicSession(connection, config),
+QuicServerSession::QuicServerSession(const QuicConfig& config,
+                                     QuicConnection* connection,
+                                     QuicServerSessionVisitor* visitor,
+                                     bool is_secure)
+    : QuicSession(connection, config, is_secure),
       visitor_(visitor),
       bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()),
-      last_server_config_update_time_(QuicTime::Zero()) {}
+      last_scup_time_(QuicTime::Zero()),
+      last_scup_sequence_number_(0) {}
 
 QuicServerSession::~QuicServerSession() {}
 
@@ -52,7 +53,7 @@ void QuicServerSession::OnConnectionClosed(QuicErrorCode error,
   QuicSession::OnConnectionClosed(error, from_peer);
   // In the unlikely event we get a connection close while doing an asynchronous
   // crypto event, make sure we cancel the callback.
-  if (crypto_stream_.get() != NULL) {
+  if (crypto_stream_.get() != nullptr) {
     crypto_stream_->CancelOutstandingCallbacks();
   }
   visitor_->OnConnectionClosed(connection()->connection_id(), error);
@@ -69,14 +70,18 @@ void QuicServerSession::OnCongestionWindowChange(QuicTime now) {
   }
 
   // If not enough time has passed since the last time we sent an update to the
-  // client, then return early.
+  // client, or not enough packets have been sent, then return early.
   const QuicSentPacketManager& sent_packet_manager =
       connection()->sent_packet_manager();
   int64 srtt_ms =
-      sent_packet_manager.GetRttStats()->SmoothedRtt().ToMilliseconds();
-  int64 now_ms = now.Subtract(last_server_config_update_time_).ToMilliseconds();
+      sent_packet_manager.GetRttStats()->smoothed_rtt().ToMilliseconds();
+  int64 now_ms = now.Subtract(last_scup_time_).ToMilliseconds();
+  int64 packets_since_last_scup =
+      connection()->sequence_number_of_last_sent_packet() -
+      last_scup_sequence_number_;
   if (now_ms < (kMinIntervalBetweenServerConfigUpdatesRTTs * srtt_ms) ||
-      now_ms < kMinIntervalBetweenServerConfigUpdatesMs) {
+      now_ms < kMinIntervalBetweenServerConfigUpdatesMs ||
+      packets_since_last_scup < kMinPacketsBetweenServerConfigUpdates) {
     return;
   }
 
@@ -128,12 +133,16 @@ void QuicServerSession::OnCongestionWindowChange(QuicTime now) {
       bandwidth_recorder.EstimateRecordedDuringSlowStart()
           ? CachedNetworkParameters::SLOW_START
           : CachedNetworkParameters::CONGESTION_AVOIDANCE);
+  cached_network_params.set_timestamp(
+      connection()->clock()->WallNow().ToUNIXSeconds());
   if (!serving_region_.empty()) {
     cached_network_params.set_serving_region(serving_region_);
   }
 
   crypto_stream_->SendServerConfigUpdate(&cached_network_params);
-  last_server_config_update_time_ = now;
+  last_scup_time_ = now;
+  last_scup_sequence_number_ =
+      connection()->sequence_number_of_last_sent_packet();
 }
 
 bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) {
@@ -155,7 +164,7 @@ bool QuicServerSession::ShouldCreateIncomingDataStream(QuicStreamId id) {
 QuicDataStream* QuicServerSession::CreateIncomingDataStream(
     QuicStreamId id) {
   if (!ShouldCreateIncomingDataStream(id)) {
-    return NULL;
+    return nullptr;
   }
 
   return new QuicSpdyServerStream(id, this);
@@ -163,7 +172,7 @@ QuicDataStream* QuicServerSession::CreateIncomingDataStream(
 
 QuicDataStream* QuicServerSession::CreateOutgoingDataStream() {
   DLOG(ERROR) << "Server push not yet supported";
-  return NULL;
+  return nullptr;
 }
 
 QuicCryptoServerStream* QuicServerSession::GetCryptoStream() {