| 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_framer.h" | 5 #include "net/quic/quic_framer.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_handshake_message.h" | 10 #include "net/quic/crypto/crypto_handshake_message.h" |
| (...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 return false; | 1479 return false; |
| 1480 } | 1480 } |
| 1481 QuicPacketSequenceNumber packet = smallest_received + sequence_delta; | 1481 QuicPacketSequenceNumber packet = smallest_received + sequence_delta; |
| 1482 inter_arrival->received_packet_times.insert( | 1482 inter_arrival->received_packet_times.insert( |
| 1483 make_pair(packet, time_received.Add( | 1483 make_pair(packet, time_received.Add( |
| 1484 QuicTime::Delta::FromMicroseconds(time_delta_us)))); | 1484 QuicTime::Delta::FromMicroseconds(time_delta_us)))); |
| 1485 } | 1485 } |
| 1486 } | 1486 } |
| 1487 break; | 1487 break; |
| 1488 } | 1488 } |
| 1489 case kFixRate: { | |
| 1490 uint32 bitrate = 0; | |
| 1491 if (!reader_->ReadUInt32(&bitrate)) { | |
| 1492 set_detailed_error("Unable to read bitrate."); | |
| 1493 return false; | |
| 1494 } | |
| 1495 frame->fix_rate.bitrate = QuicBandwidth::FromBytesPerSecond(bitrate); | |
| 1496 break; | |
| 1497 } | |
| 1498 case kTCP: { | 1489 case kTCP: { |
| 1499 CongestionFeedbackMessageTCP* tcp = &frame->tcp; | 1490 CongestionFeedbackMessageTCP* tcp = &frame->tcp; |
| 1500 // TODO(ianswett): Remove receive window, since it's constant. | 1491 // TODO(ianswett): Remove receive window, since it's constant. |
| 1501 uint16 receive_window = 0; | 1492 uint16 receive_window = 0; |
| 1502 if (!reader_->ReadUInt16(&receive_window)) { | 1493 if (!reader_->ReadUInt16(&receive_window)) { |
| 1503 set_detailed_error("Unable to read receive window."); | 1494 set_detailed_error("Unable to read receive window."); |
| 1504 return false; | 1495 return false; |
| 1505 } | 1496 } |
| 1506 // Simple bit packing, don't send the 4 least significant bits. | 1497 // Simple bit packing, don't send the 4 least significant bits. |
| 1507 tcp->receive_window = static_cast<QuicByteCount>(receive_window) << 4; | 1498 tcp->receive_window = static_cast<QuicByteCount>(receive_window) << 4; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1824 len += 1; // Number received packets. | 1815 len += 1; // Number received packets. |
| 1825 if (inter_arrival.received_packet_times.size() > 0) { | 1816 if (inter_arrival.received_packet_times.size() > 0) { |
| 1826 len += PACKET_6BYTE_SEQUENCE_NUMBER; // Smallest received. | 1817 len += PACKET_6BYTE_SEQUENCE_NUMBER; // Smallest received. |
| 1827 len += 8; // Time. | 1818 len += 8; // Time. |
| 1828 // 2 bytes per sequence number delta plus 4 bytes per delta time. | 1819 // 2 bytes per sequence number delta plus 4 bytes per delta time. |
| 1829 len += PACKET_6BYTE_SEQUENCE_NUMBER * | 1820 len += PACKET_6BYTE_SEQUENCE_NUMBER * |
| 1830 (inter_arrival.received_packet_times.size() - 1); | 1821 (inter_arrival.received_packet_times.size() - 1); |
| 1831 } | 1822 } |
| 1832 break; | 1823 break; |
| 1833 } | 1824 } |
| 1834 case kFixRate: | |
| 1835 len += 4; // Bitrate. | |
| 1836 break; | |
| 1837 case kTCP: | 1825 case kTCP: |
| 1838 len += 2; // Receive window. | 1826 len += 2; // Receive window. |
| 1839 break; | 1827 break; |
| 1840 default: | 1828 default: |
| 1841 set_detailed_error("Illegal feedback type."); | 1829 set_detailed_error("Illegal feedback type."); |
| 1842 DVLOG(1) << "Illegal feedback type: " << congestion_feedback.type; | 1830 DVLOG(1) << "Illegal feedback type: " << congestion_feedback.type; |
| 1843 break; | 1831 break; |
| 1844 } | 1832 } |
| 1845 return len; | 1833 return len; |
| 1846 } | 1834 } |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 | 2163 |
| 2176 int32 time_delta_us = | 2164 int32 time_delta_us = |
| 2177 it->second.Subtract(lowest_time).ToMicroseconds(); | 2165 it->second.Subtract(lowest_time).ToMicroseconds(); |
| 2178 if (!writer->WriteBytes(&time_delta_us, sizeof(time_delta_us))) { | 2166 if (!writer->WriteBytes(&time_delta_us, sizeof(time_delta_us))) { |
| 2179 return false; | 2167 return false; |
| 2180 } | 2168 } |
| 2181 } | 2169 } |
| 2182 } | 2170 } |
| 2183 break; | 2171 break; |
| 2184 } | 2172 } |
| 2185 case kFixRate: { | |
| 2186 const CongestionFeedbackMessageFixRate& fix_rate = | |
| 2187 frame.fix_rate; | |
| 2188 if (!writer->WriteUInt32(fix_rate.bitrate.ToBytesPerSecond())) { | |
| 2189 return false; | |
| 2190 } | |
| 2191 break; | |
| 2192 } | |
| 2193 case kTCP: { | 2173 case kTCP: { |
| 2194 const CongestionFeedbackMessageTCP& tcp = frame.tcp; | 2174 const CongestionFeedbackMessageTCP& tcp = frame.tcp; |
| 2195 DCHECK_LE(tcp.receive_window, 1u << 20); | 2175 DCHECK_LE(tcp.receive_window, 1u << 20); |
| 2196 // Simple bit packing, don't send the 4 least significant bits. | 2176 // Simple bit packing, don't send the 4 least significant bits. |
| 2197 uint16 receive_window = static_cast<uint16>(tcp.receive_window >> 4); | 2177 uint16 receive_window = static_cast<uint16>(tcp.receive_window >> 4); |
| 2198 if (!writer->WriteUInt16(receive_window)) { | 2178 if (!writer->WriteUInt16(receive_window)) { |
| 2199 return false; | 2179 return false; |
| 2200 } | 2180 } |
| 2201 break; | 2181 break; |
| 2202 } | 2182 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2312 | 2292 |
| 2313 bool QuicFramer::RaiseError(QuicErrorCode error) { | 2293 bool QuicFramer::RaiseError(QuicErrorCode error) { |
| 2314 DVLOG(1) << "Error detail: " << detailed_error_; | 2294 DVLOG(1) << "Error detail: " << detailed_error_; |
| 2315 set_error(error); | 2295 set_error(error); |
| 2316 visitor_->OnError(this); | 2296 visitor_->OnError(this); |
| 2317 reader_.reset(NULL); | 2297 reader_.reset(NULL); |
| 2318 return false; | 2298 return false; |
| 2319 } | 2299 } |
| 2320 | 2300 |
| 2321 } // namespace net | 2301 } // namespace net |
| OLD | NEW |