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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 if (headers_var.is_string()) | 376 if (headers_var.is_string()) |
377 headers = headers_var.AsString(); | 377 headers = headers_var.AsString(); |
378 | 378 |
379 std::string boundary = GetMultiPartBoundary(headers); | 379 std::string boundary = GetMultiPartBoundary(headers); |
380 if (!boundary.empty()) { | 380 if (!boundary.empty()) { |
381 // Leave position untouched for now, when we read the data we'll get it. | 381 // Leave position untouched for now, when we read the data we'll get it. |
382 is_multipart_ = true; | 382 is_multipart_ = true; |
383 multipart_boundary_ = boundary; | 383 multipart_boundary_ = boundary; |
384 } else { | 384 } else { |
385 // Need to make sure that the server returned a byte-range, since it's | 385 // Need to make sure that the server returned a byte-range, since it's |
386 // possible for a server to just ignore our bye-range request and just | 386 // possible for a server to just ignore our byte-range request and just |
387 // return the entire document even if it supports byte-range requests. | 387 // return the entire document even if it supports byte-range requests. |
388 // i.e. sniff response to | 388 // i.e. sniff response to |
389 // http://www.act.org/compass/sample/pdf/geometry.pdf | 389 // http://www.act.org/compass/sample/pdf/geometry.pdf |
390 current_pos_ = 0; | 390 current_pos_ = 0; |
391 uint32_t start_pos, end_pos; | 391 uint32_t start_pos, end_pos; |
392 if (GetByteRange(headers, &start_pos, &end_pos)) { | 392 if (GetByteRange(headers, &start_pos, &end_pos)) { |
393 current_pos_ = start_pos; | 393 current_pos_ = start_pos; |
394 if (end_pos && end_pos > start_pos) | 394 if (end_pos && end_pos > start_pos) |
395 current_chunk_size_ = end_pos - start_pos + 1; | 395 current_chunk_size_ = end_pos - start_pos + 1; |
| 396 } else { |
| 397 partial_document_ = false; |
396 } | 398 } |
397 } | 399 } |
398 | 400 |
399 ReadMore(); | 401 ReadMore(); |
400 } | 402 } |
401 | 403 |
402 void DocumentLoader::ReadMore() { | 404 void DocumentLoader::ReadMore() { |
403 pp::CompletionCallback callback = | 405 pp::CompletionCallback callback = |
404 loader_factory_.NewCallback(&DocumentLoader::DidRead); | 406 loader_factory_.NewCallback(&DocumentLoader::DidRead); |
405 int rv = loader_.ReadResponseBody(buffer_, sizeof(buffer_), callback); | 407 int rv = loader_.ReadResponseBody(buffer_, sizeof(buffer_), callback); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 | 536 |
535 void DocumentLoader::UpdateRendering() { | 537 void DocumentLoader::UpdateRendering() { |
536 if (header_request_) | 538 if (header_request_) |
537 client_->OnPartialDocumentLoaded(); | 539 client_->OnPartialDocumentLoaded(); |
538 else | 540 else |
539 client_->OnPendingRequestComplete(); | 541 client_->OnPendingRequestComplete(); |
540 header_request_ = false; | 542 header_request_ = false; |
541 } | 543 } |
542 | 544 |
543 } // namespace chrome_pdf | 545 } // namespace chrome_pdf |
OLD | NEW |