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

Side by Side Diff: net/quic/quic_crypto_server_stream.cc

Issue 648933003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with TOT Created 6 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
« no previous file with comments | « net/quic/quic_crypto_server_stream.h ('k') | net/quic/quic_crypto_server_stream_test.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic_crypto_server_stream.h" 5 #include "net/quic/quic_crypto_server_stream.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "crypto/secure_hash.h" 8 #include "crypto/secure_hash.h"
9 #include "net/quic/crypto/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/crypto_utils.h" 10 #include "net/quic/crypto/crypto_utils.h"
11 #include "net/quic/crypto/quic_crypto_server_config.h" 11 #include "net/quic/crypto/quic_crypto_server_config.h"
12 #include "net/quic/crypto/source_address_token.h" 12 #include "net/quic/crypto/source_address_token.h"
13 #include "net/quic/quic_config.h" 13 #include "net/quic/quic_config.h"
14 #include "net/quic/quic_flags.h"
14 #include "net/quic/quic_protocol.h" 15 #include "net/quic/quic_protocol.h"
15 #include "net/quic/quic_session.h" 16 #include "net/quic/quic_session.h"
16 17
17 namespace net { 18 namespace net {
18 19
19 void ServerHelloNotifier::OnAckNotification( 20 void ServerHelloNotifier::OnAckNotification(
20 int num_original_packets, 21 int num_original_packets,
21 int num_original_bytes, 22 int num_original_bytes,
22 int num_retransmitted_packets, 23 int num_retransmitted_packets,
23 int num_retransmitted_bytes, 24 int num_retransmitted_bytes,
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 session()->connection()->SetAlternativeDecrypter( 146 session()->connection()->SetAlternativeDecrypter(
146 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(), 147 crypto_negotiated_params_.forward_secure_crypters.decrypter.release(),
147 ENCRYPTION_FORWARD_SECURE, false /* don't latch */); 148 ENCRYPTION_FORWARD_SECURE, false /* don't latch */);
148 149
149 encryption_established_ = true; 150 encryption_established_ = true;
150 handshake_confirmed_ = true; 151 handshake_confirmed_ = true;
151 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); 152 session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED);
152 153
153 // Now that the handshake is complete, send an updated server config and 154 // Now that the handshake is complete, send an updated server config and
154 // source-address token to the client. 155 // source-address token to the client.
155 SendServerConfigUpdate(nullptr); 156 SendServerConfigUpdate(previous_cached_network_params_.get(), true);
156 } 157 }
157 158
158 void QuicCryptoServerStream::SendServerConfigUpdate( 159 void QuicCryptoServerStream::SendServerConfigUpdate(
159 const CachedNetworkParameters* cached_network_params) { 160 const CachedNetworkParameters* cached_network_params,
161 bool on_handshake_complete) {
160 if (session()->connection()->version() <= QUIC_VERSION_21 || 162 if (session()->connection()->version() <= QUIC_VERSION_21 ||
161 !handshake_confirmed_) { 163 !handshake_confirmed_) {
162 return; 164 return;
163 } 165 }
164 166
165 CryptoHandshakeMessage server_config_update_message; 167 CryptoHandshakeMessage server_config_update_message;
166 if (!crypto_config_.BuildServerConfigUpdateMessage( 168 if (!crypto_config_.BuildServerConfigUpdateMessage(
167 session()->connection()->peer_address(), 169 session()->connection()->peer_address(),
168 session()->connection()->clock(), 170 session()->connection()->clock(),
169 session()->connection()->random_generator(), 171 session()->connection()->random_generator(),
170 crypto_negotiated_params_, 172 crypto_negotiated_params_,
171 cached_network_params, 173 cached_network_params,
172 &server_config_update_message)) { 174 &server_config_update_message)) {
173 DVLOG(1) << "Server: Failed to build server config update (SCUP)!"; 175 DVLOG(1) << "Server: Failed to build server config update (SCUP)!";
174 return; 176 return;
175 } 177 }
176 178
177 DVLOG(1) << "Server: Sending server config update: " 179 DVLOG(1) << "Server: Sending server config update"
180 << (on_handshake_complete ? " immediately after handshake: " : ": ")
178 << server_config_update_message.DebugString(); 181 << server_config_update_message.DebugString();
179 const QuicData& data = server_config_update_message.GetSerialized(); 182 const QuicData& data = server_config_update_message.GetSerialized();
180 WriteOrBufferData(string(data.data(), data.length()), false, nullptr); 183 WriteOrBufferData(string(data.data(), data.length()), false, nullptr);
181 184
182 ++num_server_config_update_messages_sent_; 185 ++num_server_config_update_messages_sent_;
183 } 186 }
184 187
185 void QuicCryptoServerStream::OnServerHelloAcked() { 188 void QuicCryptoServerStream::OnServerHelloAcked() {
186 session()->connection()->OnHandshakeComplete(); 189 session()->connection()->OnHandshakeComplete();
187 } 190 }
(...skipping 26 matching lines...) Expand all
214 } 217 }
215 } 218 }
216 return true; 219 return true;
217 } 220 }
218 221
219 QuicErrorCode QuicCryptoServerStream::ProcessClientHello( 222 QuicErrorCode QuicCryptoServerStream::ProcessClientHello(
220 const CryptoHandshakeMessage& message, 223 const CryptoHandshakeMessage& message,
221 const ValidateClientHelloResultCallback::Result& result, 224 const ValidateClientHelloResultCallback::Result& result,
222 CryptoHandshakeMessage* reply, 225 CryptoHandshakeMessage* reply,
223 string* error_details) { 226 string* error_details) {
227 // Store the bandwidth estimate from the client.
228 if (FLAGS_quic_store_cached_network_params_from_chlo &&
229 result.cached_network_params.bandwidth_estimate_bytes_per_second() > 0) {
230 previous_cached_network_params_.reset(
231 new CachedNetworkParameters(result.cached_network_params));
232 }
233
224 return crypto_config_.ProcessClientHello( 234 return crypto_config_.ProcessClientHello(
225 result, 235 result,
226 session()->connection()->connection_id(), 236 session()->connection()->connection_id(),
227 session()->connection()->peer_address(), 237 session()->connection()->peer_address(),
228 session()->connection()->version(), 238 session()->connection()->version(),
229 session()->connection()->supported_versions(), 239 session()->connection()->supported_versions(),
230 session()->connection()->clock(), 240 session()->connection()->clock(),
231 session()->connection()->random_generator(), 241 session()->connection()->random_generator(),
232 &crypto_negotiated_params_, reply, error_details); 242 &crypto_negotiated_params_, reply, error_details);
233 } 243 }
234 244
235 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) { 245 void QuicCryptoServerStream::OverrideQuicConfigDefaults(QuicConfig* config) {
236 } 246 }
237 247
238 QuicCryptoServerStream::ValidateCallback::ValidateCallback( 248 QuicCryptoServerStream::ValidateCallback::ValidateCallback(
239 QuicCryptoServerStream* parent) : parent_(parent) { 249 QuicCryptoServerStream* parent) : parent_(parent) {
240 } 250 }
241 251
242 void QuicCryptoServerStream::ValidateCallback::Cancel() { parent_ = nullptr; } 252 void QuicCryptoServerStream::ValidateCallback::Cancel() { parent_ = nullptr; }
243 253
244 void QuicCryptoServerStream::ValidateCallback::RunImpl( 254 void QuicCryptoServerStream::ValidateCallback::RunImpl(
245 const CryptoHandshakeMessage& client_hello, 255 const CryptoHandshakeMessage& client_hello,
246 const Result& result) { 256 const Result& result) {
247 if (parent_ != nullptr) { 257 if (parent_ != nullptr) {
248 parent_->FinishProcessingHandshakeMessage(client_hello, result); 258 parent_->FinishProcessingHandshakeMessage(client_hello, result);
249 } 259 }
250 } 260 }
251 261
252 } // namespace net 262 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream.h ('k') | net/quic/quic_crypto_server_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698