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

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

Issue 149413008: QUIC - Start the process for reading crypto config data from disk cache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with TOT Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/crypto/quic_crypto_client_config.h ('k') | net/quic/quic_stream_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/stl_util.h" 7 #include "base/stl_util.h"
8 #include "net/quic/crypto/cert_compressor.h" 8 #include "net/quic/crypto/cert_compressor.h"
9 #include "net/quic/crypto/channel_id.h" 9 #include "net/quic/crypto/channel_id.h"
10 #include "net/quic/crypto/common_cert_set.h" 10 #include "net/quic/crypto/common_cert_set.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/win/windows_version.h" 22 #include "base/win/windows_version.h"
23 #endif 23 #endif
24 24
25 using base::StringPiece; 25 using base::StringPiece;
26 using std::map; 26 using std::map;
27 using std::string; 27 using std::string;
28 using std::vector; 28 using std::vector;
29 29
30 namespace net { 30 namespace net {
31 31
32 QuicCryptoClientConfig::QuicCryptoClientConfig() 32 QuicCryptoClientConfig::QuicCryptoClientConfig() {
33 : quic_server_info_factory_(NULL) {
34 }
35
36 QuicCryptoClientConfig::QuicCryptoClientConfig(
37 QuicServerInfoFactory* quic_server_info_factory)
38 : quic_server_info_factory_(quic_server_info_factory) {
39 } 33 }
40 34
41 QuicCryptoClientConfig::~QuicCryptoClientConfig() { 35 QuicCryptoClientConfig::~QuicCryptoClientConfig() {
42 STLDeleteValues(&cached_states_); 36 STLDeleteValues(&cached_states_);
43 } 37 }
44 38
45 QuicCryptoClientConfig::CachedState::CachedState() 39 QuicCryptoClientConfig::CachedState::CachedState()
46 : server_config_valid_(false), 40 : server_config_valid_(false),
47 generation_counter_(0) {} 41 generation_counter_(0) {}
48 42
43 QuicCryptoClientConfig::CachedState::CachedState(
44 scoped_ptr<QuicServerInfo> quic_server_info)
45 : server_config_valid_(false),
46 generation_counter_(0),
47 quic_server_info_(quic_server_info.Pass()) {}
48
49 QuicCryptoClientConfig::CachedState::~CachedState() {} 49 QuicCryptoClientConfig::CachedState::~CachedState() {}
50 50
51 void QuicCryptoClientConfig::CachedState::LoadFromDiskCache(
52 QuicServerInfoFactory* quic_server_info_factory,
53 const string& server_hostname) {
54 DCHECK(quic_server_info_factory);
55 quic_server_info_.reset(
56 quic_server_info_factory->GetForHost(server_hostname));
57
58 // TODO(rtenneti): Need to flesh out reading data from disk cache.
59 }
60
61 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { 51 bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const {
62 if (server_config_.empty() || !server_config_valid_) { 52 if (server_config_.empty() || !server_config_valid_) {
63 return false; 53 return false;
64 } 54 }
65 55
66 const CryptoHandshakeMessage* scfg = GetServerConfig(); 56 const CryptoHandshakeMessage* scfg = GetServerConfig();
67 if (!scfg) { 57 if (!scfg) {
68 // Should be impossible short of cache corruption. 58 // Should be impossible short of cache corruption.
69 DCHECK(false); 59 DCHECK(false);
70 return false; 60 return false;
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 // Key exchange methods. 222 // Key exchange methods.
233 kexs.resize(2); 223 kexs.resize(2);
234 kexs[0] = kC255; 224 kexs[0] = kC255;
235 kexs[1] = kP256; 225 kexs[1] = kP256;
236 226
237 // Authenticated encryption algorithms. 227 // Authenticated encryption algorithms.
238 aead.resize(1); 228 aead.resize(1);
239 aead[0] = kAESG; 229 aead[0] = kAESG;
240 } 230 }
241 231
232 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::Create(
233 const string& server_hostname,
234 QuicServerInfoFactory* quic_server_info_factory) {
235 DCHECK(cached_states_.find(server_hostname) == cached_states_.end());
236 scoped_ptr<QuicServerInfo> quic_server_info;
237 if (quic_server_info_factory) {
238 quic_server_info.reset(
239 quic_server_info_factory->GetForHost(server_hostname));
240 quic_server_info->Start();
241 }
242
243 CachedState* cached = new CachedState(quic_server_info.Pass());
244 cached_states_.insert(make_pair(server_hostname, cached));
245 return cached;
246 }
247
242 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate( 248 QuicCryptoClientConfig::CachedState* QuicCryptoClientConfig::LookupOrCreate(
243 const string& server_hostname) { 249 const string& server_hostname) {
244 map<string, CachedState*>::const_iterator it = 250 map<string, CachedState*>::const_iterator it =
245 cached_states_.find(server_hostname); 251 cached_states_.find(server_hostname);
246 if (it != cached_states_.end()) { 252 if (it != cached_states_.end()) {
247 return it->second; 253 return it->second;
248 } 254 }
249 255 return Create(server_hostname, NULL);
250 CachedState* cached = new CachedState;
251 if (quic_server_info_factory_) {
252 cached->LoadFromDiskCache(quic_server_info_factory_, server_hostname);
253 }
254 cached_states_.insert(make_pair(server_hostname, cached));
255 return cached;
256 } 256 }
257 257
258 void QuicCryptoClientConfig::FillInchoateClientHello( 258 void QuicCryptoClientConfig::FillInchoateClientHello(
259 const string& server_hostname, 259 const string& server_hostname,
260 const QuicVersion preferred_version, 260 const QuicVersion preferred_version,
261 const CachedState* cached, 261 const CachedState* cached,
262 QuicCryptoNegotiatedParameters* out_params, 262 QuicCryptoNegotiatedParameters* out_params,
263 CryptoHandshakeMessage* out) const { 263 CryptoHandshakeMessage* out) const {
264 out->set_tag(kCHLO); 264 out->set_tag(kCHLO);
265 out->set_minimum_size(kClientHelloMinimumSize); 265 out->set_minimum_size(kClientHelloMinimumSize);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 CachedState* canonical_cached = 667 CachedState* canonical_cached =
668 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); 668 canonical_crypto_config->LookupOrCreate(canonical_server_hostname);
669 if (!canonical_cached->proof_valid()) { 669 if (!canonical_cached->proof_valid()) {
670 return; 670 return;
671 } 671 }
672 CachedState* cached = LookupOrCreate(server_hostname); 672 CachedState* cached = LookupOrCreate(server_hostname);
673 cached->InitializeFrom(*canonical_cached); 673 cached->InitializeFrom(*canonical_cached);
674 } 674 }
675 675
676 } // namespace net 676 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/quic_crypto_client_config.h ('k') | net/quic/quic_stream_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698