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

Side by Side Diff: pdf/document_loader.cc

Issue 1705353002: Disable range requests if the origin ignores byte-range. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « no previous file | no next file » | 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 <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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698