Upload upstream chromium 76.0.3809.146
[platform/framework/web/chromium-efl.git] / pdf / url_loader_wrapper.h
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
22   // Returns if the response headers contains "accept-ranges".
23   virtual bool IsAcceptRangesBytes() const = 0;
24
25   // Returns if the content encoded in response.
26   virtual bool IsContentEncoded() const = 0;
27
28   // Returns response content type.
29   virtual std::string GetContentType() const = 0;
30
31   // Returns response content disposition.
32   virtual std::string GetContentDisposition() const = 0;
33
34   // Returns response status code.
35   virtual int GetStatusCode() const = 0;
36
37   // Returns if the response contains multi parts.
38   virtual bool IsMultipart() const = 0;
39
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;
43
44   // Close connection.
45   virtual void Close() = 0;
46
47   // Open new connection and send http range request.
48   virtual void OpenRange(const std::string& url,
49                          const std::string& referrer_url,
50                          uint32_t position,
51                          uint32_t size,
52                          const pp::CompletionCallback& cc) = 0;
53
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,
58                                 int buffer_size,
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
63   // will be undefined.
64   virtual bool GetDownloadProgress(
65       int64_t* bytes_received,
66       int64_t* total_bytes_to_be_received) const = 0;
67 };
68
69 }  // namespace chrome_pdf
70
71 #endif  // PDF_URL_LOADER_WRAPPER_H_