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

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

Issue 604163002: Change the return type of QuicConnection::CheckForTimeout from bool to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Remove_calls_to_OnSerializedPacket_75716236
Patch Set: Created 6 years, 2 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/quic_connection.h ('k') | 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 1884 matching lines...) Expand 10 before | Expand all | Expand 10 after
1895 1895
1896 void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) { 1896 void QuicConnection::SetOverallConnectionTimeout(QuicTime::Delta timeout) {
1897 if (timeout < overall_connection_timeout_) { 1897 if (timeout < overall_connection_timeout_) {
1898 overall_connection_timeout_ = timeout; 1898 overall_connection_timeout_ = timeout;
1899 CheckForTimeout(); 1899 CheckForTimeout();
1900 } else { 1900 } else {
1901 overall_connection_timeout_ = timeout; 1901 overall_connection_timeout_ = timeout;
1902 } 1902 }
1903 } 1903 }
1904 1904
1905 bool QuicConnection::CheckForTimeout() { 1905 void QuicConnection::CheckForTimeout() {
1906 QuicTime now = clock_->ApproximateNow(); 1906 QuicTime now = clock_->ApproximateNow();
1907 QuicTime time_of_last_packet = max(time_of_last_received_packet_, 1907 QuicTime time_of_last_packet = max(time_of_last_received_packet_,
1908 time_of_last_sent_new_packet_); 1908 time_of_last_sent_new_packet_);
1909 1909
1910 // If no packets have been sent or received, then don't timeout. 1910 // If no packets have been sent or received, then don't timeout.
1911 if (FLAGS_quic_timeouts_require_activity && 1911 if (FLAGS_quic_timeouts_require_activity &&
1912 !time_of_last_packet.IsInitialized()) { 1912 !time_of_last_packet.IsInitialized()) {
1913 timeout_alarm_->Cancel(); 1913 timeout_alarm_->Cancel();
1914 timeout_alarm_->Set(now.Add(idle_network_timeout_)); 1914 timeout_alarm_->Set(now.Add(idle_network_timeout_));
1915 return false; 1915 return;
1916 } 1916 }
1917 1917
1918 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet| 1918 // |delta| can be < 0 as |now| is approximate time but |time_of_last_packet|
1919 // is accurate time. However, this should not change the behavior of 1919 // is accurate time. However, this should not change the behavior of
1920 // timeout handling. 1920 // timeout handling.
1921 QuicTime::Delta delta = now.Subtract(time_of_last_packet); 1921 QuicTime::Delta delta = now.Subtract(time_of_last_packet);
1922 DVLOG(1) << ENDPOINT << "last packet " 1922 DVLOG(1) << ENDPOINT << "last packet "
1923 << time_of_last_packet.ToDebuggingValue() 1923 << time_of_last_packet.ToDebuggingValue()
1924 << " now:" << now.ToDebuggingValue() 1924 << " now:" << now.ToDebuggingValue()
1925 << " delta:" << delta.ToMicroseconds() 1925 << " delta:" << delta.ToMicroseconds()
1926 << " network_timeout: " << idle_network_timeout_.ToMicroseconds(); 1926 << " network_timeout: " << idle_network_timeout_.ToMicroseconds();
1927 if (delta >= idle_network_timeout_) { 1927 if (delta >= idle_network_timeout_) {
1928 DVLOG(1) << ENDPOINT << "Connection timedout due to no network activity."; 1928 DVLOG(1) << ENDPOINT << "Connection timedout due to no network activity.";
1929 SendConnectionClose(QUIC_CONNECTION_TIMED_OUT); 1929 SendConnectionClose(QUIC_CONNECTION_TIMED_OUT);
1930 return true; 1930 return;
1931 } 1931 }
1932 1932
1933 // Next timeout delta. 1933 // Next timeout delta.
1934 QuicTime::Delta timeout = idle_network_timeout_.Subtract(delta); 1934 QuicTime::Delta timeout = idle_network_timeout_.Subtract(delta);
1935 1935
1936 if (!overall_connection_timeout_.IsInfinite()) { 1936 if (!overall_connection_timeout_.IsInfinite()) {
1937 QuicTime::Delta connected_time = 1937 QuicTime::Delta connected_time =
1938 now.Subtract(stats_.connection_creation_time); 1938 now.Subtract(stats_.connection_creation_time);
1939 DVLOG(1) << ENDPOINT << "connection time: " 1939 DVLOG(1) << ENDPOINT << "connection time: "
1940 << connected_time.ToMilliseconds() << " overall timeout: " 1940 << connected_time.ToMilliseconds() << " overall timeout: "
1941 << overall_connection_timeout_.ToMilliseconds(); 1941 << overall_connection_timeout_.ToMilliseconds();
1942 if (connected_time >= overall_connection_timeout_) { 1942 if (connected_time >= overall_connection_timeout_) {
1943 DVLOG(1) << ENDPOINT << 1943 DVLOG(1) << ENDPOINT <<
1944 "Connection timedout due to overall connection timeout."; 1944 "Connection timedout due to overall connection timeout.";
1945 SendConnectionClose(QUIC_CONNECTION_OVERALL_TIMED_OUT); 1945 SendConnectionClose(QUIC_CONNECTION_OVERALL_TIMED_OUT);
1946 return true; 1946 return;
1947 } 1947 }
1948 1948
1949 // Take the min timeout. 1949 // Take the min timeout.
1950 QuicTime::Delta connection_timeout = 1950 QuicTime::Delta connection_timeout =
1951 overall_connection_timeout_.Subtract(connected_time); 1951 overall_connection_timeout_.Subtract(connected_time);
1952 if (connection_timeout < timeout) { 1952 if (connection_timeout < timeout) {
1953 timeout = connection_timeout; 1953 timeout = connection_timeout;
1954 } 1954 }
1955 } 1955 }
1956 1956
1957 timeout_alarm_->Cancel(); 1957 timeout_alarm_->Cancel();
1958 timeout_alarm_->Set(now.Add(timeout)); 1958 timeout_alarm_->Set(now.Add(timeout));
1959 return false;
1960 } 1959 }
1961 1960
1962 void QuicConnection::SetPingAlarm() { 1961 void QuicConnection::SetPingAlarm() {
1963 if (is_server_) { 1962 if (is_server_) {
1964 // Only clients send pings. 1963 // Only clients send pings.
1965 return; 1964 return;
1966 } 1965 }
1967 if (!visitor_->HasOpenDataStreams()) { 1966 if (!visitor_->HasOpenDataStreams()) {
1968 ping_alarm_->Cancel(); 1967 ping_alarm_->Cancel();
1969 // Don't send a ping unless there are open streams. 1968 // Don't send a ping unless there are open streams.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2033 } 2032 }
2034 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { 2033 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) {
2035 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { 2034 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) {
2036 return true; 2035 return true;
2037 } 2036 }
2038 } 2037 }
2039 return false; 2038 return false;
2040 } 2039 }
2041 2040
2042 } // namespace net 2041 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698