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

Side by Side Diff: net/quic/core/quic_connection.cc

Issue 2651673004: Add quic_map_util. (Closed)
Patch Set: Created 3 years, 11 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/core/quic_buffered_packet_store_test.cc ('k') | net/quic/core/quic_connection_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/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <iterator> 11 #include <iterator>
12 #include <limits> 12 #include <limits>
13 #include <memory> 13 #include <memory>
14 #include <set> 14 #include <set>
15 #include <utility> 15 #include <utility>
16 16
17 #include "base/format_macros.h" 17 #include "base/format_macros.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
20 #include "base/stl_util.h"
21 #include "net/base/address_family.h" 20 #include "net/base/address_family.h"
22 #include "net/base/ip_address.h" 21 #include "net/base/ip_address.h"
23 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
24 #include "net/quic/core/crypto/crypto_protocol.h" 23 #include "net/quic/core/crypto/crypto_protocol.h"
25 #include "net/quic/core/crypto/quic_decrypter.h" 24 #include "net/quic/core/crypto/quic_decrypter.h"
26 #include "net/quic/core/crypto/quic_encrypter.h" 25 #include "net/quic/core/crypto/quic_encrypter.h"
27 #include "net/quic/core/proto/cached_network_parameters.pb.h" 26 #include "net/quic/core/proto/cached_network_parameters.pb.h"
28 #include "net/quic/core/quic_bandwidth.h" 27 #include "net/quic/core/quic_bandwidth.h"
29 #include "net/quic/core/quic_config.h" 28 #include "net/quic/core/quic_config.h"
30 #include "net/quic/core/quic_flags.h" 29 #include "net/quic/core/quic_flags.h"
31 #include "net/quic/core/quic_packet_generator.h" 30 #include "net/quic/core/quic_packet_generator.h"
32 #include "net/quic/core/quic_pending_retransmission.h" 31 #include "net/quic/core/quic_pending_retransmission.h"
33 #include "net/quic/core/quic_utils.h" 32 #include "net/quic/core/quic_utils.h"
34 #include "net/quic/platform/api/quic_bug_tracker.h" 33 #include "net/quic/platform/api/quic_bug_tracker.h"
35 #include "net/quic/platform/api/quic_logging.h" 34 #include "net/quic/platform/api/quic_logging.h"
35 #include "net/quic/platform/api/quic_map_util.h"
36 #include "net/quic/platform/api/quic_str_cat.h" 36 #include "net/quic/platform/api/quic_str_cat.h"
37 #include "net/quic/platform/api/quic_text_utils.h" 37 #include "net/quic/platform/api/quic_text_utils.h"
38 38
39 using base::StringPiece; 39 using base::StringPiece;
40 using std::string; 40 using std::string;
41 41
42 namespace net { 42 namespace net {
43 43
44 class QuicDecrypter; 44 class QuicDecrypter;
45 class QuicEncrypter; 45 class QuicEncrypter;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 } 386 }
387 387
388 bool QuicConnection::SelectMutualVersion( 388 bool QuicConnection::SelectMutualVersion(
389 const QuicVersionVector& available_versions) { 389 const QuicVersionVector& available_versions) {
390 // Try to find the highest mutual version by iterating over supported 390 // Try to find the highest mutual version by iterating over supported
391 // versions, starting with the highest, and breaking out of the loop once we 391 // versions, starting with the highest, and breaking out of the loop once we
392 // find a matching version in the provided available_versions vector. 392 // find a matching version in the provided available_versions vector.
393 const QuicVersionVector& supported_versions = framer_.supported_versions(); 393 const QuicVersionVector& supported_versions = framer_.supported_versions();
394 for (size_t i = 0; i < supported_versions.size(); ++i) { 394 for (size_t i = 0; i < supported_versions.size(); ++i) {
395 const QuicVersion& version = supported_versions[i]; 395 const QuicVersion& version = supported_versions[i];
396 if (base::ContainsValue(available_versions, version)) { 396 if (QuicContainsValue(available_versions, version)) {
397 framer_.set_version(version); 397 framer_.set_version(version);
398 return true; 398 return true;
399 } 399 }
400 } 400 }
401 401
402 return false; 402 return false;
403 } 403 }
404 404
405 void QuicConnection::OnError(QuicFramer* framer) { 405 void QuicConnection::OnError(QuicFramer* framer) {
406 // Packets that we can not or have not decrypted are dropped. 406 // Packets that we can not or have not decrypted are dropped.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 } 504 }
505 if (debug_visitor_ != nullptr) { 505 if (debug_visitor_ != nullptr) {
506 debug_visitor_->OnVersionNegotiationPacket(packet); 506 debug_visitor_->OnVersionNegotiationPacket(packet);
507 } 507 }
508 508
509 if (version_negotiation_state_ != START_NEGOTIATION) { 509 if (version_negotiation_state_ != START_NEGOTIATION) {
510 // Possibly a duplicate version negotiation packet. 510 // Possibly a duplicate version negotiation packet.
511 return; 511 return;
512 } 512 }
513 513
514 if (base::ContainsValue(packet.versions, version())) { 514 if (QuicContainsValue(packet.versions, version())) {
515 const string error_details = 515 const string error_details =
516 "Server already supports client's version and should have accepted the " 516 "Server already supports client's version and should have accepted the "
517 "connection."; 517 "connection.";
518 QUIC_DLOG(WARNING) << error_details; 518 QUIC_DLOG(WARNING) << error_details;
519 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, 519 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
520 error_details, 520 error_details,
521 ConnectionCloseSource::FROM_SELF); 521 ConnectionCloseSource::FROM_SELF);
522 return; 522 return;
523 } 523 }
524 524
(...skipping 1921 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 2446
2447 void QuicConnection::CheckIfApplicationLimited() { 2447 void QuicConnection::CheckIfApplicationLimited() {
2448 if (queued_packets_.empty() && 2448 if (queued_packets_.empty() &&
2449 !sent_packet_manager_.HasPendingRetransmissions() && 2449 !sent_packet_manager_.HasPendingRetransmissions() &&
2450 !visitor_->WillingAndAbleToWrite()) { 2450 !visitor_->WillingAndAbleToWrite()) {
2451 sent_packet_manager_.OnApplicationLimited(); 2451 sent_packet_manager_.OnApplicationLimited();
2452 } 2452 }
2453 } 2453 }
2454 2454
2455 } // namespace net 2455 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_buffered_packet_store_test.cc ('k') | net/quic/core/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698