src/net/quic/quic_client_session_cache_unittests.cc
// Expired session isn't considered valid and nullptr will be returned upon
// Lookup.
Expired session isn't considered valid and nullptr will be returned upon
Lookup.
Expired session isn ' t considered valid and nullptr will be returned upon Lookup .
TEST_F(QuicClientSessionCacheTest, Expiration) {
  const base::TimeDelta kTimeout = base::TimeDelta::FromSeconds(1000);
  QuicClientSessionCache cache;
  std::unique_ptr<base::SimpleTestClock> clock = MakeTestClock();
  cache.SetClockForTesting(clock.get());
  std::unique_ptr<quic::QuicResumptionState> state1 =
      std::make_unique<quic::QuicResumptionState>();
  state1->tls_session = MakeTestSession(clock->Now(), kTimeout);
  quic::QuicServerId id1("a.com", 443);
  std::unique_ptr<quic::QuicResumptionState> state2 =
      std::make_unique<quic::QuicResumptionState>();
  state2->tls_session = MakeTestSession(clock->Now(), 3 * kTimeout);
  ;
  state2->application_state.push_back('b');
  quic::QuicServerId id2("b.com", 443);
  cache.Insert(id1, std::move(state1));
  cache.Insert(id2, std::move(state2));
  EXPECT_EQ(2u, cache.size());
  clock->Advance(kTimeout * 2);
  EXPECT_EQ(2u, cache.size());
  EXPECT_EQ(nullptr, cache.Lookup(id1, ssl_ctx_.get()));
  EXPECT_EQ(1u, cache.size());
  EXPECT_EQ('b', cache.Lookup(id2, ssl_ctx_.get())->application_state.front());
  EXPECT_EQ(0u, cache.size());
}
TEST_F ( QuicClientSessionCacheTest , Expiration ) { const base :: TimeDelta kTimeout = base :: TimeDelta :: FromSeconds ( 1000 ) ; QuicClientSessionCache cache ; std :: unique_ptr < base :: SimpleTestClock > clock = MakeTestClock ( ) ; cache . SetClockForTesting ( clock . get ( ) ) ; std :: unique_ptr < quic :: QuicResumptionState > state1 = std :: make_unique < quic :: QuicResumptionState > ( ) ; state1 -> tls_session = MakeTestSession ( clock -> Now ( ) , kTimeout ) ; quic :: QuicServerId id1 ( " " , 443 ) ; std :: unique_ptr < quic :: QuicResumptionState > state2 = std :: make_unique < quic :: QuicResumptionState > ( ) ; state2 -> tls_session = MakeTestSession ( clock -> Now ( ) , 3 * kTimeout ) ; ; state2 -> application_state . push_back ( ' ' ) ; quic :: QuicServerId id2 ( " " , 443 ) ; cache . Insert ( id1 , std :: move ( state1 ) ) ; cache . Insert ( id2 , std :: move ( state2 ) ) ; EXPECT_EQ ( 2u , cache . size ( ) ) ; clock -> Advance ( kTimeout * 2 ) ; EXPECT_EQ ( 2u , cache . size ( ) ) ; EXPECT_EQ ( nullptr , cache . Lookup ( id1 , ssl_ctx_ . get ( ) ) ) ; EXPECT_EQ ( 1u , cache . size ( ) ) ; EXPECT_EQ ( ' ' , cache . Lookup ( id2 , ssl_ctx_ . get ( ) ) -> application_state . front ( ) ) ; EXPECT_EQ ( 0u , cache . size ( ) ) ; }
Expired session isn't considered valid and nullptr will be returned upon
Lookup.
Expired session isn ' t considered valid and nullptr will be returned upon Lookup .
// Expire the session. // The entry has not been removed yet.