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

Side by Side Diff: pdf/chunk_stream.cc

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 | « pdf/chunk_stream.h ('k') | pdf/out_of_process_instance.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 #include "pdf/chunk_stream.h" 5 #include "pdf/chunk_stream.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #define __STDC_LIMIT_MACROS 10 #define __STDC_LIMIT_MACROS
(...skipping 17 matching lines...) Expand all
28 chunks_.clear(); 28 chunks_.clear();
29 data_.clear(); 29 data_.clear();
30 stream_size_ = 0; 30 stream_size_ = 0;
31 } 31 }
32 32
33 void ChunkStream::Preallocate(size_t stream_size) { 33 void ChunkStream::Preallocate(size_t stream_size) {
34 data_.reserve(stream_size); 34 data_.reserve(stream_size);
35 stream_size_ = stream_size; 35 stream_size_ = stream_size;
36 } 36 }
37 37
38 size_t ChunkStream::GetSize() { 38 size_t ChunkStream::GetSize() const {
39 return data_.size(); 39 return data_.size();
40 } 40 }
41 41
42 bool ChunkStream::WriteData(size_t offset, void* buffer, size_t size) { 42 bool ChunkStream::WriteData(size_t offset, void* buffer, size_t size) {
43 if (SIZE_MAX - size < offset) 43 if (SIZE_MAX - size < offset)
44 return false; 44 return false;
45 45
46 if (data_.size() < offset + size) 46 if (data_.size() < offset + size)
47 data_.resize(offset + size); 47 data_.resize(offset + size);
48 48
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 size_t ChunkStream::GetLastMissingByteInInterval(size_t offset) const { 166 size_t ChunkStream::GetLastMissingByteInInterval(size_t offset) const {
167 if (chunks_.empty()) 167 if (chunks_.empty())
168 return stream_size_ - 1; 168 return stream_size_ - 1;
169 std::map<size_t, size_t>::const_iterator it = chunks_.upper_bound(offset); 169 std::map<size_t, size_t>::const_iterator it = chunks_.upper_bound(offset);
170 if (it == chunks_.end()) 170 if (it == chunks_.end())
171 return stream_size_ - 1; 171 return stream_size_ - 1;
172 return it->first - 1; 172 return it->first - 1;
173 } 173 }
174 174
175 } // namespace chrome_pdf 175 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « pdf/chunk_stream.h ('k') | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698