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/tools/quic/test_tools/quic_test_utils.h" | 5 #include "net/tools/quic/test_tools/quic_test_utils.h" |
6 | 6 |
7 #include "base/sha1.h" | |
8 #include "net/quic/quic_connection.h" | 7 #include "net/quic/quic_connection.h" |
9 #include "net/quic/test_tools/quic_connection_peer.h" | 8 #include "net/quic/test_tools/quic_connection_peer.h" |
10 #include "net/quic/test_tools/quic_test_utils.h" | 9 #include "net/quic/test_tools/quic_test_utils.h" |
11 #include "net/tools/quic/quic_epoll_connection_helper.h" | 10 #include "net/tools/quic/quic_epoll_connection_helper.h" |
12 | 11 |
13 using base::StringPiece; | 12 using base::StringPiece; |
14 using net::test::kInitialFlowControlWindowForTest; | 13 using net::test::kInitialFlowControlWindowForTest; |
15 using net::test::MakeAckFrame; | 14 using net::test::MakeAckFrame; |
16 using net::test::MockHelper; | 15 using net::test::MockHelper; |
17 using net::test::QuicConnectionPeer; | 16 using net::test::QuicConnectionPeer; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 size_t num_nack_ranges, QuicPacketSequenceNumber least_unacked) { | 72 size_t num_nack_ranges, QuicPacketSequenceNumber least_unacked) { |
74 QuicAckFrame ack = MakeAckFrame(2 * num_nack_ranges + least_unacked, | 73 QuicAckFrame ack = MakeAckFrame(2 * num_nack_ranges + least_unacked, |
75 least_unacked); | 74 least_unacked); |
76 // Add enough missing packets to get num_nack_ranges nack ranges. | 75 // Add enough missing packets to get num_nack_ranges nack ranges. |
77 for (QuicPacketSequenceNumber i = 1; i < 2 * num_nack_ranges; i += 2) { | 76 for (QuicPacketSequenceNumber i = 1; i < 2 * num_nack_ranges; i += 2) { |
78 ack.received_info.missing_packets.insert(least_unacked + i); | 77 ack.received_info.missing_packets.insert(least_unacked + i); |
79 } | 78 } |
80 return ack; | 79 return ack; |
81 } | 80 } |
82 | 81 |
83 uint64 SimpleRandom::RandUint64() { | |
84 unsigned char hash[base::kSHA1Length]; | |
85 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), | |
86 hash); | |
87 memcpy(&seed_, hash, sizeof(seed_)); | |
88 return seed_; | |
89 } | |
90 | |
91 TestSession::TestSession(QuicConnection* connection, | 82 TestSession::TestSession(QuicConnection* connection, |
92 const QuicConfig& config) | 83 const QuicConfig& config) |
93 : QuicSession(connection, kInitialFlowControlWindowForTest, config), | 84 : QuicSession(connection, kInitialFlowControlWindowForTest, config), |
94 crypto_stream_(NULL) { | 85 crypto_stream_(NULL) { |
95 } | 86 } |
96 | 87 |
97 TestSession::~TestSession() {} | 88 TestSession::~TestSession() {} |
98 | 89 |
99 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { | 90 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { |
100 crypto_stream_ = stream; | 91 crypto_stream_ = stream; |
(...skipping 17 matching lines...) Expand all Loading... |
118 | 109 |
119 MockAckNotifierDelegate::MockAckNotifierDelegate() { | 110 MockAckNotifierDelegate::MockAckNotifierDelegate() { |
120 } | 111 } |
121 | 112 |
122 MockAckNotifierDelegate::~MockAckNotifierDelegate() { | 113 MockAckNotifierDelegate::~MockAckNotifierDelegate() { |
123 } | 114 } |
124 | 115 |
125 } // namespace test | 116 } // namespace test |
126 } // namespace tools | 117 } // namespace tools |
127 } // namespace net | 118 } // namespace net |
OLD | NEW |