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 #ifndef CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ | 5 #ifndef CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ |
6 #define CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ | 6 #define CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "base/memory/scoped_vector.h" | |
17 #include "content/common/content_export.h" | 16 #include "content/common/content_export.h" |
18 | 17 |
19 namespace content { | 18 namespace content { |
20 | 19 |
21 // Models a chunk-oriented byte buffer. The term chunk is herein defined as an | 20 // Models a chunk-oriented byte buffer. The term chunk is herein defined as an |
22 // arbitrary sequence of bytes that is preceeded by N header bytes, indicating | 21 // arbitrary sequence of bytes that is preceeded by N header bytes, indicating |
23 // its size. Data may be appended to the buffer with no particular respect of | 22 // its size. Data may be appended to the buffer with no particular respect of |
24 // chunks boundaries. However, chunks can be extracted (FIFO) only when their | 23 // chunks boundaries. However, chunks can be extracted (FIFO) only when their |
25 // content (according to their header) is fully available in the buffer. | 24 // content (according to their header) is fully available in the buffer. |
26 // The current implementation support only 4 byte Big Endian headers. | 25 // The current implementation support only 4 byte Big Endian headers. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 ~Chunk(); | 57 ~Chunk(); |
59 | 58 |
60 std::vector<uint8_t> header; | 59 std::vector<uint8_t> header; |
61 std::unique_ptr<std::vector<uint8_t>> content; | 60 std::unique_ptr<std::vector<uint8_t>> content; |
62 size_t ExpectedContentLength() const; | 61 size_t ExpectedContentLength() const; |
63 | 62 |
64 private: | 63 private: |
65 DISALLOW_COPY_AND_ASSIGN(Chunk); | 64 DISALLOW_COPY_AND_ASSIGN(Chunk); |
66 }; | 65 }; |
67 | 66 |
68 ScopedVector<Chunk> chunks_; | 67 std::vector<std::unique_ptr<Chunk>> chunks_; |
69 std::unique_ptr<Chunk> partial_chunk_; | 68 std::unique_ptr<Chunk> partial_chunk_; |
70 size_t total_bytes_stored_; | 69 size_t total_bytes_stored_; |
71 | 70 |
72 DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer); | 71 DISALLOW_COPY_AND_ASSIGN(ChunkedByteBuffer); |
73 }; | 72 }; |
74 | 73 |
75 | 74 |
76 } // namespace content | 75 } // namespace content |
77 | 76 |
78 #endif // CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ | 77 #endif // CONTENT_BROWSER_SPEECH_CHUNKED_BYTE_BUFFER_H_ |
OLD | NEW |