Chromium Code Reviews| 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 // Streams classes. | 5 // Streams classes. |
| 6 // | 6 // |
| 7 // These memory-resident streams are used for serializing data into a sequential | 7 // These memory-resident streams are used for serializing data into a sequential |
| 8 // region of memory. | 8 // region of memory. |
| 9 // Streams are divided into SourceStreams for reading and SinkStreams for | 9 // Streams are divided into SourceStreams for reading and SinkStreams for |
| 10 // writing. Streams are aggregated into Sets which allows several streams to be | 10 // writing. Streams are aggregated into Sets which allows several streams to be |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 | 26 |
| 27 | 27 |
| 28 namespace courgette { | 28 namespace courgette { |
| 29 | 29 |
| 30 class SourceStream; | 30 class SourceStream; |
| 31 class SinkStream; | 31 class SinkStream; |
| 32 | 32 |
| 33 // Maximum number of streams in a stream set. | 33 // Maximum number of streams in a stream set. |
| 34 static const unsigned int kMaxStreams = 10; | 34 static const unsigned int kMaxStreams = 10; |
| 35 | 35 |
| 36 // A simple interface for reading binary data. | |
| 37 class BasicBuffer { | |
| 38 public: | |
| 39 BasicBuffer() {} | |
|
chrisha
2017/04/24 18:15:50
Virtual destructor needed for interface classes.
huangs
2017/04/24 20:08:14
Done. Also getting the 2 implementations to overri
| |
| 40 virtual const uint8_t* data() const = 0; | |
| 41 virtual size_t length() const = 0; | |
| 42 }; | |
| 43 | |
| 36 // A SourceStream allows a region of memory to be scanned by a sequence of Read | 44 // A SourceStream allows a region of memory to be scanned by a sequence of Read |
| 37 // operations. The stream does not own the memory. | 45 // operations. The stream does not own the memory. |
| 38 class SourceStream { | 46 class SourceStream { |
| 39 public: | 47 public: |
| 40 SourceStream() : start_(NULL), end_(NULL), current_(NULL) {} | 48 SourceStream() : start_(NULL), end_(NULL), current_(NULL) {} |
| 41 | 49 |
| 42 // Initializes the SourceStream to yield the bytes at |pointer|. The caller | 50 // Initializes the SourceStream to yield the bytes at |pointer|. The caller |
| 43 // still owns the memory at |pointer| and should free the memory only after | 51 // still owns the memory at |pointer| and should free the memory only after |
| 44 // the last use of the stream. | 52 // the last use of the stream. |
| 45 void Init(const void* pointer, size_t length) { | 53 void Init(const void* pointer, size_t length) { |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 235 |
| 228 private: | 236 private: |
| 229 CheckBool CopyHeaderTo(SinkStream* stream) WARN_UNUSED_RESULT; | 237 CheckBool CopyHeaderTo(SinkStream* stream) WARN_UNUSED_RESULT; |
| 230 | 238 |
| 231 size_t count_; | 239 size_t count_; |
| 232 SinkStream streams_[kMaxStreams]; | 240 SinkStream streams_[kMaxStreams]; |
| 233 | 241 |
| 234 DISALLOW_COPY_AND_ASSIGN(SinkStreamSet); | 242 DISALLOW_COPY_AND_ASSIGN(SinkStreamSet); |
| 235 }; | 243 }; |
| 236 | 244 |
| 237 } // namespace | 245 } // namespace courgette |
| 246 | |
| 238 #endif // COURGETTE_STREAMS_H_ | 247 #endif // COURGETTE_STREAMS_H_ |
| OLD | NEW |