| 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/core/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 } // namespace | 55 } // namespace |
| 56 | 56 |
| 57 QuicCryptoClientConfig::QuicCryptoClientConfig( | 57 QuicCryptoClientConfig::QuicCryptoClientConfig( |
| 58 std::unique_ptr<ProofVerifier> proof_verifier) | 58 std::unique_ptr<ProofVerifier> proof_verifier) |
| 59 : proof_verifier_(std::move(proof_verifier)) { | 59 : proof_verifier_(std::move(proof_verifier)) { |
| 60 DCHECK(proof_verifier_.get()); | 60 DCHECK(proof_verifier_.get()); |
| 61 SetDefaults(); | 61 SetDefaults(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 QuicCryptoClientConfig::~QuicCryptoClientConfig() { | 64 QuicCryptoClientConfig::~QuicCryptoClientConfig() { |
| 65 STLDeleteValues(&cached_states_); | 65 base::STLDeleteValues(&cached_states_); |
| 66 } | 66 } |
| 67 | 67 |
| 68 QuicCryptoClientConfig::CachedState::CachedState() | 68 QuicCryptoClientConfig::CachedState::CachedState() |
| 69 : server_config_valid_(false), generation_counter_(0) {} | 69 : server_config_valid_(false), generation_counter_(0) {} |
| 70 | 70 |
| 71 QuicCryptoClientConfig::CachedState::~CachedState() {} | 71 QuicCryptoClientConfig::CachedState::~CachedState() {} |
| 72 | 72 |
| 73 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { | 73 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { |
| 74 if (server_config_.empty()) { | 74 if (server_config_.empty()) { |
| 75 RecordInchoateClientHelloReason(SERVER_CONFIG_EMPTY); | 75 RecordInchoateClientHelloReason(SERVER_CONFIG_EMPTY); |
| (...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 base::CompareCase::INSENSITIVE_ASCII)) { | 951 base::CompareCase::INSENSITIVE_ASCII)) { |
| 952 break; | 952 break; |
| 953 } | 953 } |
| 954 } | 954 } |
| 955 if (i == canonical_suffixes_.size()) { | 955 if (i == canonical_suffixes_.size()) { |
| 956 return false; | 956 return false; |
| 957 } | 957 } |
| 958 | 958 |
| 959 QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(), | 959 QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(), |
| 960 server_id.privacy_mode()); | 960 server_id.privacy_mode()); |
| 961 if (!ContainsKey(canonical_server_map_, suffix_server_id)) { | 961 if (!base::ContainsKey(canonical_server_map_, suffix_server_id)) { |
| 962 // This is the first host we've seen which matches the suffix, so make it | 962 // This is the first host we've seen which matches the suffix, so make it |
| 963 // canonical. | 963 // canonical. |
| 964 canonical_server_map_[suffix_server_id] = server_id; | 964 canonical_server_map_[suffix_server_id] = server_id; |
| 965 return false; | 965 return false; |
| 966 } | 966 } |
| 967 | 967 |
| 968 const QuicServerId& canonical_server_id = | 968 const QuicServerId& canonical_server_id = |
| 969 canonical_server_map_[suffix_server_id]; | 969 canonical_server_map_[suffix_server_id]; |
| 970 CachedState* canonical_state = cached_states_[canonical_server_id]; | 970 CachedState* canonical_state = cached_states_[canonical_server_id]; |
| 971 if (!canonical_state->proof_valid()) { | 971 if (!canonical_state->proof_valid()) { |
| 972 return false; | 972 return false; |
| 973 } | 973 } |
| 974 | 974 |
| 975 // Update canonical version to point at the "most recent" entry. | 975 // Update canonical version to point at the "most recent" entry. |
| 976 canonical_server_map_[suffix_server_id] = server_id; | 976 canonical_server_map_[suffix_server_id] = server_id; |
| 977 | 977 |
| 978 server_state->InitializeFrom(*canonical_state); | 978 server_state->InitializeFrom(*canonical_state); |
| 979 return true; | 979 return true; |
| 980 } | 980 } |
| 981 | 981 |
| 982 } // namespace net | 982 } // namespace net |
| OLD | NEW |