Chromium Code Reviews| Index: net/quic/crypto/quic_crypto_client_config.cc |
| diff --git a/net/quic/crypto/quic_crypto_client_config.cc b/net/quic/crypto/quic_crypto_client_config.cc |
| index 0ce7e83d27c85ea32f3c7c6e98cc9fa55fcfc58b..a273e43fc5d1778e4fd0e65e5e109b84538e7ba8 100644 |
| --- a/net/quic/crypto/quic_crypto_client_config.cc |
| +++ b/net/quic/crypto/quic_crypto_client_config.cc |
| @@ -38,13 +38,23 @@ QuicCryptoClientConfig::~QuicCryptoClientConfig() { |
| QuicCryptoClientConfig::CachedState::CachedState() |
| : server_config_valid_(false), |
| + need_to_persist_(false), |
| generation_counter_(0) {} |
| QuicCryptoClientConfig::CachedState::CachedState( |
| scoped_ptr<QuicServerInfo> quic_server_info) |
| : server_config_valid_(false), |
| + need_to_persist_(false), |
| generation_counter_(0), |
| - quic_server_info_(quic_server_info.Pass()) {} |
| + quic_server_info_(quic_server_info.Pass()) { |
| + if (quic_server_info_.get()) { |
| + QuicServerInfo::State* state = quic_server_info_->mutable_state(); |
| + state->SetConfigData(&server_config_, |
|
wtc
2014/02/19 02:24:11
It is a little dangerous for quic_server_info_ to
ramant (doing other things)
2014/02/19 02:57:53
This change shouldn't have been uploaded. I was ha
|
| + &source_address_token_, |
| + &certs_, |
| + &server_config_sig_); |
| + } |
| +} |
| QuicCryptoClientConfig::CachedState::~CachedState() {} |
| @@ -69,6 +79,10 @@ bool QuicCryptoClientConfig::CachedState::IsComplete(QuicWallTime now) const { |
| return true; |
| } |
| +bool QuicCryptoClientConfig::CachedState::IsEmpty() const { |
| + return server_config_.empty(); |
| +} |
| + |
| const CryptoHandshakeMessage* |
| QuicCryptoClientConfig::CachedState::GetServerConfig() const { |
| if (server_config_.empty()) { |
| @@ -118,6 +132,7 @@ QuicErrorCode QuicCryptoClientConfig::CachedState::SetServerConfig( |
| server_config_ = server_config.as_string(); |
| SetProofInvalid(); |
| scfg_.reset(new_scfg_storage.release()); |
| + need_to_persist_ = true; |
| } |
| return QUIC_NO_ERROR; |
| } |
| @@ -160,6 +175,7 @@ void QuicCryptoClientConfig::CachedState::ClearProof() { |
| void QuicCryptoClientConfig::CachedState::SetProofValid() { |
| server_config_valid_ = true; |
| + SaveQuicServerInfo(); |
| } |
| void QuicCryptoClientConfig::CachedState::SetProofInvalid() { |
| @@ -197,6 +213,10 @@ QuicCryptoClientConfig::CachedState::proof_verify_details() const { |
| return proof_verify_details_.get(); |
| } |
| +QuicServerInfo* QuicCryptoClientConfig::CachedState::quic_server_info() const { |
| + return quic_server_info_.get(); |
| +} |
| + |
| void QuicCryptoClientConfig::CachedState::set_source_address_token( |
| StringPiece token) { |
| source_address_token_ = token.as_string(); |
| @@ -218,6 +238,39 @@ void QuicCryptoClientConfig::CachedState::InitializeFrom( |
| server_config_valid_ = other.server_config_valid_; |
| } |
| +// TODO(rtenneti): LoadQuicServerInfo and SaveQuicServerInfo have duplication of |
| +// data in CachedState and QuicServerInfo. We should eliminate the duplication |
| +// of data. |
|
wtc
2014/02/19 02:24:11
I think you should remove this TODO comment now.
|
| +// An issue to be solved: while we are loading the data from disk cache, it is |
| +// possible for another request for the same hostname update the CachedState |
| +// because that request has sent FillInchoateClientHello and got REJ message. |
| +// Loading of data from disk cache shouldn't blindly overwrite what is in |
| +// CachedState. |
| +bool QuicCryptoClientConfig::CachedState::LoadQuicServerInfo(QuicWallTime now) { |
| + DCHECK(server_config_.empty()); |
| + DCHECK(quic_server_info_.get()); |
| + DCHECK(quic_server_info_->IsDataReady()); |
| + |
| + // TODO (rtenneti): Implement check for expiration. |
| + return true; |
| +} |
| + |
| +void QuicCryptoClientConfig::CachedState::SaveQuicServerInfo() { |
| + if (!quic_server_info_.get() || !need_to_persist_) { |
| + return; |
| + } |
| + DCHECK(server_config_valid_); |
| + |
| + // If the QuicServerInfo hasn't managed to load from disk yet then we can't |
| + // save anything. |
| + if (!quic_server_info_->IsDataReady()) { |
| + return; |
| + } |
| + |
| + quic_server_info_->Persist(); |
| + need_to_persist_ = false; |
| +} |
| + |
| void QuicCryptoClientConfig::SetDefaults() { |
| // Key exchange methods. |
| kexs.resize(2); |