OLD | NEW |
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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 | 291 |
292 return request; | 292 return request; |
293 } | 293 } |
294 | 294 |
295 void DocumentLoader::DidOpen(int32_t result) { | 295 void DocumentLoader::DidOpen(int32_t result) { |
296 if (result != PP_OK) { | 296 if (result != PP_OK) { |
297 NOTREACHED(); | 297 NOTREACHED(); |
298 return; | 298 return; |
299 } | 299 } |
300 | 300 |
| 301 int32_t http_code = loader_.GetResponseInfo().GetStatusCode(); |
| 302 if (http_code >= 400 && http_code < 500) { |
| 303 // Error accessing resource. 4xx error indicate subsequent requests |
| 304 // will fail too. |
| 305 // E.g. resource has been removed from the server while loading it. |
| 306 // https://code.google.com/p/chromium/issues/detail?id=414827 |
| 307 return; |
| 308 } |
| 309 |
301 is_multipart_ = false; | 310 is_multipart_ = false; |
302 current_chunk_size_ = 0; | 311 current_chunk_size_ = 0; |
303 current_chunk_read_ = 0; | 312 current_chunk_read_ = 0; |
304 | 313 |
305 pp::Var headers_var = loader_.GetResponseInfo().GetHeaders(); | 314 pp::Var headers_var = loader_.GetResponseInfo().GetHeaders(); |
306 std::string headers; | 315 std::string headers; |
307 if (headers_var.is_string()) | 316 if (headers_var.is_string()) |
308 headers = headers_var.AsString(); | 317 headers = headers_var.AsString(); |
309 | 318 |
310 std::string boundary = GetMultiPartBoundary(headers); | 319 std::string boundary = GetMultiPartBoundary(headers); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 uint32 DocumentLoader::GetRequestSize() const { | 504 uint32 DocumentLoader::GetRequestSize() const { |
496 // Document loading strategy: | 505 // Document loading strategy: |
497 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we | 506 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we |
498 // double the size (64k), and so on, until we cap max request size at 2M for | 507 // double the size (64k), and so on, until we cap max request size at 2M for |
499 // 71 or more requests. | 508 // 71 or more requests. |
500 uint32 limited_count = std::min(std::max(requests_count_, 10u), 70u); | 509 uint32 limited_count = std::min(std::max(requests_count_, 10u), 70u); |
501 return 32*1024 * (1 << ((limited_count - 1) / 10u)); | 510 return 32*1024 * (1 << ((limited_count - 1) / 10u)); |
502 } | 511 } |
503 | 512 |
504 } // namespace chrome_pdf | 513 } // namespace chrome_pdf |
OLD | NEW |