Update from chromium https://crrev.com/304586

Review URL: https://codereview.chromium.org/732423002
diff --git a/net/quic/congestion_control/hybrid_slow_start.cc b/net/quic/congestion_control/hybrid_slow_start.cc
index 4b1e842..e3789b4 100644
--- a/net/quic/congestion_control/hybrid_slow_start.cc
+++ b/net/quic/congestion_control/hybrid_slow_start.cc
@@ -23,6 +23,7 @@
 
 HybridSlowStart::HybridSlowStart(const QuicClock* clock)
     : clock_(clock),
+      ack_train_detection_(true),
       started_(false),
       hystart_found_(NOT_FOUND),
       last_sent_sequence_number_(0),
@@ -84,12 +85,8 @@
   // more than the capacity.
   // This first trigger will not come into play until we hit roughly 9.6 Mbps
   // with delayed acks (or 4.8Mbps without delayed acks)
-  // TODO(ianswett): QUIC always uses delayed acks, even at the beginning, so
-  // this should likely be at least 4ms.
-  // TODO(pwestin): we need to make sure our pacing don't trigger this detector.
-  // TODO(ianswett): Pacing or other cases could be handled by checking the send
-  // time of the first acked packet in a receive round.
-  if (current_time.Subtract(last_close_ack_pair_time_).ToMicroseconds() <=
+  if (ack_train_detection_ &&
+      current_time.Subtract(last_close_ack_pair_time_).ToMicroseconds() <=
           kHybridStartDelayMinThresholdUs) {
     last_close_ack_pair_time_ = current_time;
     if (current_time.Subtract(round_start_).ToMicroseconds() >=
diff --git a/net/quic/congestion_control/hybrid_slow_start.h b/net/quic/congestion_control/hybrid_slow_start.h
index 5d36c53..cee9a60 100644
--- a/net/quic/congestion_control/hybrid_slow_start.h
+++ b/net/quic/congestion_control/hybrid_slow_start.h
@@ -53,6 +53,14 @@
   // Call for the start of each receive round (burst) in the slow start phase.
   void StartReceiveRound(QuicPacketSequenceNumber last_sent);
 
+  void set_ack_train_detection(bool ack_train_detection) {
+    ack_train_detection_ = ack_train_detection;
+  }
+
+  bool ack_train_detection() const {
+    return ack_train_detection_;
+  }
+
   // Whether slow start has started.
   bool started() const {
     return started_;
@@ -67,6 +75,7 @@
   };
 
   const QuicClock* clock_;
+  bool ack_train_detection_;
   // Whether the hybrid slow start has been started.
   bool started_;
   HystartState hystart_found_;
diff --git a/net/quic/congestion_control/hybrid_slow_start_test.cc b/net/quic/congestion_control/hybrid_slow_start_test.cc
index dd74933..bcdf8d9 100644
--- a/net/quic/congestion_control/hybrid_slow_start_test.cc
+++ b/net/quic/congestion_control/hybrid_slow_start_test.cc
@@ -54,26 +54,33 @@
   // At a typical RTT 60 ms, assuming that the inter arrival timestamp is 1 ms,
   // we expect to be able to send a burst of 30 packet before we trigger the
   // ack train detection.
-  const int kMaxLoopCount = 5;
-  QuicPacketSequenceNumber sequence_number = 2;
-  QuicPacketSequenceNumber end_sequence_number = 2;
-  for (int burst = 0; burst < kMaxLoopCount; ++burst) {
+  // Run this test for both enabled and disabled ack train detection.
+  for (int i = 0; i < 2; ++i) {
+    const bool ack_train_detection = (i == 1);
+    slow_start_->set_ack_train_detection(ack_train_detection);
+
+    const int kMaxLoopCount = 5;
+    QuicPacketSequenceNumber sequence_number = 2;
+    QuicPacketSequenceNumber end_sequence_number = 2;
+    for (int burst = 0; burst < kMaxLoopCount; ++burst) {
+      slow_start_->StartReceiveRound(end_sequence_number);
+      do {
+        clock_.AdvanceTime(one_ms_);
+        EXPECT_FALSE(slow_start_->ShouldExitSlowStart(rtt_, rtt_, 100));
+      } while (!slow_start_->IsEndOfRound(sequence_number++));
+      end_sequence_number *= 2;  // Exponential growth.
+    }
     slow_start_->StartReceiveRound(end_sequence_number);
-    do {
+
+    for (int n = 0;
+         n < 29 && !slow_start_->IsEndOfRound(sequence_number++); ++n) {
       clock_.AdvanceTime(one_ms_);
       EXPECT_FALSE(slow_start_->ShouldExitSlowStart(rtt_, rtt_, 100));
-    }  while (!slow_start_->IsEndOfRound(sequence_number++));
-    end_sequence_number *= 2;  // Exponential growth.
-  }
-  slow_start_->StartReceiveRound(end_sequence_number);
-
-  for (int n = 0;
-       n < 29 && !slow_start_->IsEndOfRound(sequence_number++); ++n) {
+    }
     clock_.AdvanceTime(one_ms_);
-    EXPECT_FALSE(slow_start_->ShouldExitSlowStart(rtt_, rtt_, 100));
+    EXPECT_EQ(ack_train_detection,
+              slow_start_->ShouldExitSlowStart(rtt_, rtt_, 100));
   }
-  clock_.AdvanceTime(one_ms_);
-  EXPECT_TRUE(slow_start_->ShouldExitSlowStart(rtt_, rtt_, 100));
 }
 
 TEST_F(HybridSlowStartTest, Delay) {
diff --git a/net/quic/congestion_control/leaky_bucket.cc b/net/quic/congestion_control/leaky_bucket.cc
deleted file mode 100644
index f3972f6..0000000
--- a/net/quic/congestion_control/leaky_bucket.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "net/quic/congestion_control/leaky_bucket.h"
-
-#include "base/time/time.h"
-
-namespace net {
-
-LeakyBucket::LeakyBucket(QuicBandwidth draining_rate)
-    : bytes_(0),
-      time_last_updated_(QuicTime::Zero()),
-      draining_rate_(draining_rate) {
-}
-
-void LeakyBucket::SetDrainingRate(QuicTime now, QuicBandwidth draining_rate) {
-  Update(now);
-  draining_rate_ = draining_rate;
-}
-
-void LeakyBucket::Add(QuicTime now, QuicByteCount bytes) {
-  Update(now);
-  bytes_ += bytes;
-}
-
-QuicTime::Delta LeakyBucket::TimeRemaining(QuicTime now) const {
-  QuicTime::Delta time_since_last_update = now.Subtract(time_last_updated_);
-  QuicTime::Delta send_delay = QuicTime::Delta::FromMicroseconds(
-      (bytes_ * base::Time::kMicrosecondsPerSecond) /
-      draining_rate_.ToBytesPerSecond());
-  if (send_delay < time_since_last_update) {
-    return QuicTime::Delta::Zero();
-  }
-  return send_delay.Subtract(time_since_last_update);
-}
-
-QuicByteCount LeakyBucket::BytesPending(QuicTime now) {
-  Update(now);
-  return bytes_;
-}
-
-void LeakyBucket::Update(QuicTime now) {
-  QuicTime::Delta elapsed_time = now.Subtract(time_last_updated_);
-  QuicByteCount bytes_cleared = draining_rate_.ToBytesPerPeriod(elapsed_time);
-  if (bytes_cleared >= bytes_) {
-    bytes_ = 0;
-  } else {
-    bytes_ -= bytes_cleared;
-  }
-  time_last_updated_ = now;
-}
-
-}  // namespace net
diff --git a/net/quic/congestion_control/leaky_bucket.h b/net/quic/congestion_control/leaky_bucket.h
deleted file mode 100644
index eb4cdb0..0000000
--- a/net/quic/congestion_control/leaky_bucket.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-// Helper class to track the rate data can leave the buffer for pacing.
-// A leaky bucket drains the data at a constant rate regardless of fullness of
-// the buffer.
-// See http://en.wikipedia.org/wiki/Leaky_bucket for more details.
-
-#ifndef NET_QUIC_CONGESTION_CONTROL_LEAKY_BUCKET_H_
-#define NET_QUIC_CONGESTION_CONTROL_LEAKY_BUCKET_H_
-
-#include "base/basictypes.h"
-#include "net/base/net_export.h"
-#include "net/quic/quic_bandwidth.h"
-#include "net/quic/quic_protocol.h"
-#include "net/quic/quic_time.h"
-
-namespace net {
-
-class NET_EXPORT_PRIVATE LeakyBucket {
- public:
-  explicit LeakyBucket(QuicBandwidth draining_rate);
-
-  // Set the rate at which the bytes leave the buffer.
-  void SetDrainingRate(QuicTime now, QuicBandwidth draining_rate);
-
-  // Add data to the buffer.
-  void Add(QuicTime now, QuicByteCount bytes);
-
-  // Time until the buffer is empty.
-  QuicTime::Delta TimeRemaining(QuicTime now) const;
-
-  // Number of bytes in the buffer.
-  QuicByteCount BytesPending(QuicTime now);
-
- private:
-  void Update(QuicTime now);
-
-  QuicByteCount bytes_;
-  QuicTime time_last_updated_;
-  QuicBandwidth draining_rate_;
-
-  DISALLOW_COPY_AND_ASSIGN(LeakyBucket);
-};
-
-}  // namespace net
-
-#endif  // NET_QUIC_CONGESTION_CONTROL_LEAKY_BUCKET_H_
diff --git a/net/quic/congestion_control/leaky_bucket_test.cc b/net/quic/congestion_control/leaky_bucket_test.cc
deleted file mode 100644
index 8387ada..0000000
--- a/net/quic/congestion_control/leaky_bucket_test.cc
+++ /dev/null
@@ -1,75 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "base/logging.h"
-#include "base/memory/scoped_ptr.h"
-#include "net/quic/congestion_control/leaky_bucket.h"
-#include "net/quic/test_tools/mock_clock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace net {
-namespace test {
-
-class LeakyBucketTest : public ::testing::Test {
- protected:
-  void SetUp() override {
-    leaky_bucket_.reset(new LeakyBucket(QuicBandwidth::Zero()));
-  }
-  MockClock clock_;
-  scoped_ptr<LeakyBucket> leaky_bucket_;
-};
-
-TEST_F(LeakyBucketTest, Basic) {
-  QuicBandwidth draining_rate = QuicBandwidth::FromBytesPerSecond(200000);
-  leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate);
-  leaky_bucket_->Add(clock_.Now(), 2000);
-  EXPECT_EQ(2000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  EXPECT_EQ(1000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(5),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  EXPECT_EQ(0u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_TRUE(leaky_bucket_->TimeRemaining(clock_.Now()).IsZero());
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  EXPECT_EQ(0u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_TRUE(leaky_bucket_->TimeRemaining(clock_.Now()).IsZero());
-  leaky_bucket_->Add(clock_.Now(), 2000);
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(11));
-  EXPECT_EQ(0u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_TRUE(leaky_bucket_->TimeRemaining(clock_.Now()).IsZero());
-  leaky_bucket_->Add(clock_.Now(), 2000);
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  leaky_bucket_->Add(clock_.Now(), 2000);
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  EXPECT_EQ(2000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(10));
-  EXPECT_EQ(0u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_TRUE(leaky_bucket_->TimeRemaining(clock_.Now()).IsZero());
-}
-
-TEST_F(LeakyBucketTest, ChangeDrainRate) {
-  QuicBandwidth draining_rate = QuicBandwidth::FromBytesPerSecond(200000);
-  leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate);
-  leaky_bucket_->Add(clock_.Now(), 2000);
-  EXPECT_EQ(2000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-  clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-  EXPECT_EQ(1000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(5),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-  draining_rate = draining_rate.Scale(0.5f);  // Cut drain rate in half.
-  leaky_bucket_->SetDrainingRate(clock_.Now(), draining_rate);
-  EXPECT_EQ(1000u, leaky_bucket_->BytesPending(clock_.Now()));
-  EXPECT_EQ(QuicTime::Delta::FromMilliseconds(10),
-            leaky_bucket_->TimeRemaining(clock_.Now()));
-}
-
-}  // namespace test
-}  // namespace net
diff --git a/net/quic/congestion_control/pacing_sender.cc b/net/quic/congestion_control/pacing_sender.cc
index 061f6ec..8073c5b 100644
--- a/net/quic/congestion_control/pacing_sender.cc
+++ b/net/quic/congestion_control/pacing_sender.cc
@@ -20,8 +20,11 @@
 
 PacingSender::~PacingSender() {}
 
-void PacingSender::SetFromConfig(const QuicConfig& config, bool is_server) {
-  sender_->SetFromConfig(config, is_server);
+void PacingSender::SetFromConfig(const QuicConfig& config,
+                                 bool is_server,
+                                 bool using_pacing) {
+  DCHECK(using_pacing);
+  sender_->SetFromConfig(config, is_server, using_pacing);
 }
 
 void PacingSender::SetNumEmulatedConnections(int num_connections) {
diff --git a/net/quic/congestion_control/pacing_sender.h b/net/quic/congestion_control/pacing_sender.h
index f16172a..4eb3dab 100644
--- a/net/quic/congestion_control/pacing_sender.h
+++ b/net/quic/congestion_control/pacing_sender.h
@@ -35,7 +35,9 @@
   ~PacingSender() override;
 
   // SendAlgorithmInterface methods.
-  void SetFromConfig(const QuicConfig& config, bool is_server) override;
+  void SetFromConfig(const QuicConfig& config,
+                     bool is_server,
+                     bool using_pacing) override;
   void SetNumEmulatedConnections(int num_connections) override;
   void OnCongestionEvent(bool rtt_updated,
                          QuicByteCount bytes_in_flight,
diff --git a/net/quic/congestion_control/rtt_stats.cc b/net/quic/congestion_control/rtt_stats.cc
index dfb50ef..32e3b58 100644
--- a/net/quic/congestion_control/rtt_stats.cc
+++ b/net/quic/congestion_control/rtt_stats.cc
@@ -28,7 +28,7 @@
       min_rtt_(QuicTime::Delta::Zero()),
       smoothed_rtt_(QuicTime::Delta::Zero()),
       mean_deviation_(QuicTime::Delta::Zero()),
-      initial_rtt_us_(kInitialRttMs * base::Time::kMicrosecondsPerMillisecond),
+      initial_rtt_us_(kInitialRttMs * kNumMicrosPerMilli),
       num_min_rtt_samples_remaining_(0),
       recent_min_rtt_window_(QuicTime::Delta::Infinite()) {}
 
diff --git a/net/quic/congestion_control/send_algorithm_interface.cc b/net/quic/congestion_control/send_algorithm_interface.cc
index 7245e33..82f1135 100644
--- a/net/quic/congestion_control/send_algorithm_interface.cc
+++ b/net/quic/congestion_control/send_algorithm_interface.cc
@@ -16,17 +16,23 @@
     const QuicClock* clock,
     const RttStats* rtt_stats,
     CongestionControlType congestion_control_type,
-    QuicConnectionStats* stats) {
+    QuicConnectionStats* stats,
+    QuicPacketCount initial_congestion_window) {
   switch (congestion_control_type) {
     case kCubic:
-      return new TcpCubicSender(clock, rtt_stats,
-                                false /* don't use Reno */,
+      return new TcpCubicSender(clock, rtt_stats, false /* don't use Reno */,
+                                initial_congestion_window,
                                 kMaxTcpCongestionWindow, stats);
     case kReno:
-      return new TcpCubicSender(clock, rtt_stats,
-                                true /* use Reno */,
+      return new TcpCubicSender(clock, rtt_stats, true /* use Reno */,
+                                initial_congestion_window,
                                 kMaxTcpCongestionWindow, stats);
     case kBBR:
+  // TODO(rtenneti): Enable BbrTcpSender.
+#if 0
+      return new BbrTcpSender(clock, rtt_stats, initial_congestion_window,
+                              kMaxTcpCongestionWindow, stats);
+#endif
       LOG(DFATAL) << "BbrTcpSender is not supported.";
       return nullptr;
   }
diff --git a/net/quic/congestion_control/send_algorithm_interface.h b/net/quic/congestion_control/send_algorithm_interface.h
index 4f74628..7195f81 100644
--- a/net/quic/congestion_control/send_algorithm_interface.h
+++ b/net/quic/congestion_control/send_algorithm_interface.h
@@ -29,14 +29,17 @@
   typedef std::vector<std::pair<QuicPacketSequenceNumber, TransmissionInfo>>
       CongestionVector;
 
-  static SendAlgorithmInterface* Create(const QuicClock* clock,
-                                        const RttStats* rtt_stats,
-                                        CongestionControlType type,
-                                        QuicConnectionStats* stats);
+  static SendAlgorithmInterface* Create(
+      const QuicClock* clock,
+      const RttStats* rtt_stats,
+      CongestionControlType type,
+      QuicConnectionStats* stats,
+      QuicPacketCount initial_congestion_window);
 
   virtual ~SendAlgorithmInterface() {}
 
-  virtual void SetFromConfig(const QuicConfig& config, bool is_server) = 0;
+  virtual void SetFromConfig(
+      const QuicConfig& config, bool is_server, bool using_pacing) = 0;
 
   // Sets the number of connections to emulate when doing congestion control,
   // particularly for congestion avoidance.  Can be set any time.
diff --git a/net/quic/congestion_control/tcp_cubic_sender.cc b/net/quic/congestion_control/tcp_cubic_sender.cc
index 5f20597..2d0efd7 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender.cc
@@ -31,6 +31,7 @@
     const QuicClock* clock,
     const RttStats* rtt_stats,
     bool reno,
+    QuicPacketCount initial_tcp_congestion_window,
     QuicPacketCount max_tcp_congestion_window,
     QuicConnectionStats* stats)
     : hybrid_slow_start_(clock),
@@ -43,7 +44,7 @@
       largest_sent_sequence_number_(0),
       largest_acked_sequence_number_(0),
       largest_sent_at_last_cutback_(0),
-      congestion_window_(kDefaultInitialWindow),
+      congestion_window_(initial_tcp_congestion_window),
       previous_congestion_window_(0),
       slowstart_threshold_(max_tcp_congestion_window),
       previous_slowstart_threshold_(0),
@@ -55,20 +56,19 @@
   UMA_HISTOGRAM_COUNTS("Net.QuicSession.FinalTcpCwnd", congestion_window_);
 }
 
-void TcpCubicSender::SetFromConfig(const QuicConfig& config, bool is_server) {
+void TcpCubicSender::SetFromConfig(const QuicConfig& config,
+                                   bool is_server,
+                                   bool using_pacing) {
   if (is_server) {
     if (config.HasReceivedConnectionOptions() &&
         ContainsQuicTag(config.ReceivedConnectionOptions(), kIW10)) {
-      // Initial window experiment.  Ignore the initial congestion
-      // window suggested by the client and use the default ICWND of
-      // 10 instead.
-      congestion_window_ = kDefaultInitialWindow;
-    } else if (config.HasReceivedInitialCongestionWindow()) {
-      // Set the initial window size.
-      congestion_window_ = max(kMinimumCongestionWindow,
-          min(kMaxInitialWindow,
-              static_cast<QuicPacketCount>(
-                  config.ReceivedInitialCongestionWindow())));
+      // Initial window experiment.
+      congestion_window_ = 10;
+    }
+    if (using_pacing) {
+      // Disable the ack train mode in hystart when pacing is enabled, since it
+      // may be falsely triggered.
+      hybrid_slow_start_.set_ack_train_detection(false);
     }
   }
 }
diff --git a/net/quic/congestion_control/tcp_cubic_sender.h b/net/quic/congestion_control/tcp_cubic_sender.h
index 7491565..a7507a2 100644
--- a/net/quic/congestion_control/tcp_cubic_sender.h
+++ b/net/quic/congestion_control/tcp_cubic_sender.h
@@ -34,12 +34,15 @@
   TcpCubicSender(const QuicClock* clock,
                  const RttStats* rtt_stats,
                  bool reno,
+                 QuicPacketCount initial_tcp_congestion_window,
                  QuicPacketCount max_tcp_congestion_window,
                  QuicConnectionStats* stats);
   ~TcpCubicSender() override;
 
   // Start implementation of SendAlgorithmInterface.
-  void SetFromConfig(const QuicConfig& config, bool is_server) override;
+  void SetFromConfig(const QuicConfig& config,
+                     bool is_server,
+                     bool using_pacing) override;
   void SetNumEmulatedConnections(int num_connections) override;
   void OnCongestionEvent(bool rtt_updated,
                          QuicByteCount bytes_in_flight,
diff --git a/net/quic/congestion_control/tcp_cubic_sender_test.cc b/net/quic/congestion_control/tcp_cubic_sender_test.cc
index 48a1300..427dd8c 100644
--- a/net/quic/congestion_control/tcp_cubic_sender_test.cc
+++ b/net/quic/congestion_control/tcp_cubic_sender_test.cc
@@ -21,19 +21,22 @@
 namespace net {
 namespace test {
 
-const uint32 kDefaultWindowTCP = kDefaultInitialWindow * kDefaultTCPMSS;
+// TODO(ianswett): A number of theses tests were written with the assumption of
+// an initial CWND of 10. They have carefully calculated values which should be
+// updated to be based on kInitialCongestionWindowInsecure.
+const uint32 kInitialCongestionWindowPackets = 10;
+const uint32 kDefaultWindowTCP =
+    kInitialCongestionWindowPackets * kDefaultTCPMSS;
 const float kRenoBeta = 0.7f;  // Reno backoff factor.
 
-// TODO(ianswett): Remove 10000 once b/10075719 is fixed.
-const QuicPacketCount kDefaultMaxCongestionWindowTCP = 10000;
-
 class TcpCubicSenderPeer : public TcpCubicSender {
  public:
   TcpCubicSenderPeer(const QuicClock* clock,
                      bool reno,
                      QuicPacketCount max_tcp_congestion_window)
       : TcpCubicSender(
-            clock, &rtt_stats_, reno, max_tcp_congestion_window, &stats_) {
+            clock, &rtt_stats_, reno, kInitialCongestionWindowPackets,
+            max_tcp_congestion_window, &stats_) {
   }
 
   QuicPacketCount congestion_window() {
@@ -61,7 +64,7 @@
   TcpCubicSenderTest()
       : one_ms_(QuicTime::Delta::FromMilliseconds(1)),
         sender_(new TcpCubicSenderPeer(&clock_, true,
-                                       kDefaultMaxCongestionWindowTCP)),
+                                       kMaxTcpCongestionWindow)),
         receiver_(new TcpReceiver()),
         sequence_number_(1),
         acked_sequence_number_(0),
@@ -209,7 +212,7 @@
 
 TEST_F(TcpCubicSenderTest, SlowStartAckTrain) {
   sender_->SetNumEmulatedConnections(1);
-  EXPECT_EQ(kDefaultMaxCongestionWindowTCP * kDefaultTCPMSS,
+  EXPECT_EQ(kMaxTcpCongestionWindow * kDefaultTCPMSS,
             sender_->GetSlowStartThreshold());
 
   // Make sure that we fall out of slow start when we send ACK train longer
@@ -305,7 +308,7 @@
 
 TEST_F(TcpCubicSenderTest, NoPRRWhenLessThanOnePacketInFlight) {
   SendAvailableSendWindow();
-  LoseNPackets(kDefaultInitialWindow - 1);
+  LoseNPackets(kInitialCongestionWindowPackets - 1);
   AckNPackets(1);
   // PRR will allow 2 packets for every ack during recovery.
   EXPECT_EQ(2, SendAvailableSendWindow());
@@ -424,7 +427,7 @@
 
 TEST_F(TcpCubicSenderTest, RTOCongestionWindowAndRevert) {
   EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
-  EXPECT_EQ(10000u, sender_->slowstart_threshold());
+  EXPECT_EQ(kMaxTcpCongestionWindow, sender_->slowstart_threshold());
 
   // Expect the window to decrease to the minimum once the RTO fires
   // and slow start threshold to be set to 1/2 of the CWND.
@@ -435,7 +438,7 @@
   // Now repair the RTO and ensure the slowstart threshold reverts.
   sender_->RevertRetransmissionTimeout();
   EXPECT_EQ(kDefaultWindowTCP, sender_->GetCongestionWindow());
-  EXPECT_EQ(10000u, sender_->slowstart_threshold());
+  EXPECT_EQ(kMaxTcpCongestionWindow, sender_->slowstart_threshold());
 }
 
 TEST_F(TcpCubicSenderTest, RTOCongestionWindowNoRetransmission) {
@@ -574,20 +577,26 @@
 }
 
 TEST_F(TcpCubicSenderTest, ConfigureMaxInitialWindow) {
-  QuicPacketCount congestion_window = sender_->congestion_window();
   QuicConfig config;
-  QuicConfigPeer::SetReceivedInitialWindow(&config, 2 * congestion_window);
 
-  sender_->SetFromConfig(config, true);
-  EXPECT_EQ(2 * congestion_window, sender_->congestion_window());
-
-  // Verify that kCOPT: kIW10 forces the congestion window to the
-  // default of 10 regardless of ReceivedInitialWindow.
+  // Verify that kCOPT: kIW10 forces the congestion window to the default of 10.
   QuicTagVector options;
   options.push_back(kIW10);
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
-  sender_->SetFromConfig(config, true);
-  EXPECT_EQ(congestion_window, sender_->congestion_window());
+  sender_->SetFromConfig(config,
+                         /* is_server= */ true,
+                         /* using_pacing= */ false);
+  EXPECT_EQ(10u, sender_->congestion_window());
+}
+
+TEST_F(TcpCubicSenderTest, DisableAckTrainDetectionWithPacing) {
+  EXPECT_TRUE(sender_->hybrid_slow_start().ack_train_detection());
+
+  QuicConfig config;
+  sender_->SetFromConfig(config,
+                         /* is_server= */ true,
+                         /* using_pacing= */ true);
+  EXPECT_FALSE(sender_->hybrid_slow_start().ack_train_detection());
 }
 
 TEST_F(TcpCubicSenderTest, 2ConnectionCongestionAvoidanceAtEndOfRecovery) {
diff --git a/net/quic/crypto/cached_network_parameters.cc b/net/quic/crypto/cached_network_parameters.cc
new file mode 100644
index 0000000..20a438b
--- /dev/null
+++ b/net/quic/crypto/cached_network_parameters.cc
@@ -0,0 +1,40 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/quic/crypto/cached_network_parameters.h"
+
+namespace net {
+
+CachedNetworkParameters::CachedNetworkParameters()
+    : bandwidth_estimate_bytes_per_second_(0),
+      max_bandwidth_estimate_bytes_per_second_(0),
+      max_bandwidth_timestamp_seconds_(0),
+      min_rtt_ms_(0),
+      previous_connection_state_(0),
+      timestamp_(0) {
+}
+
+CachedNetworkParameters::~CachedNetworkParameters() {
+}
+
+bool CachedNetworkParameters::operator==(
+    const CachedNetworkParameters& other) const {
+  return serving_region_ == other.serving_region_ &&
+      bandwidth_estimate_bytes_per_second_ ==
+          other.bandwidth_estimate_bytes_per_second_ &&
+      max_bandwidth_estimate_bytes_per_second_ ==
+          other.max_bandwidth_estimate_bytes_per_second_ &&
+      max_bandwidth_timestamp_seconds_ ==
+          other.max_bandwidth_timestamp_seconds_ &&
+      min_rtt_ms_ == other.min_rtt_ms_ &&
+      previous_connection_state_ == other.previous_connection_state_ &&
+      timestamp_ == other.timestamp_;
+}
+
+bool CachedNetworkParameters::operator!=(
+    const CachedNetworkParameters& other) const {
+  return !(*this == other);
+}
+
+}  // namespace net
diff --git a/net/quic/crypto/cached_network_parameters.h b/net/quic/crypto/cached_network_parameters.h
new file mode 100644
index 0000000..5f22070
--- /dev/null
+++ b/net/quic/crypto/cached_network_parameters.h
@@ -0,0 +1,109 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_
+#define NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_
+
+#include <string>
+
+#include "base/basictypes.h"
+#include "base/strings/string_piece.h"
+#include "net/base/net_export.h"
+
+namespace net {
+
+// TODO(rtenneti): sync with server more rationally.
+// CachedNetworkParameters contains data that can be used to choose appropriate
+// connection parameters (initial RTT, initial CWND, etc.) in new connections.
+class NET_EXPORT_PRIVATE CachedNetworkParameters {
+ public:
+  // Describes the state of the connection during which the supplied network
+  // parameters were calculated.
+  enum PreviousConnectionState {
+    SLOW_START = 0,
+    CONGESTION_AVOIDANCE = 1,
+  };
+
+  CachedNetworkParameters();
+  ~CachedNetworkParameters();
+
+  bool operator==(const CachedNetworkParameters& other) const;
+  bool operator!=(const CachedNetworkParameters& other) const;
+
+  std::string serving_region() const {
+    return serving_region_;
+  }
+  void set_serving_region(base::StringPiece serving_region) {
+    serving_region_ = serving_region.as_string();
+  }
+
+  int32 bandwidth_estimate_bytes_per_second() const {
+    return bandwidth_estimate_bytes_per_second_;
+  }
+  void set_bandwidth_estimate_bytes_per_second(
+      int32 bandwidth_estimate_bytes_per_second) {
+    bandwidth_estimate_bytes_per_second_ = bandwidth_estimate_bytes_per_second;
+  }
+
+  int32 max_bandwidth_estimate_bytes_per_second() const {
+    return max_bandwidth_estimate_bytes_per_second_;
+  }
+  void set_max_bandwidth_estimate_bytes_per_second(
+      int32 max_bandwidth_estimate_bytes_per_second) {
+    max_bandwidth_estimate_bytes_per_second_ =
+        max_bandwidth_estimate_bytes_per_second;
+  }
+
+  int64 max_bandwidth_timestamp_seconds() const {
+    return max_bandwidth_timestamp_seconds_;
+  }
+  void set_max_bandwidth_timestamp_seconds(
+      int64 max_bandwidth_timestamp_seconds) {
+    max_bandwidth_timestamp_seconds_ = max_bandwidth_timestamp_seconds;
+  }
+
+  int32 min_rtt_ms() const {
+    return min_rtt_ms_;
+  }
+  void set_min_rtt_ms(int32 min_rtt_ms) {
+    min_rtt_ms_ = min_rtt_ms;
+  }
+
+  int32 previous_connection_state() const {
+    return previous_connection_state_;
+  }
+  void set_previous_connection_state(int32 previous_connection_state) {
+    previous_connection_state_ = previous_connection_state;
+  }
+
+  int64 timestamp() const { return timestamp_; }
+  void set_timestamp(int64 timestamp) { timestamp_ = timestamp; }
+
+ private:
+  // serving_region_ is used to decide whether or not the bandwidth estimate and
+  // min RTT are reasonable and if they should be used.
+  // For example a group of geographically close servers may share the same
+  // serving_region_ string if they are expected to have similar network
+  // performance.
+  std::string serving_region_;
+  // The server can supply a bandwidth estimate (in bytes/s) which it may re-use
+  // on receipt of a source-address token with this field set.
+  int32 bandwidth_estimate_bytes_per_second_;
+  // The maximum bandwidth seen by the client, not necessarily the latest.
+  int32 max_bandwidth_estimate_bytes_per_second_;
+  // Timestamp (seconds since UNIX epoch) that indicates when the max bandwidth
+  // was seen by the server.
+  int64 max_bandwidth_timestamp_seconds_;
+  // The min RTT seen on a previous connection can be used by the server to
+  // inform initial connection parameters for new connections.
+  int32 min_rtt_ms_;
+  // Encodes the PreviousConnectionState enum.
+  int32 previous_connection_state_;
+  // UNIX timestamp when this bandwidth estimate was created.
+  int64 timestamp_;
+};
+
+}  // namespace net
+
+#endif  // NET_QUIC_CRYPTO_CACHED_NETWORK_PARAMETERS_H_
diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc
index 4828c3a..268c8ee 100644
--- a/net/quic/crypto/quic_crypto_client_config.cc
+++ b/net/quic/crypto/quic_crypto_client_config.cc
@@ -847,8 +847,9 @@
       break;
     }
   }
-  if (i == canonical_suffixes_.size())
+  if (i == canonical_suffixes_.size()) {
     return false;
+  }
 
   QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(),
                                 server_id.is_https(),
diff --git a/net/quic/crypto/quic_crypto_server_config.h b/net/quic/crypto/quic_crypto_server_config.h
index dbbff1a..8a58aea 100644
--- a/net/quic/crypto/quic_crypto_server_config.h
+++ b/net/quic/crypto/quic_crypto_server_config.h
@@ -15,11 +15,11 @@
 #include "base/synchronization/lock.h"
 #include "net/base/ip_endpoint.h"
 #include "net/base/net_export.h"
+#include "net/quic/crypto/cached_network_parameters.h"
 #include "net/quic/crypto/crypto_handshake.h"
 #include "net/quic/crypto/crypto_handshake_message.h"
 #include "net/quic/crypto/crypto_protocol.h"
 #include "net/quic/crypto/crypto_secret_boxer.h"
-#include "net/quic/crypto/source_address_token.h"
 #include "net/quic/quic_time.h"
 
 namespace net {
diff --git a/net/quic/crypto/source_address_token.cc b/net/quic/crypto/source_address_token.cc
index 0b514fe..5faedaa 100644
--- a/net/quic/crypto/source_address_token.cc
+++ b/net/quic/crypto/source_address_token.cc
@@ -11,37 +11,6 @@
 
 namespace net {
 
-CachedNetworkParameters::CachedNetworkParameters()
-    : bandwidth_estimate_bytes_per_second_(0),
-      max_bandwidth_estimate_bytes_per_second_(0),
-      max_bandwidth_timestamp_seconds_(0),
-      min_rtt_ms_(0),
-      previous_connection_state_(0),
-      timestamp_(0) {
-}
-
-CachedNetworkParameters::~CachedNetworkParameters() {
-}
-
-bool CachedNetworkParameters::operator==(
-    const CachedNetworkParameters& other) const {
-  return serving_region_ == other.serving_region_ &&
-      bandwidth_estimate_bytes_per_second_ ==
-          other.bandwidth_estimate_bytes_per_second_ &&
-      max_bandwidth_estimate_bytes_per_second_ ==
-          other.max_bandwidth_estimate_bytes_per_second_ &&
-      max_bandwidth_timestamp_seconds_ ==
-          other.max_bandwidth_timestamp_seconds_ &&
-      min_rtt_ms_ == other.min_rtt_ms_ &&
-      previous_connection_state_ == other.previous_connection_state_ &&
-      timestamp_ == other.timestamp_;
-}
-
-bool CachedNetworkParameters::operator!=(
-    const CachedNetworkParameters& other) const {
-  return !(*this == other);
-}
-
 SourceAddressToken::SourceAddressToken()
     : has_cached_network_parameters_(false) {
 }
diff --git a/net/quic/crypto/source_address_token.h b/net/quic/crypto/source_address_token.h
index 76c3454..f9a5098 100644
--- a/net/quic/crypto/source_address_token.h
+++ b/net/quic/crypto/source_address_token.h
@@ -10,101 +10,11 @@
 #include "base/basictypes.h"
 #include "base/strings/string_piece.h"
 #include "net/base/net_export.h"
+#include "net/quic/crypto/cached_network_parameters.h"
 
 namespace net {
 
 // TODO(rtenneti): sync with server more rationally.
-// CachedNetworkParameters contains data that can be used to choose appropriate
-// connection parameters (initial RTT, initial CWND, etc.) in new connections.
-class NET_EXPORT_PRIVATE CachedNetworkParameters {
- public:
-  // Describes the state of the connection during which the supplied network
-  // parameters were calculated.
-  enum PreviousConnectionState {
-    SLOW_START = 0,
-    CONGESTION_AVOIDANCE = 1,
-  };
-
-  CachedNetworkParameters();
-  ~CachedNetworkParameters();
-
-  bool operator==(const CachedNetworkParameters& other) const;
-  bool operator!=(const CachedNetworkParameters& other) const;
-
-  std::string serving_region() const {
-    return serving_region_;
-  }
-  void set_serving_region(base::StringPiece serving_region) {
-    serving_region_ = serving_region.as_string();
-  }
-
-  int32 bandwidth_estimate_bytes_per_second() const {
-    return bandwidth_estimate_bytes_per_second_;
-  }
-  void set_bandwidth_estimate_bytes_per_second(
-      int32 bandwidth_estimate_bytes_per_second) {
-    bandwidth_estimate_bytes_per_second_ = bandwidth_estimate_bytes_per_second;
-  }
-
-  int32 max_bandwidth_estimate_bytes_per_second() const {
-    return max_bandwidth_estimate_bytes_per_second_;
-  }
-  void set_max_bandwidth_estimate_bytes_per_second(
-      int32 max_bandwidth_estimate_bytes_per_second) {
-    max_bandwidth_estimate_bytes_per_second_ =
-        max_bandwidth_estimate_bytes_per_second;
-  }
-
-  int64 max_bandwidth_timestamp_seconds() const {
-    return max_bandwidth_timestamp_seconds_;
-  }
-  void set_max_bandwidth_timestamp_seconds(
-      int64 max_bandwidth_timestamp_seconds) {
-    max_bandwidth_timestamp_seconds_ = max_bandwidth_timestamp_seconds;
-  }
-
-  int32 min_rtt_ms() const {
-    return min_rtt_ms_;
-  }
-  void set_min_rtt_ms(int32 min_rtt_ms) {
-    min_rtt_ms_ = min_rtt_ms;
-  }
-
-  int32 previous_connection_state() const {
-    return previous_connection_state_;
-  }
-  void set_previous_connection_state(int32 previous_connection_state) {
-    previous_connection_state_ = previous_connection_state;
-  }
-
-  int64 timestamp() const { return timestamp_; }
-  void set_timestamp(int64 timestamp) { timestamp_ = timestamp; }
-
- private:
-  // serving_region_ is used to decide whether or not the bandwidth estimate and
-  // min RTT are reasonable and if they should be used.
-  // For example a group of geographically close servers may share the same
-  // serving_region_ string if they are expected to have similar network
-  // performance.
-  std::string serving_region_;
-  // The server can supply a bandwidth estimate (in bytes/s) which it may re-use
-  // on receipt of a source-address token with this field set.
-  int32 bandwidth_estimate_bytes_per_second_;
-  // The maximum bandwidth seen by the client, not necessarily the latest.
-  int32 max_bandwidth_estimate_bytes_per_second_;
-  // Timestamp (seconds since UNIX epoch) that indicates when the max bandwidth
-  // was seen by the server.
-  int64 max_bandwidth_timestamp_seconds_;
-  // The min RTT seen on a previous connection can be used by the server to
-  // inform initial connection parameters for new connections.
-  int32 min_rtt_ms_;
-  // Encodes the PreviousConnectionState enum.
-  int32 previous_connection_state_;
-  // UNIX timestamp when this bandwidth estimate was created.
-  int64 timestamp_;
-};
-
-// TODO(rtenneti): sync with server more rationally.
 // A SourceAddressToken is serialised, encrypted and sent to clients so that
 // they can prove ownership of an IP address.
 class NET_EXPORT_PRIVATE SourceAddressToken {
diff --git a/net/quic/quic_client_session.cc b/net/quic/quic_client_session.cc
index 73a5aec..274099c 100644
--- a/net/quic/quic_client_session.cc
+++ b/net/quic/quic_client_session.cc
@@ -155,10 +155,9 @@
     TransportSecurityState* transport_security_state,
     scoped_ptr<QuicServerInfo> server_info,
     const QuicConfig& config,
-    bool is_secure,
     base::TaskRunner* task_runner,
     NetLog* net_log)
-    : QuicClientSessionBase(connection, config, is_secure),
+    : QuicClientSessionBase(connection, config),
       require_confirmation_(false),
       stream_factory_(stream_factory),
       socket_(socket.Pass()),
diff --git a/net/quic/quic_client_session.h b/net/quic/quic_client_session.h
index 6c33eb5..b1a35d9 100644
--- a/net/quic/quic_client_session.h
+++ b/net/quic/quic_client_session.h
@@ -96,7 +96,6 @@
                     TransportSecurityState* transport_security_state,
                     scoped_ptr<QuicServerInfo> server_info,
                     const QuicConfig& config,
-                    bool is_secure,
                     base::TaskRunner* task_runner,
                     NetLog* net_log);
   ~QuicClientSession() override;
diff --git a/net/quic/quic_client_session_base.cc b/net/quic/quic_client_session_base.cc
index 5b5902b..40d4b86 100644
--- a/net/quic/quic_client_session_base.cc
+++ b/net/quic/quic_client_session_base.cc
@@ -10,9 +10,8 @@
 
 QuicClientSessionBase::QuicClientSessionBase(
     QuicConnection* connection,
-    const QuicConfig& config,
-    bool is_secure)
-    : QuicSession(connection, config, is_secure) {}
+    const QuicConfig& config)
+    : QuicSession(connection, config) {}
 
 QuicClientSessionBase::~QuicClientSessionBase() {}
 
diff --git a/net/quic/quic_client_session_base.h b/net/quic/quic_client_session_base.h
index a7f64fb..d72996c 100644
--- a/net/quic/quic_client_session_base.h
+++ b/net/quic/quic_client_session_base.h
@@ -14,8 +14,7 @@
 class NET_EXPORT_PRIVATE QuicClientSessionBase : public QuicSession {
  public:
   QuicClientSessionBase(QuicConnection* connection,
-                        const QuicConfig& config,
-                        bool is_secure);
+                        const QuicConfig& config);
 
   ~QuicClientSessionBase() override;
 
diff --git a/net/quic/quic_client_session_test.cc b/net/quic/quic_client_session_test.cc
index 8860f2e..66583b8 100644
--- a/net/quic/quic_client_session_test.cc
+++ b/net/quic/quic_client_session_test.cc
@@ -46,7 +46,6 @@
         session_(connection_, GetSocket().Pass(), nullptr,
                  &transport_security_state_,
                  make_scoped_ptr((QuicServerInfo*)nullptr), DefaultQuicConfig(),
-                 /*is_secure=*/false,
                  base::MessageLoop::current()->message_loop_proxy().get(),
                  &net_log_) {
     session_.InitializeSession(QuicServerId(kServerHostname, kServerPort,
diff --git a/net/quic/quic_config.cc b/net/quic/quic_config.cc
index b1b7343..622cf3f 100644
--- a/net/quic/quic_config.cc
+++ b/net/quic/quic_config.cc
@@ -434,7 +434,6 @@
       keepalive_timeout_seconds_(kKATO, PRESENCE_OPTIONAL),
       max_streams_per_connection_(kMSPC, PRESENCE_REQUIRED),
       bytes_for_connection_id_(kTCID, PRESENCE_OPTIONAL),
-      initial_congestion_window_(kSWND, PRESENCE_OPTIONAL),
       initial_round_trip_time_us_(kIRTT, PRESENCE_OPTIONAL),
       // TODO(rjshade): Remove this when retiring QUIC_VERSION_19.
       initial_flow_control_window_bytes_(kIFCW, PRESENCE_OPTIONAL),
@@ -524,18 +523,6 @@
   return bytes_for_connection_id_.GetReceivedValue();
 }
 
-void QuicConfig::SetInitialCongestionWindowToSend(size_t initial_window) {
-  initial_congestion_window_.SetSendValue(initial_window);
-}
-
-bool QuicConfig::HasReceivedInitialCongestionWindow() const {
-  return initial_congestion_window_.HasReceivedValue();
-}
-
-uint32 QuicConfig::ReceivedInitialCongestionWindow() const {
-  return initial_congestion_window_.GetReceivedValue();
-}
-
 void QuicConfig::SetInitialRoundTripTimeUsToSend(size_t rtt) {
   initial_round_trip_time_us_.SetSendValue(rtt);
 }
@@ -675,7 +662,6 @@
   keepalive_timeout_seconds_.ToHandshakeMessage(out);
   max_streams_per_connection_.ToHandshakeMessage(out);
   bytes_for_connection_id_.ToHandshakeMessage(out);
-  initial_congestion_window_.ToHandshakeMessage(out);
   initial_round_trip_time_us_.ToHandshakeMessage(out);
   initial_flow_control_window_bytes_.ToHandshakeMessage(out);
   initial_stream_flow_control_window_bytes_.ToHandshakeMessage(out);
@@ -712,10 +698,6 @@
         peer_hello, hello_type, error_details);
   }
   if (error == QUIC_NO_ERROR) {
-    error = initial_congestion_window_.ProcessPeerHello(
-        peer_hello, hello_type, error_details);
-  }
-  if (error == QUIC_NO_ERROR) {
     error = initial_round_trip_time_us_.ProcessPeerHello(
         peer_hello, hello_type, error_details);
   }
diff --git a/net/quic/quic_config.h b/net/quic/quic_config.h
index a4d6129..cf3775c 100644
--- a/net/quic/quic_config.h
+++ b/net/quic/quic_config.h
@@ -319,13 +319,6 @@
 
   uint32 ReceivedBytesForConnectionId() const;
 
-  // Sets the peer's default initial congestion window in packets.
-  void SetInitialCongestionWindowToSend(size_t initial_window);
-
-  bool HasReceivedInitialCongestionWindow() const;
-
-  uint32 ReceivedInitialCongestionWindow() const;
-
   // Sets an estimated initial round trip time in us.
   void SetInitialRoundTripTimeUsToSend(size_t rtt_us);
 
@@ -413,8 +406,6 @@
   QuicNegotiableUint32 max_streams_per_connection_;
   // The number of bytes required for the connection ID.
   QuicFixedUint32 bytes_for_connection_id_;
-  // Initial congestion window in packets.
-  QuicFixedUint32 initial_congestion_window_;
   // Initial round trip time estimate in microseconds.
   QuicFixedUint32 initial_round_trip_time_us_;
 
diff --git a/net/quic/quic_config_test.cc b/net/quic/quic_config_test.cc
index 914b137..413d7fb 100644
--- a/net/quic/quic_config_test.cc
+++ b/net/quic/quic_config_test.cc
@@ -81,8 +81,7 @@
       QuicTime::Delta::FromSeconds(kMaximumIdleTimeoutSecs));
   client_config.SetMaxStreamsPerConnection(
       2 * kDefaultMaxStreamsPerConnection, kDefaultMaxStreamsPerConnection);
-  client_config.SetInitialRoundTripTimeUsToSend(
-      10 * base::Time::kMicrosecondsPerMillisecond);
+  client_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli);
   client_config.SetInitialFlowControlWindowToSend(
       2 * kInitialSessionFlowControlWindowForTest);
   client_config.SetInitialStreamFlowControlWindowToSend(
@@ -107,8 +106,7 @@
   EXPECT_EQ(kDefaultMaxStreamsPerConnection,
             config_.MaxStreamsPerConnection());
   EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.KeepaliveTimeout());
-  EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond,
-            config_.ReceivedInitialRoundTripTimeUs());
+  EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs());
   EXPECT_TRUE(config_.HasReceivedConnectionOptions());
   EXPECT_EQ(2u, config_.ReceivedConnectionOptions().size());
   EXPECT_EQ(config_.ReceivedConnectionOptions()[0], kTBBR);
@@ -134,9 +132,7 @@
   server_config.SetMaxStreamsPerConnection(
       kDefaultMaxStreamsPerConnection / 2,
       kDefaultMaxStreamsPerConnection / 2);
-  server_config.SetInitialCongestionWindowToSend(kDefaultInitialWindow / 2);
-  server_config.SetInitialRoundTripTimeUsToSend(
-      10 * base::Time::kMicrosecondsPerMillisecond);
+  server_config.SetInitialRoundTripTimeUsToSend(10 * kNumMicrosPerMilli);
   server_config.SetInitialFlowControlWindowToSend(
       2 * kInitialSessionFlowControlWindowForTest);
   server_config.SetInitialStreamFlowControlWindowToSend(
@@ -156,11 +152,8 @@
             config_.IdleConnectionStateLifetime());
   EXPECT_EQ(kDefaultMaxStreamsPerConnection / 2,
             config_.MaxStreamsPerConnection());
-  EXPECT_EQ(kDefaultInitialWindow / 2,
-            config_.ReceivedInitialCongestionWindow());
   EXPECT_EQ(QuicTime::Delta::FromSeconds(0), config_.KeepaliveTimeout());
-  EXPECT_EQ(10 * base::Time::kMicrosecondsPerMillisecond,
-            config_.ReceivedInitialRoundTripTimeUs());
+  EXPECT_EQ(10 * kNumMicrosPerMilli, config_.ReceivedInitialRoundTripTimeUs());
   EXPECT_EQ(config_.ReceivedInitialFlowControlWindowBytes(),
             2 * kInitialSessionFlowControlWindowForTest);
   EXPECT_EQ(config_.ReceivedInitialStreamFlowControlWindowBytes(),
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 6308d88..fd9ec5f 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -189,6 +189,7 @@
                                const PacketWriterFactory& writer_factory,
                                bool owns_writer,
                                bool is_server,
+                               bool is_secure,
                                const QuicVersionVector& supported_versions)
     : framer_(supported_versions, helper->GetClock()->ApproximateNow(),
               is_server),
@@ -222,9 +223,7 @@
       timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
       ping_alarm_(helper->CreateAlarm(new PingAlarm(this))),
       packet_generator_(connection_id_, &framer_, random_generator_, this),
-      idle_network_timeout_(FLAGS_quic_unified_timeouts ?
-          QuicTime::Delta::Infinite() :
-          QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs)),
+      idle_network_timeout_(QuicTime::Delta::Infinite()),
       overall_connection_timeout_(QuicTime::Delta::Infinite()),
       time_of_last_received_packet_(clock_->ApproximateNow()),
       time_of_last_sent_new_packet_(clock_->ApproximateNow()),
@@ -232,7 +231,8 @@
       sent_packet_manager_(
           is_server, clock_, &stats_,
           FLAGS_quic_use_bbr_congestion_control ? kBBR : kCubic,
-          FLAGS_quic_use_time_loss_detection ? kTime : kNack),
+          FLAGS_quic_use_time_loss_detection ? kTime : kNack,
+          is_secure),
       version_negotiation_state_(START_NEGOTIATION),
       is_server_(is_server),
       connected_(true),
@@ -240,12 +240,10 @@
       peer_port_changed_(false),
       self_ip_changed_(false),
       self_port_changed_(false),
-      can_truncate_connection_ids_(true) {
+      can_truncate_connection_ids_(true),
+      is_secure_(is_secure) {
   DVLOG(1) << ENDPOINT << "Created connection with connection_id: "
            << connection_id;
-  if (!FLAGS_quic_unified_timeouts) {
-    timeout_alarm_->Set(clock_->ApproximateNow().Add(idle_network_timeout_));
-  }
   framer_.set_visitor(this);
   framer_.set_received_entropy_calculator(&received_packet_manager_);
   stats_.connection_creation_time = clock_->ApproximateNow();
@@ -266,17 +264,14 @@
 }
 
 void QuicConnection::SetFromConfig(const QuicConfig& config) {
-  if (FLAGS_quic_unified_timeouts) {
-    if (config.negotiated()) {
-      SetNetworkTimeouts(QuicTime::Delta::Infinite(),
-                         config.IdleConnectionStateLifetime());
-    } else {
-      SetNetworkTimeouts(config.max_time_before_crypto_handshake(),
-                         config.max_idle_time_before_crypto_handshake());
-    }
+  if (config.negotiated()) {
+    SetNetworkTimeouts(QuicTime::Delta::Infinite(),
+                       config.IdleConnectionStateLifetime());
   } else {
-    SetIdleNetworkTimeout(config.IdleConnectionStateLifetime());
+    SetNetworkTimeouts(config.max_time_before_crypto_handshake(),
+                       config.max_idle_time_before_crypto_handshake());
   }
+
   sent_packet_manager_.SetFromConfig(config);
   if (FLAGS_allow_truncated_connection_ids_for_quic &&
       config.HasReceivedBytesForConnectionId() &&
@@ -1898,11 +1893,11 @@
   }
 }
 
-size_t QuicConnection::max_packet_length() const {
+QuicByteCount QuicConnection::max_packet_length() const {
   return packet_generator_.max_packet_length();
 }
 
-void QuicConnection::set_max_packet_length(size_t length) {
+void QuicConnection::set_max_packet_length(QuicByteCount length) {
   return packet_generator_.set_max_packet_length(length);
 }
 
@@ -1928,32 +1923,6 @@
                               pending_handshake);
 }
 
-void QuicConnection::SetIdleNetworkTimeout(QuicTime::Delta timeout) {
-  // Adjust the idle timeout on client and server to prevent clients from
-  // sending requests to servers which have already closed the connection.
-  if (is_server_) {
-    timeout = timeout.Add(QuicTime::Delta::FromSeconds(3));
-  } else if (timeout > QuicTime::Delta::FromSeconds(1)) {
-    timeout = timeout.Subtract(QuicTime::Delta::FromSeconds(1));
-  }
-
-  if (timeout < idle_network_timeout_) {
-    idle_network_timeout_ = timeout;
-    SetTimeoutAlarm();
-  } else {
-    idle_network_timeout_ = timeout;
-  }
-}
-
-void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) {
-  if (timeout < overall_connection_timeout_) {
-    overall_connection_timeout_ = timeout;
-    SetTimeoutAlarm();
-  } else {
-    overall_connection_timeout_ = timeout;
-  }
-}
-
 void QuicConnection::SetNetworkTimeouts(QuicTime::Delta overall_timeout,
                                         QuicTime::Delta idle_timeout) {
   LOG_IF(DFATAL, idle_timeout > overall_timeout)
diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h
index f9f8733..96f5cbc 100644
--- a/net/quic/quic_connection.h
+++ b/net/quic/quic_connection.h
@@ -251,6 +251,7 @@
                  const PacketWriterFactory& writer_factory,
                  bool owns_writer,
                  bool is_server,
+                 bool is_secure,
                  const QuicVersionVector& supported_versions);
   ~QuicConnection() override;
 
@@ -397,8 +398,8 @@
   QuicConnectionId connection_id() const { return connection_id_; }
   const QuicClock* clock() const { return clock_; }
   QuicRandom* random_generator() const { return random_generator_; }
-  size_t max_packet_length() const;
-  void set_max_packet_length(size_t length);
+  QuicByteCount max_packet_length() const;
+  void set_max_packet_length(QuicByteCount length);
 
   bool connected() const { return connected_; }
 
@@ -425,16 +426,6 @@
   // Returns true if the connection has queued packets or frames.
   bool HasQueuedData() const;
 
-  // TODO(ianswett): Remove when quic_unified_timeouts is removed.
-  // Sets (or resets) the idle state connection timeout. Also, checks and times
-  // out the connection if network timer has expired for |timeout|.
-  void SetIdleNetworkTimeout(QuicTime::Delta timeout);
-
-  // Sets (or resets) the total time delta the connection can be alive for.
-  // Used to limit the time a connection can be alive before crypto handshake
-  // finishes.
-  void SetOverallConnectionTimeout(QuicTime::Delta timeout);
-
   // Sets the overall and idle state connection timeouts.
   void SetNetworkTimeouts(QuicTime::Delta overall_timeout,
                           QuicTime::Delta idle_timeout);
@@ -530,6 +521,9 @@
   QuicPacketSequenceNumber sequence_number_of_last_sent_packet() const {
     return sequence_number_of_last_sent_packet_;
   }
+  const QuicPacketWriter* writer() const { return writer_; }
+
+  bool is_secure() const { return is_secure_; }
 
  protected:
   // Packets which have not been written to the wire.
@@ -567,7 +561,6 @@
   bool SelectMutualVersion(const QuicVersionVector& available_versions);
 
   QuicPacketWriter* writer() { return writer_; }
-  const QuicPacketWriter* writer() const { return writer_; }
 
   bool peer_port_changed() const { return peer_port_changed_; }
 
@@ -702,7 +695,7 @@
   // decrypted.
   bool last_packet_decrypted_;
   bool last_packet_revived_;  // True if the last packet was revived from FEC.
-  size_t last_size_;  // Size of the last received packet.
+  QuicByteCount last_size_;  // Size of the last received packet.
   EncryptionLevel last_decrypted_packet_level_;
   QuicPacketHeader last_header_;
   std::vector<QuicStreamFrame> last_stream_frames_;
@@ -837,6 +830,9 @@
   // version negotiation packet.
   QuicVersionVector server_supported_versions_;
 
+  // True if this is a secure QUIC connection.
+  bool is_secure_;
+
   DISALLOW_COPY_AND_ASSIGN(QuicConnection);
 };
 
diff --git a/net/quic/quic_connection_test.cc b/net/quic/quic_connection_test.cc
index 66cb89c..4e58dfd 100644
--- a/net/quic/quic_connection_test.cc
+++ b/net/quic/quic_connection_test.cc
@@ -408,6 +408,7 @@
                        factory,
                        /* owns_writer= */ false,
                        is_server,
+                       /* is_secure= */ false,
                        SupportedVersions(version)) {
     // Disable tail loss probes for most tests.
     QuicSentPacketManagerPeer::SetMaxTailLossProbes(
@@ -2506,7 +2507,7 @@
 
 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
   // SetFromConfig is always called after construction from InitializeSession.
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   QuicConfig config;
   connection_.SetFromConfig(config);
   EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
@@ -2536,7 +2537,7 @@
 
 TEST_P(QuicConnectionTest, Buffer100NonDecryptablePackets) {
   // SetFromConfig is always called after construction from InitializeSession.
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   QuicConfig config;
   config.set_max_undecryptable_packets(100);
   connection_.SetFromConfig(config);
@@ -2775,36 +2776,12 @@
 }
 
 TEST_P(QuicConnectionTest, InitialTimeout) {
-  if (!FLAGS_quic_unified_timeouts) {
-    EXPECT_TRUE(connection_.connected());
-    EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
-    EXPECT_CALL(*send_algorithm_,
-                OnPacketSent(_, _, _, _, _)).Times(AnyNumber());
-
-    QuicTime default_timeout = clock_.ApproximateNow().Add(
-        QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs));
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-
-    // Simulate the timeout alarm firing.
-    clock_.AdvanceTime(QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs));
-    connection_.GetTimeoutAlarm()->Fire();
-
-    EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
-    EXPECT_FALSE(connection_.connected());
-
-    EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
-    EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
-    EXPECT_FALSE(connection_.GetResumeWritesAlarm()->IsSet());
-    EXPECT_FALSE(connection_.GetRetransmissionAlarm()->IsSet());
-    EXPECT_FALSE(connection_.GetSendAlarm()->IsSet());
-    return;
-  }
   EXPECT_TRUE(connection_.connected());
   EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber());
   EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
 
   // SetFromConfig sets the initial timeouts before negotiation.
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   QuicConfig config;
   connection_.SetFromConfig(config);
   // Subtract a second from the idle timeout on the client side.
@@ -2913,44 +2890,8 @@
 }
 
 TEST_P(QuicConnectionTest, TimeoutAfterSend) {
-  if (!FLAGS_quic_unified_timeouts) {
-    EXPECT_TRUE(connection_.connected());
-
-    QuicTime default_timeout = clock_.ApproximateNow().Add(
-        QuicTime::Delta::FromSeconds(kDefaultIdleTimeoutSecs));
-
-    // When we send a packet, the timeout will change to 5000 +
-    // kDefaultInitialTimeoutSecs.
-    clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-
-    // Send an ack so we don't set the retransmission alarm.
-    SendAckPacketToPeer();
-    EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
-
-    // The original alarm will fire.  We should not time out because we had a
-    // network event at t=5000.  The alarm will reregister.
-    clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(
-        kDefaultIdleTimeoutSecs * 1000000 - 5000));
-    EXPECT_EQ(default_timeout, clock_.ApproximateNow());
-    connection_.GetTimeoutAlarm()->Fire();
-    EXPECT_TRUE(connection_.GetTimeoutAlarm()->IsSet());
-    EXPECT_TRUE(connection_.connected());
-    EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
-              connection_.GetTimeoutAlarm()->deadline());
-
-    // This time, we should time out.
-    EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
-    EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
-    clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
-    EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
-              clock_.ApproximateNow());
-    connection_.GetTimeoutAlarm()->Fire();
-    EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
-    EXPECT_FALSE(connection_.connected());
-    return;
-  }
   EXPECT_TRUE(connection_.connected());
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   QuicConfig config;
   connection_.SetFromConfig(config);
 
@@ -3055,7 +2996,7 @@
 
   // Set up a larger payload than will fit in one packet.
   const string payload(connection_.max_packet_length(), 'a');
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber());
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)).Times(AnyNumber());
 
   // Now send some packets with no truncation.
   EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
diff --git a/net/quic/quic_crypto_server_stream.cc b/net/quic/quic_crypto_server_stream.cc
index dac2087..1d62376 100644
--- a/net/quic/quic_crypto_server_stream.cc
+++ b/net/quic/quic_crypto_server_stream.cc
@@ -6,10 +6,10 @@
 
 #include "base/base64.h"
 #include "crypto/secure_hash.h"
+#include "net/quic/crypto/cached_network_parameters.h"
 #include "net/quic/crypto/crypto_protocol.h"
 #include "net/quic/crypto/crypto_utils.h"
 #include "net/quic/crypto/quic_crypto_server_config.h"
-#include "net/quic/crypto/source_address_token.h"
 #include "net/quic/quic_config.h"
 #include "net/quic/quic_flags.h"
 #include "net/quic/quic_protocol.h"
diff --git a/net/quic/quic_dispatcher.cc b/net/quic/quic_dispatcher.cc
index aede7c2..d27b454 100644
--- a/net/quic/quic_dispatcher.cc
+++ b/net/quic/quic_dispatcher.cc
@@ -352,8 +352,7 @@
   QuicServerSession* session = new QuicServerSession(
       config_,
       CreateQuicConnection(connection_id, server_address, client_address),
-      this,
-      crypto_config_.HasProofSource());
+      this);
   session->InitializeSession(crypto_config_);
   return session;
 }
@@ -368,6 +367,7 @@
                             connection_writer_factory_,
                             /* owns_writer= */ true,
                             /* is_server= */ true,
+                            crypto_config_.HasProofSource(),
                             supported_versions_);
 }
 
diff --git a/net/quic/quic_flags.cc b/net/quic/quic_flags.cc
index 8d6dd86..47d58ce 100644
--- a/net/quic/quic_flags.cc
+++ b/net/quic/quic_flags.cc
@@ -36,10 +36,6 @@
 // limit.
 bool FLAGS_quic_allow_more_open_streams = false;
 
-// If true, then QUIC connections will set both idle and overall timeouts in a
-// single method.
-bool FLAGS_quic_unified_timeouts = true;
-
 // If true, QUIC will be more resilliant to junk packets with valid connection
 // IDs.
 bool FLAGS_quic_drop_junk_packets = true;
diff --git a/net/quic/quic_flags.h b/net/quic/quic_flags.h
index d49f47a..a75f79b 100644
--- a/net/quic/quic_flags.h
+++ b/net/quic/quic_flags.h
@@ -15,7 +15,6 @@
 NET_EXPORT_PRIVATE extern bool FLAGS_enable_quic_fec;
 NET_EXPORT_PRIVATE extern bool FLAGS_quic_use_bbr_congestion_control;
 NET_EXPORT_PRIVATE extern bool FLAGS_quic_allow_more_open_streams;
-NET_EXPORT_PRIVATE extern bool FLAGS_quic_unified_timeouts;
 NET_EXPORT_PRIVATE extern bool FLAGS_quic_drop_junk_packets;
 NET_EXPORT_PRIVATE extern bool FLAGS_quic_allow_bbr;
 NET_EXPORT_PRIVATE extern bool FLAGS_allow_truncated_connection_ids_for_quic;
diff --git a/net/quic/quic_framer.cc b/net/quic/quic_framer.cc
index e2487b4..d2a7694 100644
--- a/net/quic/quic_framer.cc
+++ b/net/quic/quic_framer.cc
@@ -978,30 +978,30 @@
 QuicFramer::AckFrameInfo QuicFramer::GetAckFrameInfo(
     const QuicAckFrame& frame) {
   AckFrameInfo ack_info;
-  if (!frame.missing_packets.empty()) {
-    DCHECK_GE(frame.largest_observed, *frame.missing_packets.rbegin());
-    size_t cur_range_length = 0;
-    SequenceNumberSet::const_iterator iter = frame.missing_packets.begin();
-    QuicPacketSequenceNumber last_missing = *iter;
-    ++iter;
-    for (; iter != frame.missing_packets.end(); ++iter) {
-      if (cur_range_length != numeric_limits<uint8>::max() &&
-          *iter == (last_missing + 1)) {
-        ++cur_range_length;
-      } else {
-        ack_info.nack_ranges[last_missing - cur_range_length] =
-            cur_range_length;
-        cur_range_length = 0;
-      }
-      ack_info.max_delta = max(ack_info.max_delta, *iter - last_missing);
-      last_missing = *iter;
-    }
-    // Include the last nack range.
-    ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length;
-    // Include the range to the largest observed.
-    ack_info.max_delta = max(ack_info.max_delta,
-                             frame.largest_observed - last_missing);
+  if (frame.missing_packets.empty()) {
+    return ack_info;
   }
+  DCHECK_GE(frame.largest_observed, *frame.missing_packets.rbegin());
+  size_t cur_range_length = 0;
+  SequenceNumberSet::const_iterator iter = frame.missing_packets.begin();
+  QuicPacketSequenceNumber last_missing = *iter;
+  ++iter;
+  for (; iter != frame.missing_packets.end(); ++iter) {
+    if (cur_range_length != numeric_limits<uint8>::max() &&
+        *iter == (last_missing + 1)) {
+      ++cur_range_length;
+    } else {
+      ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length;
+      cur_range_length = 0;
+    }
+    ack_info.max_delta = max(ack_info.max_delta, *iter - last_missing);
+    last_missing = *iter;
+  }
+  // Include the last nack range.
+  ack_info.nack_ranges[last_missing - cur_range_length] = cur_range_length;
+  // Include the range to the largest observed.
+  ack_info.max_delta =
+      max(ack_info.max_delta, frame.largest_observed - last_missing);
   return ack_info;
 }
 
diff --git a/net/quic/quic_http_stream_test.cc b/net/quic/quic_http_stream_test.cc
index db97aac..a172c24 100644
--- a/net/quic/quic_http_stream_test.cc
+++ b/net/quic/quic_http_stream_test.cc
@@ -65,8 +65,9 @@
                        address,
                        helper,
                        writer_factory,
-                       true  /* owns_writer */,
+                       true   /* owns_writer */,
                        false  /* is_server */,
+                       false  /* is_secure */,
                        versions) {
   }
 
@@ -215,7 +216,7 @@
         WillRepeatedly(Return(QuicTime::Delta::Zero()));
     EXPECT_CALL(*send_algorithm_, BandwidthEstimate()).WillRepeatedly(
         Return(QuicBandwidth::Zero()));
-    EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber());
+    EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)).Times(AnyNumber());
     helper_.reset(new QuicConnectionHelper(runner_.get(), &clock_,
                                            &random_generator_));
     TestPacketWriterFactory writer_factory(socket);
