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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 int rv = loader_.Open(request, callback); | 328 int rv = loader_.Open(request, callback); |
329 if (rv != PP_OK_COMPLETIONPENDING) | 329 if (rv != PP_OK_COMPLETIONPENDING) |
330 callback.Run(rv); | 330 callback.Run(rv); |
331 } | 331 } |
332 | 332 |
333 pp::URLRequestInfo DocumentLoader::GetRequest(uint32_t position, | 333 pp::URLRequestInfo DocumentLoader::GetRequest(uint32_t position, |
334 uint32_t size) const { | 334 uint32_t size) const { |
335 pp::URLRequestInfo request(client_->GetPluginInstance()); | 335 pp::URLRequestInfo request(client_->GetPluginInstance()); |
336 request.SetURL(url_); | 336 request.SetURL(url_); |
337 request.SetMethod("GET"); | 337 request.SetMethod("GET"); |
338 request.SetFollowRedirects(true); | 338 request.SetFollowRedirects(false); |
339 request.SetCustomReferrerURL(url_); | 339 request.SetCustomReferrerURL(url_); |
340 | 340 |
341 const size_t kBufSize = 100; | 341 const size_t kBufSize = 100; |
342 char buf[kBufSize]; | 342 char buf[kBufSize]; |
343 // According to rfc2616, byte range specifies position of the first and last | 343 // According to rfc2616, byte range specifies position of the first and last |
344 // bytes in the requested range inclusively. Therefore we should subtract 1 | 344 // bytes in the requested range inclusively. Therefore we should subtract 1 |
345 // from the position + size, to get index of the last byte that needs to be | 345 // from the position + size, to get index of the last byte that needs to be |
346 // downloaded. | 346 // downloaded. |
347 base::snprintf(buf, kBufSize, "Range: bytes=%d-%d", position, | 347 base::snprintf(buf, kBufSize, "Range: bytes=%d-%d", position, |
348 position + size - 1); | 348 position + size - 1); |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 | 537 |
538 void DocumentLoader::UpdateRendering() { | 538 void DocumentLoader::UpdateRendering() { |
539 if (header_request_) | 539 if (header_request_) |
540 client_->OnPartialDocumentLoaded(); | 540 client_->OnPartialDocumentLoaded(); |
541 else | 541 else |
542 client_->OnPendingRequestComplete(); | 542 client_->OnPendingRequestComplete(); |
543 header_request_ = false; | 543 header_request_ = false; |
544 } | 544 } |
545 | 545 |
546 } // namespace chrome_pdf | 546 } // namespace chrome_pdf |
OLD | NEW |