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.
5 #ifndef PDF_URL_LOADER_WRAPPER_H_
6 #define PDF_URL_LOADER_WRAPPER_H_
10 #include "base/macros.h"
11 #include "ppapi/cpp/completion_callback.h"
13 namespace chrome_pdf {
15 class URLLoaderWrapper {
17 virtual ~URLLoaderWrapper() {}
19 // Returns length of content, will be -1, if it is unknown.
20 virtual int GetContentLength() const = 0;
22 // Returns if the response headers contains "accept-ranges".
23 virtual bool IsAcceptRangesBytes() const = 0;
25 // Returns if the content encoded in response.
26 virtual bool IsContentEncoded() const = 0;
28 // Returns response content type.
29 virtual std::string GetContentType() const = 0;
31 // Returns response content disposition.
32 virtual std::string GetContentDisposition() const = 0;
34 // Returns response status code.
35 virtual int GetStatusCode() const = 0;
37 // Returns if the response contains multi parts.
38 virtual bool IsMultipart() const = 0;
40 // If true, |start| contains the start of the byte range.
41 // If false, response contains full document and |start| will be undefined.
42 virtual bool GetByteRangeStart(int* start) const = 0;
45 virtual void Close() = 0;
47 // Open new connection and send http range request.
48 virtual void OpenRange(const std::string& url,
49 const std::string& referrer_url,
52 const pp::CompletionCallback& cc) = 0;
54 // Read the response body. The size of the buffer must be large enough to
55 // hold the specified number of bytes to read.
56 // This function might perform a partial read.
57 virtual void ReadResponseBody(char* buffer,
59 const pp::CompletionCallback& cc) = 0;
60 // Returns the current download progress.
61 // Progress only refers to the response body and does not include the headers.
62 // If false, progress is unknown, bytes_received/total_bytes_to_be_received
64 virtual bool GetDownloadProgress(
65 int64_t* bytes_received,
66 int64_t* total_bytes_to_be_received) const = 0;
69 } // namespace chrome_pdf
71 #endif // PDF_URL_LOADER_WRAPPER_H_