| 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 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 840 bool QuicCryptoClientConfig::PopulateFromCanonicalConfig( | 840 bool QuicCryptoClientConfig::PopulateFromCanonicalConfig( |
| 841 const QuicServerId& server_id, | 841 const QuicServerId& server_id, |
| 842 CachedState* server_state) { | 842 CachedState* server_state) { |
| 843 DCHECK(server_state->IsEmpty()); | 843 DCHECK(server_state->IsEmpty()); |
| 844 size_t i = 0; | 844 size_t i = 0; |
| 845 for (; i < canonical_suffixes_.size(); ++i) { | 845 for (; i < canonical_suffixes_.size(); ++i) { |
| 846 if (EndsWith(server_id.host(), canonical_suffixes_[i], false)) { | 846 if (EndsWith(server_id.host(), canonical_suffixes_[i], false)) { |
| 847 break; | 847 break; |
| 848 } | 848 } |
| 849 } | 849 } |
| 850 if (i == canonical_suffixes_.size()) | 850 if (i == canonical_suffixes_.size()) { |
| 851 return false; | 851 return false; |
| 852 } |
| 852 | 853 |
| 853 QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(), | 854 QuicServerId suffix_server_id(canonical_suffixes_[i], server_id.port(), |
| 854 server_id.is_https(), | 855 server_id.is_https(), |
| 855 server_id.privacy_mode()); | 856 server_id.privacy_mode()); |
| 856 if (!ContainsKey(canonical_server_map_, suffix_server_id)) { | 857 if (!ContainsKey(canonical_server_map_, suffix_server_id)) { |
| 857 // This is the first host we've seen which matches the suffix, so make it | 858 // This is the first host we've seen which matches the suffix, so make it |
| 858 // canonical. | 859 // canonical. |
| 859 canonical_server_map_[suffix_server_id] = server_id; | 860 canonical_server_map_[suffix_server_id] = server_id; |
| 860 return false; | 861 return false; |
| 861 } | 862 } |
| 862 | 863 |
| 863 const QuicServerId& canonical_server_id = | 864 const QuicServerId& canonical_server_id = |
| 864 canonical_server_map_[suffix_server_id]; | 865 canonical_server_map_[suffix_server_id]; |
| 865 CachedState* canonical_state = cached_states_[canonical_server_id]; | 866 CachedState* canonical_state = cached_states_[canonical_server_id]; |
| 866 if (!canonical_state->proof_valid()) { | 867 if (!canonical_state->proof_valid()) { |
| 867 return false; | 868 return false; |
| 868 } | 869 } |
| 869 | 870 |
| 870 // Update canonical version to point at the "most recent" entry. | 871 // Update canonical version to point at the "most recent" entry. |
| 871 canonical_server_map_[suffix_server_id] = server_id; | 872 canonical_server_map_[suffix_server_id] = server_id; |
| 872 | 873 |
| 873 server_state->InitializeFrom(*canonical_state); | 874 server_state->InitializeFrom(*canonical_state); |
| 874 return true; | 875 return true; |
| 875 } | 876 } |
| 876 | 877 |
| 877 } // namespace net | 878 } // namespace net |
| OLD | NEW |