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/hash_tables.h" | 7 #include "base/hash_tables.h" |
8 #include "net/quic/crypto/quic_decrypter.h" | 8 #include "net/quic/crypto/quic_decrypter.h" |
9 #include "net/quic/crypto/quic_encrypter.h" | 9 #include "net/quic/crypto/quic_encrypter.h" |
10 #include "net/quic/quic_data_reader.h" | 10 #include "net/quic/quic_data_reader.h" |
11 #include "net/quic/quic_data_writer.h" | 11 #include "net/quic/quic_data_writer.h" |
12 #include "net/quic/quic_utils.h" | 12 #include "net/quic/quic_utils.h" |
13 | 13 |
14 using base::StringPiece; | 14 using base::StringPiece; |
| 15 using std::make_pair; |
15 using std::map; | 16 using std::map; |
16 using std::numeric_limits; | 17 using std::numeric_limits; |
17 | 18 |
18 namespace net { | 19 namespace net { |
19 | 20 |
20 bool kQuicAllowOversizedPacketsForTest = false; | 21 bool kQuicAllowOversizedPacketsForTest = false; |
21 | 22 |
22 QuicFramer::QuicFramer(QuicDecrypter* decrypter, QuicEncrypter* encrypter) | 23 QuicFramer::QuicFramer(QuicDecrypter* decrypter, QuicEncrypter* encrypter) |
23 : visitor_(NULL), | 24 : visitor_(NULL), |
24 fec_builder_(NULL), | 25 fec_builder_(NULL), |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 set_detailed_error("Unable to read smallest received."); | 493 set_detailed_error("Unable to read smallest received."); |
493 return false; | 494 return false; |
494 } | 495 } |
495 | 496 |
496 uint64 time_received_us; | 497 uint64 time_received_us; |
497 if (!reader_->ReadUInt64(&time_received_us)) { | 498 if (!reader_->ReadUInt64(&time_received_us)) { |
498 set_detailed_error("Unable to read time received."); | 499 set_detailed_error("Unable to read time received."); |
499 return false; | 500 return false; |
500 } | 501 } |
501 | 502 |
502 inter_arrival->received_packet_times[smallest_received] = | 503 inter_arrival->received_packet_times.insert( |
503 QuicTime::FromMicroseconds(time_received_us); | 504 make_pair(smallest_received, |
| 505 QuicTime::FromMicroseconds(time_received_us))); |
504 | 506 |
505 for (int i = 0; i < num_received_packets - 1; ++i) { | 507 for (int i = 0; i < num_received_packets - 1; ++i) { |
506 uint16 sequence_delta; | 508 uint16 sequence_delta; |
507 if (!reader_->ReadUInt16(&sequence_delta)) { | 509 if (!reader_->ReadUInt16(&sequence_delta)) { |
508 set_detailed_error( | 510 set_detailed_error( |
509 "Unable to read sequence delta in received packets."); | 511 "Unable to read sequence delta in received packets."); |
510 return false; | 512 return false; |
511 } | 513 } |
512 | 514 |
513 int32 time_delta_us; | 515 int32 time_delta_us; |
514 if (!reader_->ReadBytes(&time_delta_us, sizeof(time_delta_us))) { | 516 if (!reader_->ReadBytes(&time_delta_us, sizeof(time_delta_us))) { |
515 set_detailed_error( | 517 set_detailed_error( |
516 "Unable to read time delta in received packets."); | 518 "Unable to read time delta in received packets."); |
517 return false; | 519 return false; |
518 } | 520 } |
519 QuicPacketSequenceNumber packet = smallest_received + sequence_delta; | 521 QuicPacketSequenceNumber packet = smallest_received + sequence_delta; |
520 inter_arrival->received_packet_times[packet] = | 522 inter_arrival->received_packet_times.insert( |
521 QuicTime::FromMicroseconds(time_received_us + time_delta_us); | 523 make_pair(packet, QuicTime::FromMicroseconds(time_received_us + |
| 524 time_delta_us))); |
522 } | 525 } |
523 } | 526 } |
524 break; | 527 break; |
525 } | 528 } |
526 case kFixRate: { | 529 case kFixRate: { |
527 CongestionFeedbackMessageFixRate* fix_rate = &frame->fix_rate; | 530 CongestionFeedbackMessageFixRate* fix_rate = &frame->fix_rate; |
528 if (!reader_->ReadUInt32(&fix_rate->bitrate_in_bytes_per_second)) { | 531 if (!reader_->ReadUInt32(&fix_rate->bitrate_in_bytes_per_second)) { |
529 set_detailed_error("Unable to read bitrate."); | 532 set_detailed_error("Unable to read bitrate."); |
530 return false; | 533 return false; |
531 } | 534 } |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 | 928 |
926 bool QuicFramer::RaiseError(QuicErrorCode error) { | 929 bool QuicFramer::RaiseError(QuicErrorCode error) { |
927 DLOG(INFO) << detailed_error_; | 930 DLOG(INFO) << detailed_error_; |
928 set_error(error); | 931 set_error(error); |
929 visitor_->OnError(this); | 932 visitor_->OnError(this); |
930 reader_.reset(NULL); | 933 reader_.reset(NULL); |
931 return false; | 934 return false; |
932 } | 935 } |
933 | 936 |
934 } // namespace net | 937 } // namespace net |
OLD | NEW |