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

Unified Diff: net/quic/quic_connection.cc

Issue 329933003: Refactor the Connection and Generator so the Creator is completely (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_connection.cc
diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc
index 7be5fc781cbe521c1d5e81265eff4dce01f63dd9..019bb8162c94f6dac069dc0d35c880bee88ecf48 100644
--- a/net/quic/quic_connection.cc
+++ b/net/quic/quic_connection.cc
@@ -219,8 +219,7 @@ QuicConnection::QuicConnection(QuicConnectionId connection_id,
timeout_alarm_(helper->CreateAlarm(new TimeoutAlarm(this))),
ping_alarm_(helper->CreateAlarm(new PingAlarm(this))),
debug_visitor_(NULL),
- packet_creator_(connection_id_, &framer_, random_generator_, is_server),
- packet_generator_(this, NULL, &packet_creator_),
+ packet_generator_(connection_id_, &framer_, random_generator_, this),
idle_network_timeout_(
QuicTime::Delta::FromSeconds(kDefaultInitialTimeoutSecs)),
overall_connection_timeout_(QuicTime::Delta::Infinite()),
@@ -478,7 +477,7 @@ bool QuicConnection::OnPacketHeader(const QuicPacketHeader& header) {
DCHECK(!header.public_header.version_flag);
// If the client gets a packet without the version flag from the server
// it should stop sending version since the version negotiation is done.
- packet_creator_.StopSendingVersion();
+ packet_generator_.StopSendingVersion();
version_negotiation_state_ = NEGOTIATED_VERSION;
visitor_->OnSuccessfulVersionNegotiation(version());
}
@@ -616,10 +615,10 @@ bool QuicConnection::OnPingFrame(const QuicPingFrame& frame) {
bool QuicConnection::ValidateAckFrame(const QuicAckFrame& incoming_ack) {
if (incoming_ack.received_info.largest_observed >
- packet_creator_.sequence_number()) {
+ packet_generator_.sequence_number()) {
DLOG(ERROR) << ENDPOINT << "Peer's observed unsent packet:"
<< incoming_ack.received_info.largest_observed << " vs "
- << packet_creator_.sequence_number();
+ << packet_generator_.sequence_number();
// We got an error for data we have not sent. Error out.
return false;
}
@@ -938,7 +937,7 @@ void QuicConnection::UpdateStopWaitingCount() {
QuicPacketSequenceNumber QuicConnection::GetLeastUnacked() const {
return sent_packet_manager_.HasUnackedPackets() ?
sent_packet_manager_.GetLeastUnackedSentPacket() :
- packet_creator_.sequence_number() + 1;
+ packet_generator_.sequence_number() + 1;
}
void QuicConnection::MaybeSendInResponseToPacket() {
@@ -962,7 +961,7 @@ void QuicConnection::SendVersionNegotiationPacket() {
return;
}
scoped_ptr<QuicEncryptedPacket> version_packet(
- packet_creator_.SerializeVersionNegotiationPacket(
+ packet_generator_.SerializeVersionNegotiationPacket(
framer_.supported_versions()));
WriteResult result = writer_->WritePacket(
version_packet->data(), version_packet->length(),
@@ -1061,7 +1060,7 @@ const QuicConnectionStats& QuicConnection::GetStats() {
stats_.estimated_bandwidth =
sent_packet_manager_.BandwidthEstimate().ToBytesPerSecond();
stats_.congestion_window = sent_packet_manager_.GetCongestionWindow();
- stats_.max_packet_size = packet_creator_.max_packet_length();
+ stats_.max_packet_size = packet_generator_.max_packet_length();
return stats_;
}
@@ -1191,8 +1190,8 @@ bool QuicConnection::ProcessValidatedPacket() {
<< time_of_last_received_packet_.ToDebuggingValue();
if (is_server_ && encryption_level_ == ENCRYPTION_NONE &&
- last_size_ > packet_creator_.max_packet_length()) {
- packet_creator_.set_max_packet_length(last_size_);
+ last_size_ > packet_generator_.max_packet_length()) {
+ packet_generator_.set_max_packet_length(last_size_);
}
return true;
}
@@ -1237,7 +1236,7 @@ void QuicConnection::WritePendingRetransmissions() {
// TODO(ianswett): Implement ReserializeAllFrames as a separate path that
// does not require the creator to be flushed.
Flush();
- SerializedPacket serialized_packet = packet_creator_.ReserializeAllFrames(
+ SerializedPacket serialized_packet = packet_generator_.ReserializeAllFrames(
pending.retransmittable_frames.frames(),
pending.sequence_number_length);
@@ -1361,9 +1360,9 @@ bool QuicConnection::WritePacket(QueuedPacket packet) {
}
LOG_IF(DFATAL, encrypted->length() >
- packet_creator_.max_packet_length())
+ packet_generator_.max_packet_length())
<< "Writing an encrypted packet larger than max_packet_length:"
- << packet_creator_.max_packet_length() << " encrypted length: "
+ << packet_generator_.max_packet_length() << " encrypted length: "
<< encrypted->length();
DVLOG(1) << ENDPOINT << "Sending packet " << sequence_number
<< " : " << (packet.packet->is_fec_packet() ? "FEC " :
@@ -1491,7 +1490,7 @@ bool QuicConnection::OnPacketSent(WriteResult result) {
// TODO(ianswett): Change the sequence number length and other packet creator
// options by a more explicit API than setting a struct value directly.
- packet_creator_.UpdateSequenceNumberLength(
+ packet_generator_.UpdateSequenceNumberLength(
received_packet_manager_.least_packet_awaited_by_peer(),
sent_packet_manager_.GetCongestionWindow());
@@ -1635,7 +1634,7 @@ const QuicEncrypter* QuicConnection::encrypter(EncryptionLevel level) const {
void QuicConnection::SetDefaultEncryptionLevel(EncryptionLevel level) {
encryption_level_ = level;
- packet_creator_.set_encryption_level(level);
+ packet_generator_.set_encryption_level(level);
}
void QuicConnection::SetDecrypter(QuicDecrypter* decrypter,
@@ -1826,6 +1825,14 @@ void QuicConnection::CloseFecGroupsBefore(
}
}
+size_t QuicConnection::max_packet_length() const {
+ return packet_generator_.max_packet_length();
+}
+
+void QuicConnection::set_max_packet_length(size_t length) {
+ return packet_generator_.set_max_packet_length(length);
+}
+
void QuicConnection::Flush() {
packet_generator_.FlushAllQueuedFrames();
}
« no previous file with comments | « net/quic/quic_connection.h ('k') | net/quic/quic_connection_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698