@@ -232,7 +233,6 @@
                               &transport_security_state_,
                               make_scoped_ptr((QuicServerInfo*)nullptr),
                               DefaultQuicConfig(),
-                              /*is_secure=*/false,
                               base::MessageLoop::current()->
                                   message_loop_proxy().get(),
                               nullptr));
diff --git a/net/quic/quic_packet_creator.h b/net/quic/quic_packet_creator.h
index 287cde1..bada2c3 100644
--- a/net/quic/quic_packet_creator.h
+++ b/net/quic/quic_packet_creator.h
@@ -212,11 +212,11 @@
     next_sequence_number_length_ = length;
   }
 
-  size_t max_packet_length() const {
+  QuicByteCount max_packet_length() const {
     return max_packet_length_;
   }
 
-  void set_max_packet_length(size_t length) {
+  void set_max_packet_length(QuicByteCount length) {
     // |max_packet_length_| should not be changed mid-packet or mid-FEC group.
     DCHECK(fec_group_.get() == nullptr && queued_frames_.empty());
     max_packet_length_ = length;
@@ -272,7 +272,7 @@
   // packet.
   bool send_version_in_packet_;
   // Maximum length including headers and encryption (UDP payload length.)
-  size_t max_packet_length_;
+  QuicByteCount max_packet_length_;
   // 0 indicates FEC is disabled.
   size_t max_packets_per_fec_group_;
   // Length of connection_id to send over the wire.
diff --git a/net/quic/quic_packet_generator.cc b/net/quic/quic_packet_generator.cc
index 2481ddc..21ab10c 100644
--- a/net/quic/quic_packet_generator.cc
+++ b/net/quic/quic_packet_generator.cc
@@ -357,11 +357,11 @@
   return packet_creator_.sequence_number();
 }
 
-size_t QuicPacketGenerator::max_packet_length() const {
+QuicByteCount QuicPacketGenerator::max_packet_length() const {
   return packet_creator_.max_packet_length();
 }
 
-void QuicPacketGenerator::set_max_packet_length(size_t length) {
+void QuicPacketGenerator::set_max_packet_length(QuicByteCount length) {
   packet_creator_.set_max_packet_length(length);
 }
 
diff --git a/net/quic/quic_packet_generator.h b/net/quic/quic_packet_generator.h
index 3fec02a..2882aab 100644
--- a/net/quic/quic_packet_generator.h
+++ b/net/quic/quic_packet_generator.h
@@ -177,9 +177,9 @@
   // created.
   QuicPacketSequenceNumber sequence_number() const;
 
-  size_t max_packet_length() const;
+  QuicByteCount max_packet_length() const;
 
-  void set_max_packet_length(size_t length);
+  void set_max_packet_length(QuicByteCount length);
 
   void set_debug_delegate(DebugDelegate* debug_delegate) {
     debug_delegate_ = debug_delegate;
diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h
index ad920d0..00064ff 100644
--- a/net/quic/quic_protocol.h
+++ b/net/quic/quic_protocol.h
@@ -60,8 +60,11 @@
 const QuicByteCount kDefaultTCPMSS = 1460;
 
 // Maximum size of the initial congestion window in packets.
-const QuicPacketCount kDefaultInitialWindow = 10;
 const QuicPacketCount kMaxInitialWindow = 100;
+// We match SPDY's use of 32 when secure (since we'd compete with SPDY).
+const QuicPacketCount kInitialCongestionWindowSecure = 32;
+// Be conservative, and just use double a typical TCP ICWND for HTTP.
+const QuicPacketCount kInitialCongestionWindowInsecure = 20;
 
 // Default size of initial flow control window, for both stream and session.
 const uint32 kDefaultFlowControlSendWindow = 16 * 1024;  // 16 KB
diff --git a/net/quic/quic_reliable_client_stream.cc b/net/quic/quic_reliable_client_stream.cc
index e186b03..68651cb 100644
--- a/net/quic/quic_reliable_client_stream.cc
+++ b/net/quic/quic_reliable_client_stream.cc
@@ -83,7 +83,7 @@
 
 void QuicReliableClientStream::SetDelegate(
     QuicReliableClientStream::Delegate* delegate) {
-  DCHECK((!delegate_ && delegate) || (delegate_ && !delegate));
+  DCHECK(!(delegate_ && delegate));
   delegate_ = delegate;
 }
 
diff --git a/net/quic/quic_sent_packet_manager.cc b/net/quic/quic_sent_packet_manager.cc
index 9e2d04f..7978fed 100644
--- a/net/quic/quic_sent_packet_manager.cc
+++ b/net/quic/quic_sent_packet_manager.cc
@@ -34,8 +34,8 @@
 static const int64 kMaxRetransmissionTimeMs = 60000;
 static const size_t kMaxRetransmissions = 10;
 
-// Only exponentially back off the handshake timer 5 times due to a timeout.
-static const size_t kMaxHandshakeRetransmissionBackoffs = 5;
+// Ensure the handshake timer isnt't faster than 10ms.
+// This limits the tenth retransmitted packet to 10s after the initial CHLO.
 static const int64 kMinHandshakeTimeoutMs = 10;
 
 // Sends up to two tail loss probes before firing an RTO,
@@ -49,6 +49,10 @@
 // Number of unpaced packets to send after quiescence.
 static const size_t kInitialUnpacedBurst = 10;
 
+// Fraction of the receive buffer that can be used for encrypted bytes.
+// Allows a 5% overhead for IP and UDP framing, as well as ack only packets.
+static const float kUsableRecieveBufferFraction = 0.95f;
+
 bool HasCryptoHandshake(const TransmissionInfo& transmission_info) {
   if (transmission_info.retransmittable_frames == nullptr) {
     return false;
@@ -66,17 +70,22 @@
     const QuicClock* clock,
     QuicConnectionStats* stats,
     CongestionControlType congestion_control_type,
-    LossDetectionType loss_type)
+    LossDetectionType loss_type,
+    bool is_secure)
     : unacked_packets_(),
       is_server_(is_server),
       clock_(clock),
       stats_(stats),
       debug_delegate_(nullptr),
       network_change_visitor_(nullptr),
-      send_algorithm_(SendAlgorithmInterface::Create(clock,
-                                                     &rtt_stats_,
-                                                     congestion_control_type,
-                                                     stats)),
+      initial_congestion_window_(is_secure ? kInitialCongestionWindowSecure
+                                           : kInitialCongestionWindowInsecure),
+      send_algorithm_(
+          SendAlgorithmInterface::Create(clock,
+                                         &rtt_stats_,
+                                         congestion_control_type,
+                                         stats,
+                                         initial_congestion_window_)),
       loss_algorithm_(LossDetectionInterface::Create(loss_type)),
       n_connection_simulation_(false),
       receive_buffer_bytes_(kDefaultSocketReceiveBuffer),
@@ -116,15 +125,17 @@
       rtt_stats_.set_recent_min_rtt_window(
           QuicTime::Delta::FromSeconds(FLAGS_quic_recent_min_rtt_window_s));
     }
-    send_algorithm_.reset(
-        SendAlgorithmInterface::Create(clock_, &rtt_stats_, kBBR, stats_));
+    send_algorithm_.reset(SendAlgorithmInterface::Create(
+        clock_, &rtt_stats_, kBBR, stats_, initial_congestion_window_));
   }
   if (config.HasReceivedConnectionOptions() &&
       ContainsQuicTag(config.ReceivedConnectionOptions(), kRENO)) {
-    send_algorithm_.reset(
-        SendAlgorithmInterface::Create(clock_, &rtt_stats_, kReno, stats_));
+    send_algorithm_.reset(SendAlgorithmInterface::Create(
+        clock_, &rtt_stats_, kReno, stats_, initial_congestion_window_));
   }
-  if (HasClientSentConnectionOption(config, kPACE)) {
+  if (HasClientSentConnectionOption(config, kPACE) ||
+      (FLAGS_quic_allow_bbr &&
+       HasClientSentConnectionOption(config, kTBBR))) {
     EnablePacing();
   }
   if (HasClientSentConnectionOption(config, k1CON)) {
@@ -145,7 +156,7 @@
         max(kMinSocketReceiveBuffer,
             static_cast<QuicByteCount>(config.ReceivedSocketReceiveBuffer()));
   }
-  send_algorithm_->SetFromConfig(config, is_server_);
+  send_algorithm_->SetFromConfig(config, is_server_, using_pacing_);
 
   if (network_change_visitor_ != nullptr) {
     network_change_visitor_->OnCongestionWindowChange();
@@ -595,10 +606,7 @@
 
 void QuicSentPacketManager::RetransmitCryptoPackets() {
   DCHECK_EQ(HANDSHAKE_MODE, GetRetransmissionMode());
-  // TODO(ianswett): Typical TCP implementations only retransmit 5 times.
-  consecutive_crypto_retransmission_count_ =
-      min(kMaxHandshakeRetransmissionBackoffs,
-          consecutive_crypto_retransmission_count_ + 1);
+  ++consecutive_crypto_retransmission_count_;
   bool packet_retransmitted = false;
   QuicPacketSequenceNumber sequence_number = unacked_packets_.GetLeastUnacked();
   for (QuicUnackedPacketMap::const_iterator it = unacked_packets_.begin();
@@ -757,7 +765,8 @@
   if (pending_timer_transmission_count_ > 0) {
     return QuicTime::Delta::Zero();
   }
-  if (unacked_packets_.bytes_in_flight() >= receive_buffer_bytes_) {
+  if (unacked_packets_.bytes_in_flight() >=
+      kUsableRecieveBufferFraction * receive_buffer_bytes_) {
     return QuicTime::Delta::Infinite();
   }
   return send_algorithm_->TimeUntilSend(
diff --git a/net/quic/quic_sent_packet_manager.h b/net/quic/quic_sent_packet_manager.h
index f82e34b..2a3ea64 100644
--- a/net/quic/quic_sent_packet_manager.h
+++ b/net/quic/quic_sent_packet_manager.h
@@ -93,7 +93,8 @@
                         const QuicClock* clock,
                         QuicConnectionStats* stats,
                         CongestionControlType congestion_control_type,
-                        LossDetectionType loss_type);
+                        LossDetectionType loss_type,
+                        bool is_secure);
   virtual ~QuicSentPacketManager();
 
   virtual void SetFromConfig(const QuicConfig& config);
@@ -351,6 +352,7 @@
   QuicConnectionStats* stats_;
   DebugDelegate* debug_delegate_;
   NetworkChangeVisitor* network_change_visitor_;
+  const QuicPacketCount initial_congestion_window_;
   RttStats rtt_stats_;
   scoped_ptr<SendAlgorithmInterface> send_algorithm_;
   scoped_ptr<LossDetectionInterface> loss_algorithm_;
diff --git a/net/quic/quic_sent_packet_manager_test.cc b/net/quic/quic_sent_packet_manager_test.cc
index d7a846a..d710120 100644
--- a/net/quic/quic_sent_packet_manager_test.cc
+++ b/net/quic/quic_sent_packet_manager_test.cc
@@ -45,7 +45,7 @@
 class QuicSentPacketManagerTest : public ::testing::TestWithParam<bool> {
  protected:
   QuicSentPacketManagerTest()
-      : manager_(true, &clock_, &stats_, kCubic, kNack),
+      : manager_(true, &clock_, &stats_, kCubic, kNack, false),
         send_algorithm_(new StrictMock<MockSendAlgorithm>),
         network_change_visitor_(new StrictMock<MockNetworkChangeVisitor>) {
     QuicSentPacketManagerPeer::SetSendAlgorithm(&manager_, send_algorithm_);
@@ -1080,12 +1080,12 @@
 
   // Check the min.
   RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(&manager_);
-  rtt_stats->set_initial_rtt_us(1 * base::Time::kMicrosecondsPerMillisecond);
+  rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli);
   EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(10)),
             manager_.GetRetransmissionTime());
 
   // Test with a standard smoothed RTT.
-  rtt_stats->set_initial_rtt_us(100 * base::Time::kMicrosecondsPerMillisecond);
+  rtt_stats->set_initial_rtt_us(100 * kNumMicrosPerMilli);
 
   QuicTime::Delta srtt =
       QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
@@ -1109,12 +1109,12 @@
 
   // Check the min.
   RttStats* rtt_stats = QuicSentPacketManagerPeer::GetRttStats(&manager_);
-  rtt_stats->set_initial_rtt_us(1 * base::Time::kMicrosecondsPerMillisecond);
+  rtt_stats->set_initial_rtt_us(1 * kNumMicrosPerMilli);
   EXPECT_EQ(clock_.Now().Add(QuicTime::Delta::FromMilliseconds(10)),
             manager_.GetRetransmissionTime());
 
   // Test with a standard smoothed RTT.
-  rtt_stats->set_initial_rtt_us(100 * base::Time::kMicrosecondsPerMillisecond);
+  rtt_stats->set_initial_rtt_us(100 * kNumMicrosPerMilli);
   QuicTime::Delta srtt =
       QuicTime::Delta::FromMicroseconds(rtt_stats->initial_rtt_us());
   QuicTime::Delta expected_tlp_delay = srtt.Multiply(2);
@@ -1277,7 +1277,7 @@
   QuicTagVector options;
   options.push_back(kTIME);
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
   manager_.SetFromConfig(config);
 
@@ -1318,7 +1318,7 @@
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
   EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   manager_.SetFromConfig(config);
 
   QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
@@ -1326,7 +1326,7 @@
   client_config.SetConnectionOptionsToSend(options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
   EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(1));
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   manager_.SetFromConfig(client_config);
 }
 
@@ -1340,7 +1340,7 @@
   options.push_back(kNCON);
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   manager_.SetFromConfig(config);
 
   EXPECT_CALL(*send_algorithm_, SetNumEmulatedConnections(5));
@@ -1354,7 +1354,7 @@
   options.push_back(kNTLP);
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   manager_.SetFromConfig(config);
   EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
 }
@@ -1367,7 +1367,7 @@
   QuicSentPacketManagerPeer::SetIsServer(&manager_, false);
   client_config.SetConnectionOptionsToSend(options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   manager_.SetFromConfig(client_config);
   EXPECT_EQ(0u, QuicSentPacketManagerPeer::GetMaxTailLossProbes(&manager_));
 }
@@ -1380,7 +1380,7 @@
   options.push_back(kPACE);
   QuicConfigPeer::SetReceivedConnectionOptions(&config, options);
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, /* using_pacing= */ true));
   manager_.SetFromConfig(config);
 
   EXPECT_TRUE(manager_.using_pacing());
@@ -1393,7 +1393,7 @@
   // Try to set a size below the minimum and ensure it gets set to the min.
   QuicConfig client_config;
   QuicConfigPeer::SetReceivedSocketReceiveBuffer(&client_config, 1024);
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
   manager_.SetFromConfig(client_config);
 
@@ -1417,6 +1417,27 @@
             manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA));
 }
 
