diff options
author | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 20:41:30 +0000 |
---|---|---|
committer | vitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 20:41:30 +0000 |
commit | a2c2d53edb7860748dd94f339c0bf2d6e49bcf9d (patch) | |
tree | e09e885fe9b9eabeb375c2996c17bb05f1c4138a /pdf/document_loader.cc | |
parent | 037642f6e9dd120f52f832b8a9a7aa3fcb8c4800 (diff) | |
download | chromium_src-a2c2d53edb7860748dd94f339c0bf2d6e49bcf9d.zip chromium_src-a2c2d53edb7860748dd94f339c0bf2d6e49bcf9d.tar.gz chromium_src-a2c2d53edb7860748dd94f339c0bf2d6e49bcf9d.tar.bz2 |
Removed unnecessary map.
Review URL: https://codereview.chromium.org/301033003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273580 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'pdf/document_loader.cc')
-rw-r--r-- | pdf/document_loader.cc | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc index 5a35b47..0be459e 100644 --- a/pdf/document_loader.cc +++ b/pdf/document_loader.cc @@ -93,17 +93,6 @@ bool DocumentLoader::Init(const pp::URLLoader& loader, document_size_ = content_length; requests_count_ = 0; - // Document loading strategy. - // Following table shows the growth on the minimal request size depending - // on the number requests that has been made already. - chunk_size_table_[10] = 32*1024; - chunk_size_table_[20] = 64*1024; - chunk_size_table_[30] = 128*1024; - chunk_size_table_[40] = 256*1024; - chunk_size_table_[50] = 512*1024; - chunk_size_table_[60] = 1024*1024; - chunk_size_table_[70] = 2048*1024; - // Enable partial loading only if file size is above the threshold. // It will allow avoiding latency for multiple requests. if (content_length > kMinFileSize && @@ -505,11 +494,12 @@ void DocumentLoader::ReadComplete() { } uint32 DocumentLoader::GetRequestSize() const { - std::map<uint32, uint32>::const_iterator iter = - chunk_size_table_.lower_bound(requests_count_); - if (iter == chunk_size_table_.end()) - iter--; - return iter->second; + // Document loading strategy: + // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we + // double the size (64k), and so on, until we cap max request size at 2M for + // 71 or more requests. + uint32 limited_count = std::min(std::max(requests_count_, 10u), 70u); + return 32*1024 * (1 << ((limited_count - 1) / 10u)); } } // namespace chrome_pdf |