OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef PDF_URL_LOADER_WRAPPER_H_ |
| 6 #define PDF_URL_LOADER_WRAPPER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "ppapi/cpp/completion_callback.h" |
| 12 |
| 13 namespace chrome_pdf { |
| 14 |
| 15 class URLLoaderWrapper { |
| 16 public: |
| 17 virtual ~URLLoaderWrapper() {} |
| 18 |
| 19 // Returns length of content, will be -1, if it is unknown. |
| 20 virtual int GetContentLength() const = 0; |
| 21 // Returns if the response headers contains "accept-ranges". |
| 22 virtual bool IsAcceptRangesBytes() const = 0; |
| 23 // Returns if the content encoded in response. |
| 24 virtual bool IsContentEncoded() const = 0; |
| 25 // Returns response content type. |
| 26 virtual std::string GetContentType() const = 0; |
| 27 // Returns response content disposition. |
| 28 virtual std::string GetContentDisposition() const = 0; |
| 29 // Returns response status code. |
| 30 virtual int GetStatusCode() const = 0; |
| 31 // Returns if the response contains multi parts. |
| 32 virtual bool IsMultipart() const = 0; |
| 33 // If true, [start,end] - is byte range contains in response (include end). |
| 34 // If false, response contains full document, start/end will be undefined. |
| 35 virtual bool GetByteRange(int* start, int* end) const = 0; |
| 36 |
| 37 // Close connection. |
| 38 virtual void Close() = 0; |
| 39 // Open new connection and send http range request. |
| 40 virtual void OpenRange(const std::string& url, |
| 41 const std::string& referrer_url, |
| 42 uint32_t position, |
| 43 uint32_t size, |
| 44 const pp::CompletionCallback& cc) = 0; |
| 45 // Read the response body. The size of the buffer must be large enough to |
| 46 // hold the specified number of bytes to read. |
| 47 // This function might perform a partial read. |
| 48 virtual void ReadResponseBody(char* buffer, |
| 49 int buffer_size, |
| 50 const pp::CompletionCallback& cc) = 0; |
| 51 // Returns the current download progress. |
| 52 // Progress only refers to the response body and does not include the headers. |
| 53 // If false, progress is unknown, bytes_received/total_bytes_to_be_received |
| 54 // will be undefined. |
| 55 virtual bool GetDownloadProgress( |
| 56 int64_t* bytes_received, |
| 57 int64_t* total_bytes_to_be_received) const = 0; |
| 58 }; |
| 59 |
| 60 } // namespace chrome_pdf |
| 61 |
| 62 #endif // PDF_URL_LOADER_WRAPPER_H_ |
OLD | NEW |