OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 namespace { | 33 namespace { |
34 | 34 |
35 enum ServerConfigState { | 35 enum ServerConfigState { |
36 // WARNING: Do not change the numerical values of any of server config state. | 36 // WARNING: Do not change the numerical values of any of server config state. |
37 // Do not remove deprecated server config states - just comment them as | 37 // Do not remove deprecated server config states - just comment them as |
38 // deprecated. | 38 // deprecated. |
39 SERVER_CONFIG_EMPTY = 0, | 39 SERVER_CONFIG_EMPTY = 0, |
40 SERVER_CONFIG_INVALID = 1, | 40 SERVER_CONFIG_INVALID = 1, |
41 SERVER_CONFIG_CORRUPTED = 2, | 41 SERVER_CONFIG_CORRUPTED = 2, |
42 SERVER_CONFIG_EXPIRED = 3, | 42 SERVER_CONFIG_EXPIRED = 3, |
43 SERVER_CONFIG_INVALID_EXPIRY_SECONDS = 4, | 43 SERVER_CONFIG_INVALID_EXPIRY = 4, |
44 | 44 |
45 // NOTE: Add new server config states only immediately above this line. Make | 45 // NOTE: Add new server config states only immediately above this line. Make |
46 // sure to update the QuicServerConfigState enum in | 46 // sure to update the QuicServerConfigState enum in |
47 // tools/metrics/histograms/histograms.xml accordingly. | 47 // tools/metrics/histograms/histograms.xml accordingly. |
48 SERVER_CONFIG_COUNT | 48 SERVER_CONFIG_COUNT |
49 }; | 49 }; |
50 | 50 |
51 void RecordServerConfigState(ServerConfigState server_config_state) { | 51 void RecordServerConfigState(ServerConfigState server_config_state) { |
52 UMA_HISTOGRAM_ENUMERATION("Net.QuicClientHelloServerConfigState", | 52 UMA_HISTOGRAM_ENUMERATION("Net.QuicClientHelloServerConfigState", |
53 server_config_state, SERVER_CONFIG_COUNT); | 53 server_config_state, SERVER_CONFIG_COUNT); |
(...skipping 28 matching lines...) Expand all Loading... |
82 const CryptoHandshakeMessage* scfg = GetServerConfig(); | 82 const CryptoHandshakeMessage* scfg = GetServerConfig(); |
83 if (!scfg) { | 83 if (!scfg) { |
84 // Should be impossible short of cache corruption. | 84 // Should be impossible short of cache corruption. |
85 DCHECK(false); | 85 DCHECK(false); |
86 RecordServerConfigState(SERVER_CONFIG_CORRUPTED); | 86 RecordServerConfigState(SERVER_CONFIG_CORRUPTED); |
87 return false; | 87 return false; |
88 } | 88 } |
89 | 89 |
90 uint64 expiry_seconds; | 90 uint64 expiry_seconds; |
91 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR) { | 91 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR) { |
92 RecordServerConfigState(SERVER_CONFIG_INVALID_EXPIRY_SECONDS); | 92 RecordServerConfigState(SERVER_CONFIG_INVALID_EXPIRY); |
93 return false; | 93 return false; |
94 } | 94 } |
95 if (now.ToUNIXSeconds() >= expiry_seconds) { | 95 if (now.ToUNIXSeconds() >= expiry_seconds) { |
96 UMA_HISTOGRAM_TIMES( | 96 UMA_HISTOGRAM_CUSTOM_TIMES( |
97 "Net.QuicClientHelloServerConfig.HowExpired", | 97 "Net.QuicClientHelloServerConfig.InvalidDuration", |
98 base::TimeDelta::FromSeconds(now.ToUNIXSeconds() - expiry_seconds)); | 98 base::TimeDelta::FromSeconds(now.ToUNIXSeconds() - expiry_seconds), |
| 99 base::TimeDelta::FromMinutes(1), base::TimeDelta::FromDays(20), 50); |
99 RecordServerConfigState(SERVER_CONFIG_EXPIRED); | 100 RecordServerConfigState(SERVER_CONFIG_EXPIRED); |
100 return false; | 101 return false; |
101 } | 102 } |
102 | 103 |
103 return true; | 104 return true; |
104 } | 105 } |
105 | 106 |
106 bool QuicCryptoClientConfig::CachedState::IsEmpty() const { | 107 bool QuicCryptoClientConfig::CachedState::IsEmpty() const { |
107 return server_config_.empty(); | 108 return server_config_.empty(); |
108 } | 109 } |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 return; | 852 return; |
852 } | 853 } |
853 | 854 |
854 // Update canonical version to point at the "most recent" entry. | 855 // Update canonical version to point at the "most recent" entry. |
855 canonical_server_map_[suffix_server_id] = server_id; | 856 canonical_server_map_[suffix_server_id] = server_id; |
856 | 857 |
857 server_state->InitializeFrom(*canonical_state); | 858 server_state->InitializeFrom(*canonical_state); |
858 } | 859 } |
859 | 860 |
860 } // namespace net | 861 } // namespace net |
OLD | NEW |