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_fec_group.h" | 5 #include "net/quic/quic_fec_group.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | |
11 #include "base/logging.h" | 10 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
13 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
14 | 13 |
15 using ::testing::_; | 14 using ::testing::_; |
16 using base::StringPiece; | 15 using base::StringPiece; |
17 using std::string; | 16 using std::string; |
18 | 17 |
19 namespace net { | 18 namespace net { |
20 | 19 |
(...skipping 26 matching lines...) Expand all Loading... |
47 // kData[] and kEntropyFlag[] are indexed by packet numbers, which | 46 // kData[] and kEntropyFlag[] are indexed by packet numbers, which |
48 // start at 1. | 47 // start at 1. |
49 DCHECK_GE(arraysize(kData), num_packets); | 48 DCHECK_GE(arraysize(kData), num_packets); |
50 scoped_ptr<char[]> redundancy(new char[kDataMaxLen]); | 49 scoped_ptr<char[]> redundancy(new char[kDataMaxLen]); |
51 for (size_t i = 0; i < kDataMaxLen; i++) { | 50 for (size_t i = 0; i < kDataMaxLen; i++) { |
52 redundancy[i] = 0x00; | 51 redundancy[i] = 0x00; |
53 } | 52 } |
54 // XOR in the packets. | 53 // XOR in the packets. |
55 for (size_t packet = 1; packet <= num_packets; ++packet) { | 54 for (size_t packet = 1; packet <= num_packets; ++packet) { |
56 for (size_t i = 0; i < kDataMaxLen; i++) { | 55 for (size_t i = 0; i < kDataMaxLen; i++) { |
57 uint8 byte = i > strlen(kData[packet]) ? 0x00 : kData[packet][i]; | 56 uint8_t byte = i > strlen(kData[packet]) ? 0x00 : kData[packet][i]; |
58 redundancy[i] = redundancy[i] ^ byte; | 57 redundancy[i] = redundancy[i] ^ byte; |
59 } | 58 } |
60 } | 59 } |
61 | 60 |
62 QuicFecGroup group(1); | 61 QuicFecGroup group(1); |
63 | 62 |
64 // If we're out of order, send the FEC packet in the position of the | 63 // If we're out of order, send the FEC packet in the position of the |
65 // lost packet. Otherwise send all (non-missing) packets, then FEC. | 64 // lost packet. Otherwise send all (non-missing) packets, then FEC. |
66 if (out_of_order) { | 65 if (out_of_order) { |
67 // Update the FEC state for each non-lost packet. | 66 // Update the FEC state for each non-lost packet. |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 322 |
324 // XOR the buffers and compare the result with the reference. | 323 // XOR the buffers and compare the result with the reference. |
325 QuicFecGroup::XorBuffers(shorter.buffer(), shorter.size(), | 324 QuicFecGroup::XorBuffers(shorter.buffer(), shorter.size(), |
326 longer.buffer()); | 325 longer.buffer()); |
327 EXPECT_EQ(output_reference, longer.AsStringPiece()); | 326 EXPECT_EQ(output_reference, longer.AsStringPiece()); |
328 } | 327 } |
329 } | 328 } |
330 } | 329 } |
331 | 330 |
332 } // namespace net | 331 } // namespace net |
OLD | NEW |