+TEST_F(QuicSentPacketManagerTest, ReceiveWindowLimited) {
+  EXPECT_EQ(kDefaultSocketReceiveBuffer,
+            QuicSentPacketManagerPeer::GetReceiveWindow(&manager_));
+
+  // Ensure the smaller send window only allows 256 * 0.95 packets to be sent.
+  for (QuicPacketSequenceNumber i = 1; i <= 244; ++i) {
+    EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _, _)).WillOnce(Return(
+        QuicTime::Delta::Zero()));
+    EXPECT_EQ(QuicTime::Delta::Zero(),
+              manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA));
+    EXPECT_CALL(*send_algorithm_, OnPacketSent(_, BytesInFlight(), i,
+                                               1024, HAS_RETRANSMITTABLE_DATA))
+        .WillOnce(Return(true));
+    SerializedPacket packet(CreatePacket(i, true));
+    manager_.OnPacketSent(&packet, 0, clock_.Now(), 1024,
+                          NOT_RETRANSMISSION, HAS_RETRANSMITTABLE_DATA);
+  }
+  EXPECT_EQ(QuicTime::Delta::Infinite(),
+            manager_.TimeUntilSend(clock_.Now(), HAS_RETRANSMITTABLE_DATA));
+}
+
 TEST_F(QuicSentPacketManagerTest, UseInitialRoundTripTimeToSend) {
   uint32 initial_rtt_us = 325000;
   EXPECT_NE(initial_rtt_us,
@@ -1424,7 +1445,7 @@
 
   QuicConfig config;
   config.SetInitialRoundTripTimeUsToSend(initial_rtt_us);
-  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
+  EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _));
   EXPECT_CALL(*network_change_visitor_, OnCongestionWindowChange());
   manager_.SetFromConfig(config);
 
