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

Side by Side Diff: pdf/document_loader.cc

Issue 301223004: Fix loading PDFs with no HTTP response headers in OOP PDF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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/document_loader.h" 5 #include "pdf/document_loader.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/http/http_util.h" 9 #include "net/http/http_util.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 disposition = it.values(); 72 disposition = it.values();
73 } 73 }
74 } 74 }
75 } 75 }
76 if (!type.empty() && 76 if (!type.empty() &&
77 !EndsWith(type, "/pdf", false) && 77 !EndsWith(type, "/pdf", false) &&
78 !EndsWith(type, ".pdf", false) && 78 !EndsWith(type, ".pdf", false) &&
79 !EndsWith(type, "/x-pdf", false) && 79 !EndsWith(type, "/x-pdf", false) &&
80 !EndsWith(type, "/*", false) && 80 !EndsWith(type, "/*", false) &&
81 !EndsWith(type, "/acrobat", false) && 81 !EndsWith(type, "/acrobat", false) &&
82 !EndsWith(type, "/unknown", false) && 82 !EndsWith(type, "/unknown", false)) {
83 !StartsWithASCII(url, "blob:", false)) {
84 return false; 83 return false;
85 } 84 }
86 if (StartsWithASCII(disposition, "attachment", false)) { 85 if (StartsWithASCII(disposition, "attachment", false)) {
87 return false; 86 return false;
88 } 87 }
89 88
90 if (content_length > 0) 89 if (content_length > 0)
91 chunk_stream_.Preallocate(content_length); 90 chunk_stream_.Preallocate(content_length);
92 91
93 document_size_ = content_length; 92 document_size_ = content_length;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 uint32 DocumentLoader::GetRequestSize() const { 495 uint32 DocumentLoader::GetRequestSize() const {
497 // Document loading strategy: 496 // Document loading strategy:
498 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we 497 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we
499 // double the size (64k), and so on, until we cap max request size at 2M for 498 // double the size (64k), and so on, until we cap max request size at 2M for
500 // 71 or more requests. 499 // 71 or more requests.
501 uint32 limited_count = std::min(std::max(requests_count_, 10u), 70u); 500 uint32 limited_count = std::min(std::max(requests_count_, 10u), 70u);
502 return 32*1024 * (1 << ((limited_count - 1) / 10u)); 501 return 32*1024 * (1 << ((limited_count - 1) / 10u));
503 } 502 }
504 503
505 } // namespace chrome_pdf 504 } // namespace chrome_pdf
OLDNEW
« no previous file with comments | « no previous file | pdf/out_of_process_instance.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698