OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 serialzing data into a sequential | 7 // These memory-resident streams are used for serialzing 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 // be <= kMaxStreams. If Init is not called the default is has kMaxStream. | 192 // be <= kMaxStreams. If Init is not called the default is has kMaxStream. |
193 void Init(size_t stream_index_limit); | 193 void Init(size_t stream_index_limit); |
194 | 194 |
195 // Returns a pointer to a substream. | 195 // Returns a pointer to a substream. |
196 SinkStream* stream(size_t id) { return id < count_ ? &streams_[id] : NULL; } | 196 SinkStream* stream(size_t id) { return id < count_ ? &streams_[id] : NULL; } |
197 | 197 |
198 // CopyTo serializes the streams in the SinkStreamSet into a single target | 198 // CopyTo serializes the streams in the SinkStreamSet into a single target |
199 // stream or file. The serialized format may be re-read by initializing a | 199 // stream or file. The serialized format may be re-read by initializing a |
200 // SourceStreamSet with a buffer containing the data. | 200 // SourceStreamSet with a buffer containing the data. |
201 bool CopyTo(SinkStream* combined_stream); | 201 bool CopyTo(SinkStream* combined_stream); |
202 bool CopyToFile(FILE* file); | |
203 bool CopyToFileDescriptor(int file_descriptor); | |
204 | 202 |
205 // Writes the streams of |set| into the corresponding streams of |this|. | 203 // Writes the streams of |set| into the corresponding streams of |this|. |
206 // Stream zero first has some metadata written to it. |set| becomes retired. | 204 // Stream zero first has some metadata written to it. |set| becomes retired. |
207 // Partner to SourceStreamSet::ReadSet. | 205 // Partner to SourceStreamSet::ReadSet. |
208 bool WriteSet(SinkStreamSet* set); | 206 bool WriteSet(SinkStreamSet* set); |
209 | 207 |
210 private: | 208 private: |
211 void CopyHeaderTo(SinkStream* stream); | 209 void CopyHeaderTo(SinkStream* stream); |
212 | 210 |
213 size_t count_; | 211 size_t count_; |
214 SinkStream streams_[kMaxStreams]; | 212 SinkStream streams_[kMaxStreams]; |
215 | 213 |
216 DISALLOW_COPY_AND_ASSIGN(SinkStreamSet); | 214 DISALLOW_COPY_AND_ASSIGN(SinkStreamSet); |
217 }; | 215 }; |
218 | 216 |
219 } // namespace | 217 } // namespace |
220 #endif // COURGETTE_STREAMS_H_ | 218 #endif // COURGETTE_STREAMS_H_ |
OLD | NEW |