diff --git a/net/quic/quic_server_session.cc b/net/quic/quic_server_session.cc
index 7fab509..1d48182 100644
--- a/net/quic/quic_server_session.cc
+++ b/net/quic/quic_server_session.cc
@@ -5,7 +5,7 @@
 #include "net/quic/quic_server_session.h"
 
 #include "base/logging.h"
-#include "net/quic/crypto/source_address_token.h"
+#include "net/quic/crypto/cached_network_parameters.h"
 #include "net/quic/quic_connection.h"
 #include "net/quic/quic_flags.h"
 #include "net/quic/quic_spdy_server_stream.h"
@@ -15,9 +15,8 @@
 
 QuicServerSession::QuicServerSession(const QuicConfig& config,
                                      QuicConnection* connection,
-                                     QuicServerSessionVisitor* visitor,
-                                     bool is_secure)
-    : QuicSession(connection, config, is_secure),
+                                     QuicServerSessionVisitor* visitor)
+    : QuicSession(connection, config),
       visitor_(visitor),
       bandwidth_estimate_sent_to_client_(QuicBandwidth::Zero()),
       last_scup_time_(QuicTime::Zero()),
diff --git a/net/quic/quic_server_session.h b/net/quic/quic_server_session.h
index a402005..43107a0 100644
--- a/net/quic/quic_server_session.h
+++ b/net/quic/quic_server_session.h
@@ -46,8 +46,7 @@
  public:
   QuicServerSession(const QuicConfig& config,
                     QuicConnection* connection,
-                    QuicServerSessionVisitor* visitor,
-                    bool is_secure);
+                    QuicServerSessionVisitor* visitor);
 
   // Override the base class to notify the owner of the connection close.
   void OnConnectionClosed(QuicErrorCode error, bool from_peer) override;
