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

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

Issue 2591143003: Add QuicStrCat. (Closed)
Patch Set: sync Created 3 years, 12 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_bandwidth_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>
(...skipping 18 matching lines...) Expand all
29 #include "net/quic/core/crypto/quic_encrypter.h" 29 #include "net/quic/core/crypto/quic_encrypter.h"
30 #include "net/quic/core/proto/cached_network_parameters.pb.h" 30 #include "net/quic/core/proto/cached_network_parameters.pb.h"
31 #include "net/quic/core/quic_bandwidth.h" 31 #include "net/quic/core/quic_bandwidth.h"
32 #include "net/quic/core/quic_bug_tracker.h" 32 #include "net/quic/core/quic_bug_tracker.h"
33 #include "net/quic/core/quic_config.h" 33 #include "net/quic/core/quic_config.h"
34 #include "net/quic/core/quic_flags.h" 34 #include "net/quic/core/quic_flags.h"
35 #include "net/quic/core/quic_packet_generator.h" 35 #include "net/quic/core/quic_packet_generator.h"
36 #include "net/quic/core/quic_pending_retransmission.h" 36 #include "net/quic/core/quic_pending_retransmission.h"
37 #include "net/quic/core/quic_sent_packet_manager.h" 37 #include "net/quic/core/quic_sent_packet_manager.h"
38 #include "net/quic/core/quic_utils.h" 38 #include "net/quic/core/quic_utils.h"
39 #include "net/quic/platform/api/quic_str_cat.h"
39 40
40 using base::StringPiece; 41 using base::StringPiece;
41 using base::StringPrintf; 42 using base::StringPrintf;
42 using std::string; 43 using std::string;
43 44
44 namespace net { 45 namespace net {
45 46
46 class QuicDecrypter; 47 class QuicDecrypter;
47 class QuicEncrypter; 48 class QuicEncrypter;
48 49
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 DLOG(WARNING) << error_details; 531 DLOG(WARNING) << error_details;
531 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET, 532 TearDownLocalConnectionState(QUIC_INVALID_VERSION_NEGOTIATION_PACKET,
532 error_details, 533 error_details,
533 ConnectionCloseSource::FROM_SELF); 534 ConnectionCloseSource::FROM_SELF);
534 return; 535 return;
535 } 536 }
536 537
537 if (!SelectMutualVersion(packet.versions)) { 538 if (!SelectMutualVersion(packet.versions)) {
538 CloseConnection( 539 CloseConnection(
539 QUIC_INVALID_VERSION, 540 QUIC_INVALID_VERSION,
540 "No common version found. Supported versions: {" + 541 QuicStrCat("No common version found. Supported versions: {",
541 QuicVersionVectorToString(framer_.supported_versions()) + 542 QuicVersionVectorToString(framer_.supported_versions()),
542 "}, peer supported versions: {" + 543 "}, peer supported versions: {",
543 QuicVersionVectorToString(packet.versions) + "}", 544 QuicVersionVectorToString(packet.versions), "}"),
544 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 545 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
545 return; 546 return;
546 } 547 }
547 548
548 DVLOG(1) << ENDPOINT 549 DVLOG(1) << ENDPOINT
549 << "Negotiated version: " << QuicVersionToString(version()); 550 << "Negotiated version: " << QuicVersionToString(version());
550 server_supported_versions_ = packet.versions; 551 server_supported_versions_ = packet.versions;
551 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS; 552 version_negotiation_state_ = NEGOTIATION_IN_PROGRESS;
552 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION); 553 RetransmitUnackedPackets(ALL_UNACKED_RETRANSMISSION);
553 } 554 }
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 1368 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
1368 return false; 1369 return false;
1369 } 1370 }
1370 1371
1371 if (version_negotiation_state_ != NEGOTIATED_VERSION) { 1372 if (version_negotiation_state_ != NEGOTIATED_VERSION) {
1372 if (perspective_ == Perspective::IS_SERVER) { 1373 if (perspective_ == Perspective::IS_SERVER) {
1373 if (!header.public_header.version_flag) { 1374 if (!header.public_header.version_flag) {
1374 // Packets should have the version flag till version negotiation is 1375 // Packets should have the version flag till version negotiation is
1375 // done. 1376 // done.
1376 string error_details = 1377 string error_details =
1377 StringPrintf("%s Packet %" PRIu64 1378 QuicStrCat(ENDPOINT, "Packet ", header.packet_number,
1378 " without version flag before version negotiated.", 1379 " without version flag before version negotiated.");
1379 ENDPOINT, header.packet_number);
1380 DLOG(WARNING) << error_details; 1380 DLOG(WARNING) << error_details;
1381 CloseConnection(QUIC_INVALID_VERSION, error_details, 1381 CloseConnection(QUIC_INVALID_VERSION, error_details,
1382 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET); 1382 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET);
1383 return false; 1383 return false;
1384 } else { 1384 } else {
1385 DCHECK_EQ(1u, header.public_header.versions.size()); 1385 DCHECK_EQ(1u, header.public_header.versions.size());
1386 DCHECK_EQ(header.public_header.versions[0], version()); 1386 DCHECK_EQ(header.public_header.versions[0], version());
1387 version_negotiation_state_ = NEGOTIATED_VERSION; 1387 version_negotiation_state_ = NEGOTIATED_VERSION;
1388 visitor_->OnSuccessfulVersionNegotiation(version()); 1388 visitor_->OnSuccessfulVersionNegotiation(version());
1389 if (debug_visitor_ != nullptr) { 1389 if (debug_visitor_ != nullptr) {
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1688 return false; 1688 return false;
1689 } 1689 }
1690 1690
1691 void QuicConnection::OnWriteError(int error_code) { 1691 void QuicConnection::OnWriteError(int error_code) {
1692 if (write_error_occured_) { 1692 if (write_error_occured_) {
1693 // A write error already occurred. The connection is being closed. 1693 // A write error already occurred. The connection is being closed.
1694 return; 1694 return;
1695 } 1695 }
1696 write_error_occured_ = true; 1696 write_error_occured_ = true;
1697 1697
1698 const string error_details = "Write failed with error: " + 1698 const string error_details = QuicStrCat(
1699 base::IntToString(error_code) + " (" + 1699 "Write failed with error: ", error_code, " (", strerror(error_code), ")");
1700 ErrorToString(error_code) + ")";
1701 DVLOG(1) << ENDPOINT << error_details; 1700 DVLOG(1) << ENDPOINT << error_details;
1702 // We can't send an error as the socket is presumably borked. 1701 // We can't send an error as the socket is presumably borked.
1703 switch (error_code) { 1702 switch (error_code) {
1704 case kMessageTooBigErrorCode: 1703 case kMessageTooBigErrorCode:
1705 CloseConnection( 1704 CloseConnection(
1706 QUIC_PACKET_WRITE_ERROR, error_details, 1705 QUIC_PACKET_WRITE_ERROR, error_details,
1707 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK); 1706 ConnectionCloseBehavior::SEND_CONNECTION_CLOSE_PACKET_WITH_NO_ACK);
1708 break; 1707 break;
1709 default: 1708 default:
1710 // We can't send an error as the socket is presumably borked. 1709 // We can't send an error as the socket is presumably borked.
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
2459 2458
2460 void QuicConnection::CheckIfApplicationLimited() { 2459 void QuicConnection::CheckIfApplicationLimited() {
2461 if (queued_packets_.empty() && 2460 if (queued_packets_.empty() &&
2462 !sent_packet_manager_->HasPendingRetransmissions() && 2461 !sent_packet_manager_->HasPendingRetransmissions() &&
2463 !visitor_->WillingAndAbleToWrite()) { 2462 !visitor_->WillingAndAbleToWrite()) {
2464 sent_packet_manager_->OnApplicationLimited(); 2463 sent_packet_manager_->OnApplicationLimited();
2465 } 2464 }
2466 } 2465 }
2467 2466
2468 } // namespace net 2467 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_bandwidth_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