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

Unified Diff: net/quic/core/crypto/quic_crypto_client_config.cc

Issue 2541163005: [m56 merge] Make QuicCryptoClientConfig only cache server configs for 1 week. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/quic/core/crypto/quic_crypto_client_config_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/core/crypto/quic_crypto_client_config.cc
diff --git a/net/quic/core/crypto/quic_crypto_client_config.cc b/net/quic/core/crypto/quic_crypto_client_config.cc
index f9899fc6ef51a61e440e14f4ef2918563fec453f..fa8dfade2dd18b41731312337ea3fa4846cfd6b2 100644
--- a/net/quic/core/crypto/quic_crypto_client_config.cc
+++ b/net/quic/core/crypto/quic_crypto_client_config.cc
@@ -4,6 +4,7 @@
#include "net/quic/core/crypto/quic_crypto_client_config.h"
+#include <algorithm>
#include <memory>
#include "base/memory/ptr_util.h"
@@ -24,6 +25,7 @@
#include "net/quic/core/crypto/quic_random.h"
#include "net/quic/core/quic_bug_tracker.h"
#include "net/quic/core/quic_flags.h"
+#include "net/quic/core/quic_time.h"
#include "net/quic/core/quic_utils.h"
using base::StringPiece;
@@ -87,17 +89,17 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
return false;
}
- if (now.IsAfter(expiration_time_)) {
- UMA_HISTOGRAM_CUSTOM_TIMES(
- "Net.QuicClientHelloServerConfig.InvalidDuration",
- base::TimeDelta::FromSeconds(now.ToUNIXSeconds() -
- expiration_time_.ToUNIXSeconds()),
- base::TimeDelta::FromMinutes(1), base::TimeDelta::FromDays(20), 50);
- RecordInchoateClientHelloReason(SERVER_CONFIG_EXPIRED);
- return false;
+ if (now.IsBefore(expiration_time_)) {
+ return true;
}
- return true;
+ UMA_HISTOGRAM_CUSTOM_TIMES(
+ "Net.QuicClientHelloServerConfig.InvalidDuration",
+ base::TimeDelta::FromSeconds(now.ToUNIXSeconds() -
+ expiration_time_.ToUNIXSeconds()),
+ base::TimeDelta::FromMinutes(1), base::TimeDelta::FromDays(20), 50);
+ RecordInchoateClientHelloReason(SERVER_CONFIG_EXPIRED);
+ return false;
}
bool QuicCryptoClientConfig::CachedState::IsEmpty() const {
@@ -737,7 +739,9 @@ QuicErrorCode QuicCryptoClientConfig::CacheNewServerConfig(
QuicWallTime expiration_time = QuicWallTime::Zero();
uint64_t expiry_seconds;
if (message.GetUint64(kSTTL, &expiry_seconds) == QUIC_NO_ERROR) {
- expiration_time = now.Add(QuicTime::Delta::FromSeconds(expiry_seconds));
+ // Only cache configs for a maximum of 1 week.
+ expiration_time = now.Add(QuicTime::Delta::FromSeconds(
+ std::min(expiry_seconds, kNumSecondsPerWeek)));
}
CachedState::ServerConfigState state =
« no previous file with comments | « no previous file | net/quic/core/crypto/quic_crypto_client_config_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698