diff --git a/net/quic/quic_session.cc b/net/quic/quic_session.cc
index 34a668d..2318ab4 100644
--- a/net/quic/quic_session.cc
+++ b/net/quic/quic_session.cc
@@ -95,8 +95,7 @@
   QuicSession* session_;
 };
 
-QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config,
-                         bool is_secure)
+QuicSession::QuicSession(QuicConnection* connection, const QuicConfig& config)
     : connection_(connection),
       visitor_shim_(new VisitorShim(this)),
       config_(config),
@@ -106,8 +105,7 @@
       error_(QUIC_NO_ERROR),
       goaway_received_(false),
       goaway_sent_(false),
-      has_pending_handshake_(false),
-      is_secure_(is_secure) {
+      has_pending_handshake_(false) {
   if (connection_->version() == QUIC_VERSION_19) {
     flow_controller_.reset(new QuicFlowController(
         connection_.get(), 0, is_server(), kDefaultFlowControlSendWindow,
@@ -124,10 +122,6 @@
 void QuicSession::InitializeSession() {
   connection_->set_visitor(visitor_shim_.get());
   connection_->SetFromConfig(config_);
-  if (!FLAGS_quic_unified_timeouts && connection_->connected()) {
-    connection_->SetOverallConnectionTimeout(
-        config_.max_time_before_crypto_handshake());
-  }
   headers_stream_.reset(new QuicHeadersStream(this));
 }
 
@@ -569,9 +563,6 @@
       // Discard originally encrypted packets, since they can't be decrypted by
       // the peer.
       connection_->NeuterUnencryptedPackets();
-      if (!FLAGS_quic_unified_timeouts) {
-        connection_->SetOverallConnectionTimeout(QuicTime::Delta::Infinite());
-      }
       if (!FLAGS_quic_allow_more_open_streams) {
         max_open_streams_ = config_.MaxStreamsPerConnection();
       }
diff --git a/net/quic/quic_session.h b/net/quic/quic_session.h
index 6ca9ce0..43f4042 100644
--- a/net/quic/quic_session.h
+++ b/net/quic/quic_session.h
@@ -52,9 +52,7 @@
     HANDSHAKE_CONFIRMED,
   };
 
-  QuicSession(QuicConnection* connection,
-              const QuicConfig& config,
-              bool is_secure);
+  QuicSession(QuicConnection* connection, const QuicConfig& config);
   void InitializeSession();
 
   ~QuicSession() override;
@@ -212,8 +210,8 @@
   bool IsStreamFlowControlBlocked();
 
   // Returns true if this is a secure QUIC session.
-  bool is_secure() const {
-    return is_secure_;
+  bool IsSecure() const {
+    return connection()->is_secure();
   }
 
   size_t get_max_open_streams() const { return max_open_streams_; }
diff --git a/net/quic/quic_session_test.cc b/net/quic/quic_session_test.cc
index edbfbee..d14d875 100644
--- a/net/quic/quic_session_test.cc
+++ b/net/quic/quic_session_test.cc
@@ -125,9 +125,7 @@
 class TestSession : public QuicSession {
  public:
   explicit TestSession(QuicConnection* connection)
-      : QuicSession(connection,
-                    DefaultQuicConfig(),
-                    false),
+      : QuicSession(connection, DefaultQuicConfig()),
         crypto_stream_(this),
         writev_consumes_all_data_(false) {
     InitializeSession();
@@ -580,8 +578,7 @@
 }
 
 TEST_P(QuicSessionTest, IncreasedTimeoutAfterCryptoHandshake) {
-  EXPECT_EQ((FLAGS_quic_unified_timeouts ?
-             kInitialIdleTimeoutSecs : kDefaultIdleTimeoutSecs) + 3,
+  EXPECT_EQ(kInitialIdleTimeoutSecs + 3,
             QuicConnectionPeer::GetNetworkTimeout(connection_).ToSeconds());
   CryptoHandshakeMessage msg;
   session_.GetCryptoStream()->OnHandshakeMessage(msg);
diff --git a/net/quic/quic_stream_factory.cc b/net/quic/quic_stream_factory.cc
index 076797a..32adeda 100644
--- a/net/quic/quic_stream_factory.cc
+++ b/net/quic/quic_stream_factory.cc
@@ -60,16 +60,6 @@
 // The initial receive window size for both streams and sessions.
 const int32 kInitialReceiveWindowSize = 10 * 1024 * 1024;  // 10MB
 
-// The suggested initial congestion windows for a server to use.
-// TODO: This should be tested and optimized, and even better, suggest a window
-// that corresponds to historical bandwidth and min-RTT.
-// Larger initial congestion windows can, if we don't overshoot, reduce latency
-// by avoiding the RTT needed for slow start to double (and re-double) from a
-// default of 10.
-// We match SPDY's use of 32 when secure (since we'd compete with SPDY).
-const int32 kServerSecureInitialCongestionWindow = 32;
-// Be conservative, and just use double a typical TCP  ICWND for HTTP.
-const int32 kServerInecureInitialCongestionWindow = 20;
 // Set the maximum number of undecryptable packets the connection will store.
 const int32 kMaxUndecryptablePackets = 100;
 
@@ -922,15 +912,13 @@
                                                   packet_writer_factory,
                                                   true  /* owns_writer */,
                                                   false  /* is_server */,
+                                                  server_id.is_https(),
                                                   supported_versions_);
   connection->set_max_packet_length(max_packet_length_);
 
   InitializeCachedStateInCryptoConfig(server_id, server_info);
 
   QuicConfig config = config_;
-  config.SetInitialCongestionWindowToSend(
-      server_id.is_https() ? kServerSecureInitialCongestionWindow
-                           : kServerInecureInitialCongestionWindow);
   config.set_max_undecryptable_packets(kMaxUndecryptablePackets);
   config.SetInitialFlowControlWindowToSend(kInitialReceiveWindowSize);
   config.SetInitialStreamFlowControlWindowToSend(kInitialReceiveWindowSize);
@@ -954,7 +942,7 @@
 
   *session = new QuicClientSession(
       connection, socket.Pass(), this, transport_security_state_,
-      server_info.Pass(), config, server_id.is_https(),
+      server_info.Pass(), config,
       base::MessageLoop::current()->message_loop_proxy().get(),
       net_log.net_log());
   all_sessions_[*session] = server_id;  // owning pointer
diff --git a/net/quic/quic_time_wait_list_manager.cc b/net/quic/quic_time_wait_list_manager.cc
index d59cbc4..67d347f 100644
--- a/net/quic/quic_time_wait_list_manager.cc
+++ b/net/quic/quic_time_wait_list_manager.cc
@@ -27,9 +27,8 @@
 
 namespace {
 
-// Time period for which a given connection_id should live in the time-wait
-// state.
-int64 FLAGS_quic_time_wait_list_seconds = 5;
+// Time period for which the connection_id should live in time wait state.
+const int kTimeWaitSeconds = 5;
 
 }  // namespace
 
@@ -40,7 +39,8 @@
  public:
   explicit ConnectionIdCleanUpAlarm(
       QuicTimeWaitListManager* time_wait_list_manager)
-      : time_wait_list_manager_(time_wait_list_manager) {}
+      : time_wait_list_manager_(time_wait_list_manager) {
+  }
 
   QuicTime OnAlarm() override {
     time_wait_list_manager_->CleanUpOldConnectionIds();
@@ -67,7 +67,8 @@
                QuicEncryptedPacket* packet)
       : server_address_(server_address),
         client_address_(client_address),
-        packet_(packet) {}
+        packet_(packet) {
+  }
 
   const IPEndPoint& server_address() const { return server_address_; }
   const IPEndPoint& client_address() const { return client_address_; }
@@ -87,8 +88,7 @@
     QuicConnectionHelperInterface* helper,
     const QuicVersionVector& supported_versions)
     : helper_(helper),
-      kTimeWaitPeriod_(
-          QuicTime::Delta::FromSeconds(FLAGS_quic_time_wait_list_seconds)),
+      kTimeWaitPeriod_(QuicTime::Delta::FromSeconds(kTimeWaitSeconds)),
       connection_id_clean_up_alarm_(
           helper_->CreateAlarm(new ConnectionIdCleanUpAlarm(this))),
       writer_(writer),
@@ -276,7 +276,6 @@
       break;
     }
     // This connection_id has lived its age, retire it now.
-    DVLOG(1) << "Retiring " << it->first << " from the time-wait state.";
     delete it->second.close_packet;
     connection_id_map_.erase(it);
   }
diff --git a/net/quic/test_tools/quic_config_peer.cc b/net/quic/test_tools/quic_config_peer.cc
index 7c84001..d0f5bfd 100644
--- a/net/quic/test_tools/quic_config_peer.cc
+++ b/net/quic/test_tools/quic_config_peer.cc
@@ -10,12 +10,6 @@
 namespace test {
 
 // static
-void QuicConfigPeer::SetReceivedInitialWindow(QuicConfig* config,
-                                              size_t initial_window) {
-  config->initial_congestion_window_.SetReceivedValue(initial_window);
-}
-
-// static
 void QuicConfigPeer::SetReceivedSocketReceiveBuffer(
     QuicConfig* config,
     uint32 receive_buffer_bytes) {
diff --git a/net/quic/test_tools/quic_config_peer.h b/net/quic/test_tools/quic_config_peer.h
index 6c5e237..32e6bff 100644
--- a/net/quic/test_tools/quic_config_peer.h
+++ b/net/quic/test_tools/quic_config_peer.h
@@ -15,9 +15,6 @@
 
 class QuicConfigPeer {
  public:
-  static void SetReceivedInitialWindow(QuicConfig* config,
-                                       size_t initial_window);
-
   static void SetReceivedSocketReceiveBuffer(QuicConfig* config,
                                              uint32 receive_buffer_bytes);
 
diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
index ae3abfe..13e5eb1 100644
--- a/net/quic/test_tools/quic_test_utils.cc
+++ b/net/quic/test_tools/quic_test_utils.cc
@@ -221,21 +221,10 @@
   clock_.AdvanceTime(delta);
 }
 
-namespace {
-class NiceMockPacketWriterFactory
-    : public QuicConnection::PacketWriterFactory {
- public:
-  NiceMockPacketWriterFactory() {}
-  ~NiceMockPacketWriterFactory() override {}
-
-  QuicPacketWriter* Create(QuicConnection* /*connection*/) const override {
-    return new testing::NiceMock<MockPacketWriter>();
-  }
-
- private:
-  DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory);
-};
-}  // namespace
+QuicPacketWriter* NiceMockPacketWriterFactory::Create(
+    QuicConnection* /*connection*/) const {
+  return new testing::NiceMock<MockPacketWriter>();
+}
 
 MockConnection::MockConnection(bool is_server)
     : QuicConnection(kTestConnectionId,
@@ -243,7 +232,21 @@
                      new testing::NiceMock<MockHelper>(),
                      NiceMockPacketWriterFactory(),
                      /* owns_writer= */ true,
-                     is_server, QuicSupportedVersions()),
+                     is_server,
+                     /* is_secure= */ false,
+                     QuicSupportedVersions()),
+      helper_(helper()) {
+}
+
+MockConnection::MockConnection(bool is_server, bool is_secure)
+    : QuicConnection(kTestConnectionId,
+                     IPEndPoint(TestPeerIPAddress(), kTestPort),
+                     new testing::NiceMock<MockHelper>(),
+                     NiceMockPacketWriterFactory(),
+                     /* owns_writer= */ true,
+                     is_server,
+                     is_secure,
+                     QuicSupportedVersions()),
       helper_(helper()) {
 }
 
@@ -253,7 +256,9 @@
                      new testing::NiceMock<MockHelper>(),
                      NiceMockPacketWriterFactory(),
                      /* owns_writer= */ true,
-                     is_server, QuicSupportedVersions()),
+                     is_server,
+                     /* is_secure= */ false,
+                     QuicSupportedVersions()),
       helper_(helper()) {
 }
 
@@ -264,7 +269,9 @@
                      new testing::NiceMock<MockHelper>(),
                      NiceMockPacketWriterFactory(),
                      /* owns_writer= */ true,
-                     is_server, QuicSupportedVersions()),
+                     is_server,
+                     /* is_secure= */ false,
+                     QuicSupportedVersions()),
       helper_(helper()) {
 }
 
