| OLD | NEW |
| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 return delta <= kMaxPacketGap; | 65 return delta <= kMaxPacketGap; |
| 66 } | 66 } |
| 67 | 67 |
| 68 // An alarm that is scheduled to send an ack if a timeout occurs. | 68 // An alarm that is scheduled to send an ack if a timeout occurs. |
| 69 class AckAlarm : public QuicAlarm::Delegate { | 69 class AckAlarm : public QuicAlarm::Delegate { |
| 70 public: | 70 public: |
| 71 explicit AckAlarm(QuicConnection* connection) | 71 explicit AckAlarm(QuicConnection* connection) |
| 72 : connection_(connection) { | 72 : connection_(connection) { |
| 73 } | 73 } |
| 74 | 74 |
| 75 virtual QuicTime OnAlarm() OVERRIDE { | 75 virtual QuicTime OnAlarm() override { |
| 76 connection_->SendAck(); | 76 connection_->SendAck(); |
| 77 return QuicTime::Zero(); | 77 return QuicTime::Zero(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 QuicConnection* connection_; | 81 QuicConnection* connection_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(AckAlarm); | 83 DISALLOW_COPY_AND_ASSIGN(AckAlarm); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 // This alarm will be scheduled any time a data-bearing packet is sent out. | 86 // This alarm will be scheduled any time a data-bearing packet is sent out. |
| 87 // When the alarm goes off, the connection checks to see if the oldest packets | 87 // When the alarm goes off, the connection checks to see if the oldest packets |
| 88 // have been acked, and retransmit them if they have not. | 88 // have been acked, and retransmit them if they have not. |
| 89 class RetransmissionAlarm : public QuicAlarm::Delegate { | 89 class RetransmissionAlarm : public QuicAlarm::Delegate { |
| 90 public: | 90 public: |
| 91 explicit RetransmissionAlarm(QuicConnection* connection) | 91 explicit RetransmissionAlarm(QuicConnection* connection) |
| 92 : connection_(connection) { | 92 : connection_(connection) { |
| 93 } | 93 } |
| 94 | 94 |
| 95 virtual QuicTime OnAlarm() OVERRIDE { | 95 virtual QuicTime OnAlarm() override { |
| 96 connection_->OnRetransmissionTimeout(); | 96 connection_->OnRetransmissionTimeout(); |
| 97 return QuicTime::Zero(); | 97 return QuicTime::Zero(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 QuicConnection* connection_; | 101 QuicConnection* connection_; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(RetransmissionAlarm); | 103 DISALLOW_COPY_AND_ASSIGN(RetransmissionAlarm); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 // An alarm that is scheduled when the sent scheduler requires a | 106 // An alarm that is scheduled when the sent scheduler requires a |
| 107 // a delay before sending packets and fires when the packet may be sent. | 107 // a delay before sending packets and fires when the packet may be sent. |
| 108 class SendAlarm : public QuicAlarm::Delegate { | 108 class SendAlarm : public QuicAlarm::Delegate { |
| 109 public: | 109 public: |
| 110 explicit SendAlarm(QuicConnection* connection) | 110 explicit SendAlarm(QuicConnection* connection) |
| 111 : connection_(connection) { | 111 : connection_(connection) { |
| 112 } | 112 } |
| 113 | 113 |
| 114 virtual QuicTime OnAlarm() OVERRIDE { | 114 virtual QuicTime OnAlarm() override { |
| 115 connection_->WriteIfNotBlocked(); | 115 connection_->WriteIfNotBlocked(); |
| 116 // Never reschedule the alarm, since CanWrite does that. | 116 // Never reschedule the alarm, since CanWrite does that. |
| 117 return QuicTime::Zero(); | 117 return QuicTime::Zero(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 QuicConnection* connection_; | 121 QuicConnection* connection_; |
| 122 | 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(SendAlarm); | 123 DISALLOW_COPY_AND_ASSIGN(SendAlarm); |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 class TimeoutAlarm : public QuicAlarm::Delegate { | 126 class TimeoutAlarm : public QuicAlarm::Delegate { |
| 127 public: | 127 public: |
| 128 explicit TimeoutAlarm(QuicConnection* connection) | 128 explicit TimeoutAlarm(QuicConnection* connection) |
| 129 : connection_(connection) { | 129 : connection_(connection) { |
| 130 } | 130 } |
| 131 | 131 |
| 132 virtual QuicTime OnAlarm() OVERRIDE { | 132 virtual QuicTime OnAlarm() override { |
| 133 connection_->CheckForTimeout(); | 133 connection_->CheckForTimeout(); |
| 134 // Never reschedule the alarm, since CheckForTimeout does that. | 134 // Never reschedule the alarm, since CheckForTimeout does that. |
| 135 return QuicTime::Zero(); | 135 return QuicTime::Zero(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 QuicConnection* connection_; | 139 QuicConnection* connection_; |
| 140 | 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(TimeoutAlarm); | 141 DISALLOW_COPY_AND_ASSIGN(TimeoutAlarm); |
| 142 }; | 142 }; |
| 143 | 143 |
| 144 class PingAlarm : public QuicAlarm::Delegate { | 144 class PingAlarm : public QuicAlarm::Delegate { |
| 145 public: | 145 public: |
| 146 explicit PingAlarm(QuicConnection* connection) | 146 explicit PingAlarm(QuicConnection* connection) |
| 147 : connection_(connection) { | 147 : connection_(connection) { |
| 148 } | 148 } |
| 149 | 149 |
| 150 virtual QuicTime OnAlarm() OVERRIDE { | 150 virtual QuicTime OnAlarm() override { |
| 151 connection_->SendPing(); | 151 connection_->SendPing(); |
| 152 return QuicTime::Zero(); | 152 return QuicTime::Zero(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 private: | 155 private: |
| 156 QuicConnection* connection_; | 156 QuicConnection* connection_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(PingAlarm); | 158 DISALLOW_COPY_AND_ASSIGN(PingAlarm); |
| 159 }; | 159 }; |
| 160 | 160 |
| (...skipping 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2032 } | 2032 } |
| 2033 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { | 2033 for (size_t i = 0; i < retransmittable_frames->frames().size(); ++i) { |
| 2034 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { | 2034 if (retransmittable_frames->frames()[i].type == CONNECTION_CLOSE_FRAME) { |
| 2035 return true; | 2035 return true; |
| 2036 } | 2036 } |
| 2037 } | 2037 } |
| 2038 return false; | 2038 return false; |
| 2039 } | 2039 } |
| 2040 | 2040 |
| 2041 } // namespace net | 2041 } // namespace net |
| OLD | NEW |