Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: pdf/chunk_stream.h

Issue 1555153003: Another round of PDF plugin cleanups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moar Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | pdf/chunk_stream.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 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 PDF_CHUNK_STREAM_H_ 5 #ifndef PDF_CHUNK_STREAM_H_
6 #define PDF_CHUNK_STREAM_H_ 6 #define PDF_CHUNK_STREAM_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 namespace chrome_pdf { 14 namespace chrome_pdf {
15 15
16 // This class collects a chunks of data into one data stream. Client can check 16 // This class collects a chunks of data into one data stream. Client can check
17 // if data in certain range is available, and get missing chunks of data. 17 // if data in certain range is available, and get missing chunks of data.
18 class ChunkStream { 18 class ChunkStream {
19 public: 19 public:
20 ChunkStream(); 20 ChunkStream();
21 ~ChunkStream(); 21 ~ChunkStream();
22 22
23 void Clear(); 23 void Clear();
24 24
25 void Preallocate(size_t stream_size); 25 void Preallocate(size_t stream_size);
26 size_t GetSize(); 26 size_t GetSize() const;
27 27
28 bool WriteData(size_t offset, void* buffer, size_t size); 28 bool WriteData(size_t offset, void* buffer, size_t size);
29 bool ReadData(size_t offset, size_t size, void* buffer) const; 29 bool ReadData(size_t offset, size_t size, void* buffer) const;
30 30
31 // Returns vector of pairs where first is an offset, second is a size. 31 // Returns vector of pairs where first is an offset, second is a size.
32 bool GetMissedRanges(size_t offset, size_t size, 32 bool GetMissedRanges(size_t offset, size_t size,
33 std::vector<std::pair<size_t, size_t> >* ranges) const; 33 std::vector<std::pair<size_t, size_t> >* ranges) const;
34 bool IsRangeAvailable(size_t offset, size_t size) const; 34 bool IsRangeAvailable(size_t offset, size_t size) const;
35 size_t GetFirstMissingByte() const; 35 size_t GetFirstMissingByte() const;
36 36
37 // Finds the first byte of the missing byte interval that offset belongs to. 37 // Finds the first byte of the missing byte interval that offset belongs to.
38 size_t GetFirstMissingByteInInterval(size_t offset) const; 38 size_t GetFirstMissingByteInInterval(size_t offset) const;
39 // Returns the last byte of the missing byte interval that offset belongs to. 39 // Returns the last byte of the missing byte interval that offset belongs to.
40 size_t GetLastMissingByteInInterval(size_t offset) const; 40 size_t GetLastMissingByteInInterval(size_t offset) const;
41 41
42 private: 42 private:
43 std::vector<unsigned char> data_; 43 std::vector<unsigned char> data_;
44 44
45 // Pair, first - begining of the chunk, second - size of the chunk. 45 // Pair, first - begining of the chunk, second - size of the chunk.
46 std::map<size_t, size_t> chunks_; 46 std::map<size_t, size_t> chunks_;
47 47
48 size_t stream_size_; 48 size_t stream_size_;
49 }; 49 };
50 50
51 }; // namespace chrome_pdf 51 }; // namespace chrome_pdf
52 52
53 #endif // PDF_CHUNK_STREAM_H_ 53 #endif // PDF_CHUNK_STREAM_H_
OLDNEW
« no previous file with comments | « no previous file | pdf/chunk_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698