@@ -275,7 +282,9 @@
                      new testing::NiceMock<MockHelper>(),
                      NiceMockPacketWriterFactory(),
                      /* owns_writer= */ true,
-                     is_server, supported_versions),
+                     is_server,
+                     /* is_secure= */ false,
+                     supported_versions),
       helper_(helper()) {
 }
 
@@ -316,7 +325,7 @@
 }
 
 MockSession::MockSession(QuicConnection* connection)
-    : QuicSession(connection, DefaultQuicConfig(), /*is_secure=*/false) {
+    : QuicSession(connection, DefaultQuicConfig()) {
   InitializeSession();
   ON_CALL(*this, WritevData(_, _, _, _, _, _))
       .WillByDefault(testing::Return(QuicConsumedData(0, false)));
@@ -326,7 +335,7 @@
 }
 
 TestSession::TestSession(QuicConnection* connection, const QuicConfig& config)
-    : QuicSession(connection, config, /*is_secure=*/false),
+    : QuicSession(connection, config),
       crypto_stream_(nullptr) {
   InitializeSession();
 }
@@ -343,7 +352,7 @@
 
 TestClientSession::TestClientSession(QuicConnection* connection,
                                      const QuicConfig& config)
-    : QuicClientSessionBase(connection, config, /*is_secure=*/false),
+    : QuicClientSessionBase(connection, config),
       crypto_stream_(nullptr) {
   EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber());
   InitializeSession();
diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h
index ea5e5ef..fa987de 100644
--- a/net/quic/test_tools/quic_test_utils.h
+++ b/net/quic/test_tools/quic_test_utils.h
@@ -265,11 +265,25 @@
   DISALLOW_COPY_AND_ASSIGN(MockHelper);
 };
 
+class NiceMockPacketWriterFactory : public QuicConnection::PacketWriterFactory {
+ public:
+  NiceMockPacketWriterFactory() {}
+  ~NiceMockPacketWriterFactory() override {}
+
+  QuicPacketWriter* Create(QuicConnection* /*connection*/) const override;
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory);
+};
+
 class MockConnection : public QuicConnection {
  public:
   // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
   explicit MockConnection(bool is_server);
 
+  // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
+  MockConnection(bool is_server, bool is_secure);
+
   // Uses a MockHelper, ConnectionId of 42.
   MockConnection(IPEndPoint address, bool is_server);
 
@@ -437,7 +451,9 @@
   MockSendAlgorithm();
   virtual ~MockSendAlgorithm();
 
-  MOCK_METHOD2(SetFromConfig, void(const QuicConfig& config, bool is_server));
+  MOCK_METHOD3(SetFromConfig, void(const QuicConfig& config,
+                                   bool is_server,
+                                   bool using_pacing));
   MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections));
   MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size));
   MOCK_METHOD2(OnIncomingQuicCongestionFeedbackFrame,