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

Side by Side Diff: net/quic/crypto/quic_crypto_client_config.cc

Issue 431483002: QUIC - Added separate error condition for invalid expiry seconds and (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added histogram to track how expired server config is Created 6 years, 4 months 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 unified diff | Download patch
OLDNEW
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
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,
wtc 2014/08/04 23:36:30 Nit: this can be shortened to "SERVER_CONFIG_INVAL
ramant (doing other things) 2014/08/05 22:07:25 Done.
43 44
44 // 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
45 // sure to update the QuicServerConfigState enum in 46 // sure to update the QuicServerConfigState enum in
46 // tools/metrics/histograms/histograms.xml accordingly. 47 // tools/metrics/histograms/histograms.xml accordingly.
47 SERVER_CONFIG_COUNT 48 SERVER_CONFIG_COUNT
48 }; 49 };
49 50
50 void RecordServerConfigState(ServerConfigState server_config_state) { 51 void RecordServerConfigState(ServerConfigState server_config_state) {
51 UMA_HISTOGRAM_ENUMERATION("Net.QuicClientHelloServerConfigState", 52 UMA_HISTOGRAM_ENUMERATION("Net.QuicClientHelloServerConfigState",
52 server_config_state, SERVER_CONFIG_COUNT); 53 server_config_state, SERVER_CONFIG_COUNT);
(...skipping 27 matching lines...) Expand all
80 81
81 const CryptoHandshakeMessage* scfg = GetServerConfig(); 82 const CryptoHandshakeMessage* scfg = GetServerConfig();
82 if (!scfg) { 83 if (!scfg) {
83 // Should be impossible short of cache corruption. 84 // Should be impossible short of cache corruption.
84 DCHECK(false); 85 DCHECK(false);
85 RecordServerConfigState(SERVER_CONFIG_CORRUPTED); 86 RecordServerConfigState(SERVER_CONFIG_CORRUPTED);
86 return false; 87 return false;
87 } 88 }
88 89
89 uint64 expiry_seconds; 90 uint64 expiry_seconds;
90 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR || 91 if (scfg->GetUint64(kEXPY, &expiry_seconds) != QUIC_NO_ERROR) {
91 now.ToUNIXSeconds() >= expiry_seconds) { 92 RecordServerConfigState(SERVER_CONFIG_INVALID_EXPIRY_SECONDS);
93 return false;
94 }
95 if (now.ToUNIXSeconds() >= expiry_seconds) {
96 UMA_HISTOGRAM_TIMES(
97 "Net.QuicClientHelloServerConfig.HowExpired",
98 base::TimeDelta::FromSeconds(now.ToUNIXSeconds() - expiry_seconds));
92 RecordServerConfigState(SERVER_CONFIG_EXPIRED); 99 RecordServerConfigState(SERVER_CONFIG_EXPIRED);
93 return false; 100 return false;
94 } 101 }
95 102
96 return true; 103 return true;
97 } 104 }
98 105
99 bool QuicCryptoClientConfig::CachedState::IsEmpty() const { 106 bool QuicCryptoClientConfig::CachedState::IsEmpty() const {
100 return server_config_.empty(); 107 return server_config_.empty();
101 } 108 }
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 return; 851 return;
845 } 852 }
846 853
847 // Update canonical version to point at the "most recent" entry. 854 // Update canonical version to point at the "most recent" entry.
848 canonical_server_map_[suffix_server_id] = server_id; 855 canonical_server_map_[suffix_server_id] = server_id;
849 856
850 server_state->InitializeFrom(*canonical_state); 857 server_state->InitializeFrom(*canonical_state);
851 } 858 }
852 859
853 } // namespace net 860 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698