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

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

Issue 2417023003: Remove stl_util's deletion functions from: (Closed)
Patch Set: internal snapshot 10 Created 4 years, 2 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/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/memory/ptr_util.h"
9 #include "base/metrics/histogram_macros.h" 10 #include "base/metrics/histogram_macros.h"
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "net/quic/core/crypto/cert_compressor.h" 13 #include "net/quic/core/crypto/cert_compressor.h"
13 #include "net/quic/core/crypto/chacha20_poly1305_encrypter.h" 14 #include "net/quic/core/crypto/chacha20_poly1305_encrypter.h"
14 #include "net/quic/core/crypto/channel_id.h" 15 #include "net/quic/core/crypto/channel_id.h"
15 #include "net/quic/core/crypto/common_cert_set.h" 16 #include "net/quic/core/crypto/common_cert_set.h"
16 #include "net/quic/core/crypto/crypto_framer.h" 17 #include "net/quic/core/crypto/crypto_framer.h"
17 #include "net/quic/core/crypto/crypto_utils.h" 18 #include "net/quic/core/crypto/crypto_utils.h"
18 #include "net/quic/core/crypto/curve25519_key_exchange.h" 19 #include "net/quic/core/crypto/curve25519_key_exchange.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } // namespace 56 } // namespace
56 57
57 QuicCryptoClientConfig::QuicCryptoClientConfig( 58 QuicCryptoClientConfig::QuicCryptoClientConfig(
58 std::unique_ptr<ProofVerifier> proof_verifier) 59 std::unique_ptr<ProofVerifier> proof_verifier)
59 : proof_verifier_(std::move(proof_verifier)) { 60 : proof_verifier_(std::move(proof_verifier)) {
60 DCHECK(proof_verifier_.get()); 61 DCHECK(proof_verifier_.get());
61 SetDefaults(); 62 SetDefaults();
62 } 63 }
63 64
64 QuicCryptoClientConfig::~QuicCryptoClientConfig() { 65 QuicCryptoClientConfig::~QuicCryptoClientConfig() {
65 base::STLDeleteValues(&cached_states_);
66 } 66 }
67 67
68 QuicCryptoClientConfig::CachedState::CachedState() 68 QuicCryptoClientConfig::CachedState::CachedState()
69 : server_config_valid_(false), 69 : server_config_valid_(false),
70 expiration_time_(QuicWallTime::Zero()), 70 expiration_time_(QuicWallTime::Zero()),
71 generation_counter_(0) {} 71 generation_counter_(0) {}
72 72
73 QuicCryptoClientConfig::CachedState::~CachedState() {} 73 QuicCryptoClientConfig::CachedState::~CachedState() {}
74 74
75 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { 75 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 void QuicCryptoClientConfig::SetDefaults() { 386 void QuicCryptoClientConfig::SetDefaults() {
387 // Key exchange methods. 387 // Key exchange methods.
388 kexs = {kC255, kP256}; 388 kexs = {kC255, kP256};
389 389
390 // Authenticated encryption algorithms. Prefer RFC 7539 ChaCha20 by default. 390 // Authenticated encryption algorithms. Prefer RFC 7539 ChaCha20 by default.
391 aead = {kCC20, kAESG}; 391 aead = {kCC20, kAESG};
392 } 392 }
393 393
394 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( 394 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
395 const QuicServerId& server_id) { 395 const QuicServerId& server_id) {
396 CachedStateMap::const_iterator it = cached_states_.find(server_id); 396 auto it = cached_states_.find(server_id);
397 if (it != cached_states_.end()) { 397 if (it != cached_states_.end()) {
398 return it->second; 398 return it->second.get();
399 } 399 }
400 400
401 CachedState* cached = new CachedState; 401 CachedState* cached = new CachedState;
402 cached_states_.insert(std::make_pair(server_id, cached)); 402 cached_states_.insert(std::make_pair(server_id, base::WrapUnique(cached)));
403 bool cache_populated = PopulateFromCanonicalConfig(server_id, cached); 403 bool cache_populated = PopulateFromCanonicalConfig(server_id, cached);
404 UMA_HISTOGRAM_BOOLEAN( 404 UMA_HISTOGRAM_BOOLEAN(
405 "Net.QuicCryptoClientConfig.PopulatedFromCanonicalConfig", 405 "Net.QuicCryptoClientConfig.PopulatedFromCanonicalConfig",
406 cache_populated); 406 cache_populated);
407 return cached; 407 return cached;
408 } 408 }
409 409
410 void QuicCryptoClientConfig::ClearCachedStates(const ServerIdFilter& filter) { 410 void QuicCryptoClientConfig::ClearCachedStates(const ServerIdFilter& filter) {
411 for (CachedStateMap::const_iterator it = cached_states_.begin(); 411 for (auto it = cached_states_.begin(); it != cached_states_.end(); ++it) {
412 it != cached_states_.end(); ++it) {
413 if (filter.Matches(it->first)) 412 if (filter.Matches(it->first))
414 it->second->Clear(); 413 it->second->Clear();
415 } 414 }
416 } 415 }
417 416
418 void QuicCryptoClientConfig::FillInchoateClientHello( 417 void QuicCryptoClientConfig::FillInchoateClientHello(
419 const QuicServerId& server_id, 418 const QuicServerId& server_id,
420 const QuicVersion preferred_version, 419 const QuicVersion preferred_version,
421 const CachedState* cached, 420 const CachedState* cached,
422 QuicRandom* rand, 421 QuicRandom* rand,
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
976 server_id.privacy_mode()); 975 server_id.privacy_mode());
977 if (!base::ContainsKey(canonical_server_map_, suffix_server_id)) { 976 if (!base::ContainsKey(canonical_server_map_, suffix_server_id)) {
978 // This is the first host we've seen which matches the suffix, so make it 977 // This is the first host we've seen which matches the suffix, so make it
979 // canonical. 978 // canonical.
980 canonical_server_map_[suffix_server_id] = server_id; 979 canonical_server_map_[suffix_server_id] = server_id;
981 return false; 980 return false;
982 } 981 }
983 982
984 const QuicServerId& canonical_server_id = 983 const QuicServerId& canonical_server_id =
985 canonical_server_map_[suffix_server_id]; 984 canonical_server_map_[suffix_server_id];
986 CachedState* canonical_state = cached_states_[canonical_server_id]; 985 CachedState* canonical_state = cached_states_[canonical_server_id].get();
987 if (!canonical_state->proof_valid()) { 986 if (!canonical_state->proof_valid()) {
988 return false; 987 return false;
989 } 988 }
990 989
991 // Update canonical version to point at the "most recent" entry. 990 // Update canonical version to point at the "most recent" entry.
992 canonical_server_map_[suffix_server_id] = server_id; 991 canonical_server_map_[suffix_server_id] = server_id;
993 992
994 server_state->InitializeFrom(*canonical_state); 993 server_state->InitializeFrom(*canonical_state);
995 return true; 994 return true;
996 } 995 }
997 996
998 } // namespace net 997 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_crypto_client_config.h ('k') | net/quic/core/crypto/quic_crypto_server_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698