| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 } | 46 } |
| 47 return false; | 47 return false; |
| 48 } | 48 } |
| 49 | 49 |
| 50 // If the headers have a multi-part response, returns the boundary name. | 50 // If the headers have a multi-part response, returns the boundary name. |
| 51 // Otherwise returns an empty string. | 51 // Otherwise returns an empty string. |
| 52 std::string GetMultiPartBoundary(const std::string& headers) { | 52 std::string GetMultiPartBoundary(const std::string& headers) { |
| 53 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n"); | 53 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), "\n"); |
| 54 while (it.GetNext()) { | 54 while (it.GetNext()) { |
| 55 if (base::LowerCaseEqualsASCII(it.name(), "content-type")) { | 55 if (base::LowerCaseEqualsASCII(it.name(), "content-type")) { |
| 56 std::string type = base::StringToLowerASCII(it.values()); | 56 std::string type = base::ToLowerASCII(it.values()); |
| 57 if (base::StartsWith(type, "multipart/", base::CompareCase::SENSITIVE)) { | 57 if (base::StartsWith(type, "multipart/", base::CompareCase::SENSITIVE)) { |
| 58 const char* boundary = strstr(type.c_str(), "boundary="); | 58 const char* boundary = strstr(type.c_str(), "boundary="); |
| 59 if (!boundary) { | 59 if (!boundary) { |
| 60 NOTREACHED(); | 60 NOTREACHED(); |
| 61 break; | 61 break; |
| 62 } | 62 } |
| 63 | 63 |
| 64 return std::string(boundary + 9); | 64 return std::string(boundary + 9); |
| 65 } | 65 } |
| 66 } | 66 } |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 uint32_t DocumentLoader::GetRequestSize() const { | 533 uint32_t DocumentLoader::GetRequestSize() const { |
| 534 // Document loading strategy: | 534 // Document loading strategy: |
| 535 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we | 535 // For first 10 requests, we use 32k chunk sizes, for the next 10 requests we |
| 536 // double the size (64k), and so on, until we cap max request size at 2M for | 536 // double the size (64k), and so on, until we cap max request size at 2M for |
| 537 // 71 or more requests. | 537 // 71 or more requests. |
| 538 uint32_t limited_count = std::min(std::max(requests_count_, 10u), 70u); | 538 uint32_t limited_count = std::min(std::max(requests_count_, 10u), 70u); |
| 539 return 32 * 1024 * (1 << ((limited_count - 1) / 10u)); | 539 return 32 * 1024 * (1 << ((limited_count - 1) / 10u)); |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace chrome_pdf | 542 } // namespace chrome_pdf |
| OLD | NEW |