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

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

Issue 301563006: Add a packet bundler in the internal server so that headers and body go (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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <iterator> 10 #include <iterator>
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 return; 1937 return;
1938 } 1938 }
1939 QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs); 1939 QuicTime::Delta ping_timeout = QuicTime::Delta::FromSeconds(kPingTimeoutSecs);
1940 ping_alarm_->Set(clock_->ApproximateNow().Add(ping_timeout)); 1940 ping_alarm_->Set(clock_->ApproximateNow().Add(ping_timeout));
1941 } 1941 }
1942 1942
1943 QuicConnection::ScopedPacketBundler::ScopedPacketBundler( 1943 QuicConnection::ScopedPacketBundler::ScopedPacketBundler(
1944 QuicConnection* connection, 1944 QuicConnection* connection,
1945 AckBundling send_ack) 1945 AckBundling send_ack)
1946 : connection_(connection), 1946 : connection_(connection),
1947 already_in_batch_mode_(connection->packet_generator_.InBatchMode()) { 1947 already_in_batch_mode_(connection != NULL &&
1948 connection->packet_generator_.InBatchMode()) {
1949 if (connection_ == NULL) {
1950 return;
1951 }
1948 // Move generator into batch mode. If caller wants us to include an ack, 1952 // Move generator into batch mode. If caller wants us to include an ack,
1949 // check the delayed-ack timer to see if there's ack info to be sent. 1953 // check the delayed-ack timer to see if there's ack info to be sent.
1950 if (!already_in_batch_mode_) { 1954 if (!already_in_batch_mode_) {
1951 DVLOG(1) << "Entering Batch Mode."; 1955 DVLOG(1) << "Entering Batch Mode.";
1952 connection_->packet_generator_.StartBatchOperations(); 1956 connection_->packet_generator_.StartBatchOperations();
1953 } 1957 }
1954 // Bundle an ack if the alarm is set or with every second packet if we need to 1958 // Bundle an ack if the alarm is set or with every second packet if we need to
1955 // raise the peer's least unacked. 1959 // raise the peer's least unacked.
1956 bool ack_pending = 1960 bool ack_pending =
1957 connection_->ack_alarm_->IsSet() || connection_->stop_waiting_count_ > 1; 1961 connection_->ack_alarm_->IsSet() || connection_->stop_waiting_count_ > 1;
1958 if (send_ack == SEND_ACK || (send_ack == BUNDLE_PENDING_ACK && ack_pending)) { 1962 if (send_ack == SEND_ACK || (send_ack == BUNDLE_PENDING_ACK && ack_pending)) {
1959 DVLOG(1) << "Bundling ack with outgoing packet."; 1963 DVLOG(1) << "Bundling ack with outgoing packet.";
1960 connection_->SendAck(); 1964 connection_->SendAck();
1961 } 1965 }
1962 } 1966 }
1963 1967
1964 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() { 1968 QuicConnection::ScopedPacketBundler::~ScopedPacketBundler() {
1969 if (connection_ == NULL) {
1970 return;
1971 }
1965 // If we changed the generator's batch state, restore original batch state. 1972 // If we changed the generator's batch state, restore original batch state.
1966 if (!already_in_batch_mode_) { 1973 if (!already_in_batch_mode_) {
1967 DVLOG(1) << "Leaving Batch Mode."; 1974 DVLOG(1) << "Leaving Batch Mode.";
1968 connection_->packet_generator_.FinishBatchOperations(); 1975 connection_->packet_generator_.FinishBatchOperations();
1969 } 1976 }
1970 DCHECK_EQ(already_in_batch_mode_, 1977 DCHECK_EQ(already_in_batch_mode_,
1971 connection_->packet_generator_.InBatchMode()); 1978 connection_->packet_generator_.InBatchMode());
1972 } 1979 }
1973 1980
1974 } // namespace net 1981 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698