Revert of Re-enabled contenteditable and text-changed tests after content editable...
[chromium-blink-merge.git] / pdf / chunk_stream.h
blobfac1ec644de367c60a8a57c18eb7a15395292e96
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef PDF_CHUNK_STREAM_H_
6 #define PDF_CHUNK_STREAM_H_
8 #include <stddef.h>
10 #include <map>
11 #include <vector>
13 namespace chrome_pdf {
15 // This class collects a chunks of data into one data stream. Client can check
16 // if data in certain range is available, and get missing chunks of data.
17 class ChunkStream {
18 public:
19 ChunkStream();
20 ~ChunkStream();
22 void Clear();
24 void Preallocate(size_t stream_size);
25 size_t GetSize();
27 bool WriteData(size_t offset, void* buffer, size_t size);
28 bool ReadData(size_t offset, size_t size, void* buffer) const;
30 // Returns vector of pairs where first is an offset, second is a size.
31 bool GetMissedRanges(size_t offset, size_t size,
32 std::vector<std::pair<size_t, size_t> >* ranges) const;
33 bool IsRangeAvailable(size_t offset, size_t size) const;
34 size_t GetFirstMissingByte() const;
36 size_t GetLastByteBefore(size_t offset) const;
37 size_t GetFirstByteAfter(size_t offset) const;
39 private:
40 std::vector<unsigned char> data_;
42 // Pair, first - begining of the chunk, second - size of the chunk.
43 std::map<size_t, size_t> chunks_;
46 }; // namespace chrome_pdf
48 #endif