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

Unified Diff: pdf/document_loader.h

Issue 1506023002: Minimize the number of range requests made by PDFium (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issue with chunk_stream Created 5 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pdf/chunk_stream.cc ('k') | pdf/document_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/document_loader.h
diff --git a/pdf/document_loader.h b/pdf/document_loader.h
index 4e734a0663a4fab82964544eb3f6ae61668b7c81..7e175debdcf878a9511d10a6ebbb2e6e2523ba1d 100644
--- a/pdf/document_loader.h
+++ b/pdf/document_loader.h
@@ -7,6 +7,7 @@
#include <list>
#include <string>
+#include <utility>
#include <vector>
#include "base/basictypes.h"
@@ -14,8 +15,6 @@
#include "ppapi/cpp/url_loader.h"
#include "ppapi/utility/completion_callback_factory.h"
-#define kDefaultRequestSize 32768u
-
namespace chrome_pdf {
class DocumentLoader {
@@ -81,12 +80,24 @@ class DocumentLoader {
void LoadFullDocument();
// Download pending requests.
void DownloadPendingRequests();
+ // Remove completed ranges.
+ void RemoveCompletedRanges();
+ // Returns true if we are already in progress satisfying the request, or just
+ // about ready to start. This helps us avoid expensive jumping around, and
+ // even worse leaving tiny gaps in the byte stream that might have to be
+ // filled later.
+ bool SatisfyingRequest(size_t pos, size_t size) const;
// Called when we complete server request and read all data from it.
void ReadComplete();
// Creates request to download size byte of data data starting from position.
pp::URLRequestInfo GetRequest(uint32_t position, uint32_t size) const;
- // Returns current request size in bytes.
- uint32_t GetRequestSize() const;
+ // Updates the rendering by the Client.
+ void UpdateRendering();
+
+ // Document below size will be downloaded in one chunk.
+ static const uint32_t kMinFileSize = 64 * 1024;
+ // Number was chosen in crbug.com/78264#c8
+ enum { kDefaultRequestSize = 65536 };
Client* client_;
std::string url_;
@@ -97,6 +108,15 @@ class DocumentLoader {
bool request_pending_;
typedef std::list<std::pair<size_t, size_t> > PendingRequests;
PendingRequests pending_requests_;
+ // The starting position of the HTTP request currently being processed.
+ size_t current_request_offset_;
+ // The size of the byte range the current HTTP request must download before
+ // being cancelled.
+ size_t current_request_size_;
+ // The actual byte range size of the current HTTP request. This may be larger
+ // than |current_request_size_| and the request may be cancelled before
+ // reaching |current_request_offset_| + |current_request_extended_size_|.
+ size_t current_request_extended_size_;
char buffer_[kDefaultRequestSize];
uint32_t current_pos_;
uint32_t current_chunk_size_;
« no previous file with comments | « pdf/chunk_stream.cc ('k') | pdf/document_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698