| 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 | 9 | 
| 10 #include <algorithm> | 10 #include <algorithm> | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 79 bool IsInitializedIPEndPoint(const IPEndPoint& address) { | 79 bool IsInitializedIPEndPoint(const IPEndPoint& address) { | 
| 80   return net::GetAddressFamily(address.address()) != | 80   return net::GetAddressFamily(address.address()) != | 
| 81          net::ADDRESS_FAMILY_UNSPECIFIED; | 81          net::ADDRESS_FAMILY_UNSPECIFIED; | 
| 82 } | 82 } | 
| 83 | 83 | 
| 84 // An alarm that is scheduled to send an ack if a timeout occurs. | 84 // An alarm that is scheduled to send an ack if a timeout occurs. | 
| 85 class AckAlarm : public QuicAlarm::Delegate { | 85 class AckAlarm : public QuicAlarm::Delegate { | 
| 86  public: | 86  public: | 
| 87   explicit AckAlarm(QuicConnection* connection) : connection_(connection) {} | 87   explicit AckAlarm(QuicConnection* connection) : connection_(connection) {} | 
| 88 | 88 | 
| 89   QuicTime OnAlarm() override { | 89   void OnAlarm() override { | 
| 90     DCHECK(connection_->ack_frame_updated()); | 90     DCHECK(connection_->ack_frame_updated()); | 
| 91     connection_->SendAck(); | 91     connection_->SendAck(); | 
| 92     return QuicTime::Zero(); |  | 
| 93   } | 92   } | 
| 94 | 93 | 
| 95  private: | 94  private: | 
| 96   QuicConnection* connection_; | 95   QuicConnection* connection_; | 
| 97 | 96 | 
| 98   DISALLOW_COPY_AND_ASSIGN(AckAlarm); | 97   DISALLOW_COPY_AND_ASSIGN(AckAlarm); | 
| 99 }; | 98 }; | 
| 100 | 99 | 
| 101 // This alarm will be scheduled any time a data-bearing packet is sent out. | 100 // This alarm will be scheduled any time a data-bearing packet is sent out. | 
| 102 // When the alarm goes off, the connection checks to see if the oldest packets | 101 // When the alarm goes off, the connection checks to see if the oldest packets | 
| 103 // have been acked, and retransmit them if they have not. | 102 // have been acked, and retransmit them if they have not. | 
| 104 class RetransmissionAlarm : public QuicAlarm::Delegate { | 103 class RetransmissionAlarm : public QuicAlarm::Delegate { | 
| 105  public: | 104  public: | 
| 106   explicit RetransmissionAlarm(QuicConnection* connection) | 105   explicit RetransmissionAlarm(QuicConnection* connection) | 
| 107       : connection_(connection) {} | 106       : connection_(connection) {} | 
| 108 | 107 | 
| 109   QuicTime OnAlarm() override { | 108   void OnAlarm() override { connection_->OnRetransmissionTimeout(); } | 
| 110     connection_->OnRetransmissionTimeout(); |  | 
| 111     return QuicTime::Zero(); |  | 
| 112   } |  | 
| 113 | 109 | 
| 114  private: | 110  private: | 
| 115   QuicConnection* connection_; | 111   QuicConnection* connection_; | 
| 116 | 112 | 
| 117   DISALLOW_COPY_AND_ASSIGN(RetransmissionAlarm); | 113   DISALLOW_COPY_AND_ASSIGN(RetransmissionAlarm); | 
| 118 }; | 114 }; | 
| 119 | 115 | 
| 120 // An alarm that is scheduled when the SentPacketManager requires a delay | 116 // An alarm that is scheduled when the SentPacketManager requires a delay | 
| 121 // before sending packets and fires when the packet may be sent. | 117 // before sending packets and fires when the packet may be sent. | 
| 122 class SendAlarm : public QuicAlarm::Delegate { | 118 class SendAlarm : public QuicAlarm::Delegate { | 
| 123  public: | 119  public: | 
| 124   explicit SendAlarm(QuicConnection* connection) : connection_(connection) {} | 120   explicit SendAlarm(QuicConnection* connection) : connection_(connection) {} | 
| 125 | 121 | 
| 126   QuicTime OnAlarm() override { | 122   void OnAlarm() override { connection_->WriteAndBundleAcksIfNotBlocked(); } | 
| 127     connection_->WriteAndBundleAcksIfNotBlocked(); |  | 
| 128     // Never reschedule the alarm, since CanWrite does that. |  | 
| 129     return QuicTime::Zero(); |  | 
| 130   } |  | 
| 131 | 123 | 
| 132  private: | 124  private: | 
| 133   QuicConnection* connection_; | 125   QuicConnection* connection_; | 
| 134 | 126 | 
| 135   DISALLOW_COPY_AND_ASSIGN(SendAlarm); | 127   DISALLOW_COPY_AND_ASSIGN(SendAlarm); | 
| 136 }; | 128 }; | 
| 137 | 129 | 
| 138 class TimeoutAlarm : public QuicAlarm::Delegate { | 130 class TimeoutAlarm : public QuicAlarm::Delegate { | 
| 139  public: | 131  public: | 
| 140   explicit TimeoutAlarm(QuicConnection* connection) : connection_(connection) {} | 132   explicit TimeoutAlarm(QuicConnection* connection) : connection_(connection) {} | 
| 141 | 133 | 
| 142   QuicTime OnAlarm() override { | 134   void OnAlarm() override { connection_->CheckForTimeout(); } | 
| 143     connection_->CheckForTimeout(); |  | 
| 144     // Never reschedule the alarm, since CheckForTimeout does that. |  | 
| 145     return QuicTime::Zero(); |  | 
| 146   } |  | 
| 147 | 135 | 
| 148  private: | 136  private: | 
| 149   QuicConnection* connection_; | 137   QuicConnection* connection_; | 
| 150 | 138 | 
| 151   DISALLOW_COPY_AND_ASSIGN(TimeoutAlarm); | 139   DISALLOW_COPY_AND_ASSIGN(TimeoutAlarm); | 
| 152 }; | 140 }; | 
| 153 | 141 | 
| 154 class PingAlarm : public QuicAlarm::Delegate { | 142 class PingAlarm : public QuicAlarm::Delegate { | 
| 155  public: | 143  public: | 
| 156   explicit PingAlarm(QuicConnection* connection) : connection_(connection) {} | 144   explicit PingAlarm(QuicConnection* connection) : connection_(connection) {} | 
| 157 | 145 | 
| 158   QuicTime OnAlarm() override { | 146   void OnAlarm() override { connection_->OnPingTimeout(); } | 
| 159     connection_->OnPingTimeout(); |  | 
| 160     return QuicTime::Zero(); |  | 
| 161   } |  | 
| 162 | 147 | 
| 163  private: | 148  private: | 
| 164   QuicConnection* connection_; | 149   QuicConnection* connection_; | 
| 165 | 150 | 
| 166   DISALLOW_COPY_AND_ASSIGN(PingAlarm); | 151   DISALLOW_COPY_AND_ASSIGN(PingAlarm); | 
| 167 }; | 152 }; | 
| 168 | 153 | 
| 169 class MtuDiscoveryAlarm : public QuicAlarm::Delegate { | 154 class MtuDiscoveryAlarm : public QuicAlarm::Delegate { | 
| 170  public: | 155  public: | 
| 171   explicit MtuDiscoveryAlarm(QuicConnection* connection) | 156   explicit MtuDiscoveryAlarm(QuicConnection* connection) | 
| 172       : connection_(connection) {} | 157       : connection_(connection) {} | 
| 173 | 158 | 
| 174   QuicTime OnAlarm() override { | 159   void OnAlarm() override { connection_->DiscoverMtu(); } | 
| 175     connection_->DiscoverMtu(); |  | 
| 176     // DiscoverMtu() handles rescheduling the alarm by itself. |  | 
| 177     return QuicTime::Zero(); |  | 
| 178   } |  | 
| 179 | 160 | 
| 180  private: | 161  private: | 
| 181   QuicConnection* connection_; | 162   QuicConnection* connection_; | 
| 182 | 163 | 
| 183   DISALLOW_COPY_AND_ASSIGN(MtuDiscoveryAlarm); | 164   DISALLOW_COPY_AND_ASSIGN(MtuDiscoveryAlarm); | 
| 184 }; | 165 }; | 
| 185 | 166 | 
| 186 // Listens for acks of MTU discovery packets and raises the maximum packet size | 167 // Listens for acks of MTU discovery packets and raises the maximum packet size | 
| 187 // of the connection if the probe succeeds. | 168 // of the connection if the probe succeeds. | 
| 188 class MtuDiscoveryAckListener : public QuicAckListenerInterface { | 169 class MtuDiscoveryAckListener : public QuicAckListenerInterface { | 
| (...skipping 2158 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2347 } | 2328 } | 
| 2348 | 2329 | 
| 2349 StringPiece QuicConnection::GetCurrentPacket() { | 2330 StringPiece QuicConnection::GetCurrentPacket() { | 
| 2350   if (current_packet_data_ == nullptr) { | 2331   if (current_packet_data_ == nullptr) { | 
| 2351     return StringPiece(); | 2332     return StringPiece(); | 
| 2352   } | 2333   } | 
| 2353   return StringPiece(current_packet_data_, last_size_); | 2334   return StringPiece(current_packet_data_, last_size_); | 
| 2354 } | 2335 } | 
| 2355 | 2336 | 
| 2356 }  // namespace net | 2337 }  // namespace net | 
| OLD | NEW | 
|---|