OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef NET_CURVECP_TEST_DATA_STREAM_H_ | 5 #ifndef NET_BASE_TEST_DATA_STREAM_H_ |
6 #define NET_CURVECP_TEST_DATA_STREAM_H_ | 6 #define NET_BASE_TEST_DATA_STREAM_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string.h> // for memcpy() | 9 #include <string.h> // for memcpy() |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include "net/base/net_api.h" | |
11 | 12 |
12 // This is a test class for generating an infinite stream of data which can | 13 // This is a test class for generating an infinite stream of data which can |
13 // be verified independently to be the correct stream of data. | 14 // be verified independently to be the correct stream of data. |
14 | 15 |
15 namespace net { | 16 namespace net { |
16 | 17 |
17 class TestDataStream { | 18 class NET_API TestDataStream { |
18 public: | 19 public: |
19 TestDataStream() { | 20 TestDataStream() { |
20 Reset(); | 21 Reset(); |
21 } | 22 } |
22 | 23 |
23 // Fill |buffer| with |length| bytes of data from the stream. | 24 // Fill |buffer| with |length| bytes of data from the stream. |
24 void GetBytes(char* buffer, int length) { | 25 void GetBytes(char* buffer, int length) { |
Mike Belshe
2011/05/27 21:27:00
BTW - I think clank is going to bitch at you when
ramant (doing other things)
2011/05/31 21:25:36
Done.
| |
25 while (length) { | 26 while (length) { |
26 AdvanceIndex(); | 27 AdvanceIndex(); |
27 int bytes_to_copy = std::min(length, bytes_remaining_); | 28 int bytes_to_copy = std::min(length, bytes_remaining_); |
28 memcpy(buffer, buffer_ptr_, bytes_to_copy); | 29 memcpy(buffer, buffer_ptr_, bytes_to_copy); |
29 buffer += bytes_to_copy; | 30 buffer += bytes_to_copy; |
30 Consume(bytes_to_copy); | 31 Consume(bytes_to_copy); |
31 length -= bytes_to_copy; | 32 length -= bytes_to_copy; |
32 } | 33 } |
33 } | 34 } |
34 | 35 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 } | 79 } |
79 | 80 |
80 int index_; | 81 int index_; |
81 int bytes_remaining_; | 82 int bytes_remaining_; |
82 char buffer_[16]; | 83 char buffer_[16]; |
83 char* buffer_ptr_; | 84 char* buffer_ptr_; |
84 }; | 85 }; |
85 | 86 |
86 } // namespace net | 87 } // namespace net |
87 | 88 |
88 #endif // NET_CURVECP_TEST_DATA_STREAM_H_ | 89 #endif // NET_BASE_TEST_DATA_STREAM_H_ |
OLD | NEW |