OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/quic_config.h" | 5 #include "net/quic/quic_config.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 case QUIC_NO_ERROR: | 273 case QUIC_NO_ERROR: |
274 has_receive_value_ = true; | 274 has_receive_value_ = true; |
275 break; | 275 break; |
276 default: | 276 default: |
277 *error_details = "Bad " + QuicUtils::TagToString(tag_); | 277 *error_details = "Bad " + QuicUtils::TagToString(tag_); |
278 break; | 278 break; |
279 } | 279 } |
280 return error; | 280 return error; |
281 } | 281 } |
282 | 282 |
283 QuicFixedTag::QuicFixedTag(QuicTag name, | |
284 QuicConfigPresence presence) | |
285 : QuicConfigValue(name, presence), | |
286 has_send_value_(false), | |
287 has_receive_value_(false) { | |
288 } | |
289 | |
290 QuicFixedTag::~QuicFixedTag() {} | |
291 | |
292 bool QuicFixedTag::HasSendValue() const { | |
293 return has_send_value_; | |
294 } | |
295 | |
296 uint32 QuicFixedTag::GetSendValue() const { | |
297 LOG_IF(DFATAL, !has_send_value_) | |
298 << "No send value to get for tag:" << QuicUtils::TagToString(tag_); | |
299 return send_value_; | |
300 } | |
301 | |
302 void QuicFixedTag::SetSendValue(uint32 value) { | |
303 has_send_value_ = true; | |
304 send_value_ = value; | |
305 } | |
306 | |
307 bool QuicFixedTag::HasReceivedValue() const { | |
308 return has_receive_value_; | |
309 } | |
310 | |
311 uint32 QuicFixedTag::GetReceivedValue() const { | |
312 LOG_IF(DFATAL, !has_receive_value_) | |
313 << "No receive value to get for tag:" << QuicUtils::TagToString(tag_); | |
314 return receive_value_; | |
315 } | |
316 | |
317 void QuicFixedTag::SetReceivedValue(uint32 value) { | |
318 has_receive_value_ = true; | |
319 receive_value_ = value; | |
320 } | |
321 | |
322 void QuicFixedTag::ToHandshakeMessage(CryptoHandshakeMessage* out) const { | |
323 if (has_send_value_) { | |
324 out->SetValue(tag_, send_value_); | |
325 } | |
326 } | |
327 | |
328 QuicErrorCode QuicFixedTag::ProcessPeerHello( | |
329 const CryptoHandshakeMessage& peer_hello, | |
330 HelloType hello_type, | |
331 string* error_details) { | |
332 DCHECK(error_details != nullptr); | |
333 QuicErrorCode error = peer_hello.GetUint32(tag_, &receive_value_); | |
334 switch (error) { | |
335 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: | |
336 if (presence_ == PRESENCE_OPTIONAL) { | |
337 return QUIC_NO_ERROR; | |
338 } | |
339 *error_details = "Missing " + QuicUtils::TagToString(tag_); | |
340 break; | |
341 case QUIC_NO_ERROR: | |
342 has_receive_value_ = true; | |
343 break; | |
344 default: | |
345 *error_details = "Bad " + QuicUtils::TagToString(tag_); | |
346 break; | |
347 } | |
348 return error; | |
349 } | |
350 | |
351 QuicFixedTagVector::QuicFixedTagVector(QuicTag name, | 283 QuicFixedTagVector::QuicFixedTagVector(QuicTag name, |
352 QuicConfigPresence presence) | 284 QuicConfigPresence presence) |
353 : QuicConfigValue(name, presence), | 285 : QuicConfigValue(name, presence), |
354 has_send_values_(false), | 286 has_send_values_(false), |
355 has_receive_values_(false) { | 287 has_receive_values_(false) { |
356 } | 288 } |
357 | 289 |
358 QuicFixedTagVector::~QuicFixedTagVector() {} | 290 QuicFixedTagVector::~QuicFixedTagVector() {} |
359 | 291 |
360 bool QuicFixedTagVector::HasSendValues() const { | 292 bool QuicFixedTagVector::HasSendValues() const { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 idle_connection_state_lifetime_seconds_.set( | 401 idle_connection_state_lifetime_seconds_.set( |
470 static_cast<uint32>(max_idle_connection_state_lifetime.ToSeconds()), | 402 static_cast<uint32>(max_idle_connection_state_lifetime.ToSeconds()), |
471 static_cast<uint32>(default_idle_conection_state_lifetime.ToSeconds())); | 403 static_cast<uint32>(default_idle_conection_state_lifetime.ToSeconds())); |
472 } | 404 } |
473 | 405 |
474 QuicTime::Delta QuicConfig::IdleConnectionStateLifetime() const { | 406 QuicTime::Delta QuicConfig::IdleConnectionStateLifetime() const { |
475 return QuicTime::Delta::FromSeconds( | 407 return QuicTime::Delta::FromSeconds( |
476 idle_connection_state_lifetime_seconds_.GetUint32()); | 408 idle_connection_state_lifetime_seconds_.GetUint32()); |
477 } | 409 } |
478 | 410 |
| 411 // TODO(ianswett) Use this for silent close on mobile, or delete. |
479 void QuicConfig::SetSilentClose(bool silent_close) { | 412 void QuicConfig::SetSilentClose(bool silent_close) { |
480 silent_close_.set(silent_close ? 1 : 0, silent_close ? 1 : 0); | 413 silent_close_.set(silent_close ? 1 : 0, silent_close ? 1 : 0); |
481 } | 414 } |
482 | 415 |
483 bool QuicConfig::SilentClose() const { | 416 bool QuicConfig::SilentClose() const { |
484 return silent_close_.GetUint32() > 0; | 417 return silent_close_.GetUint32() > 0; |
485 } | 418 } |
486 | 419 |
487 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, | 420 void QuicConfig::SetMaxStreamsPerConnection(size_t max_streams, |
488 size_t default_streams) { | 421 size_t default_streams) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 } | 503 } |
571 | 504 |
572 uint32 QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { | 505 uint32 QuicConfig::ReceivedInitialSessionFlowControlWindowBytes() const { |
573 return initial_session_flow_control_window_bytes_.GetReceivedValue(); | 506 return initial_session_flow_control_window_bytes_.GetReceivedValue(); |
574 } | 507 } |
575 | 508 |
576 void QuicConfig::SetSocketReceiveBufferToSend(uint32 tcp_receive_window) { | 509 void QuicConfig::SetSocketReceiveBufferToSend(uint32 tcp_receive_window) { |
577 socket_receive_buffer_.SetSendValue(tcp_receive_window); | 510 socket_receive_buffer_.SetSendValue(tcp_receive_window); |
578 } | 511 } |
579 | 512 |
580 uint32 QuicConfig::GetSocketReceiveBufferToSend() const { | |
581 return socket_receive_buffer_.GetSendValue(); | |
582 } | |
583 | |
584 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { | 513 bool QuicConfig::HasReceivedSocketReceiveBuffer() const { |
585 return socket_receive_buffer_.HasReceivedValue(); | 514 return socket_receive_buffer_.HasReceivedValue(); |
586 } | 515 } |
587 | 516 |
588 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { | 517 uint32 QuicConfig::ReceivedSocketReceiveBuffer() const { |
589 return socket_receive_buffer_.GetReceivedValue(); | 518 return socket_receive_buffer_.GetReceivedValue(); |
590 } | 519 } |
591 | 520 |
592 bool QuicConfig::negotiated() const { | 521 bool QuicConfig::negotiated() const { |
593 // TODO(ianswett): Add the negotiated parameters once and iterate over all | 522 // TODO(ianswett): Add the negotiated parameters once and iterate over all |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 peer_hello, hello_type, error_details); | 602 peer_hello, hello_type, error_details); |
674 } | 603 } |
675 if (error == QUIC_NO_ERROR) { | 604 if (error == QUIC_NO_ERROR) { |
676 error = connection_options_.ProcessPeerHello( | 605 error = connection_options_.ProcessPeerHello( |
677 peer_hello, hello_type, error_details); | 606 peer_hello, hello_type, error_details); |
678 } | 607 } |
679 return error; | 608 return error; |
680 } | 609 } |
681 | 610 |
682 } // namespace net | 611 } // namespace net |
OLD | NEW |