url_loader_wrapper.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. #ifndef PDF_URL_LOADER_WRAPPER_H_
  5. #define PDF_URL_LOADER_WRAPPER_H_
  6. #include <stdint.h>
  7. #include <string>
  8. #include "base/callback_forward.h"
  9. namespace chrome_pdf {
  10. class URLLoaderWrapper {
  11. public:
  12. virtual ~URLLoaderWrapper() {}
  13. // Returns length of content, will be -1, if it is unknown.
  14. virtual int GetContentLength() const = 0;
  15. // Returns if the response headers contains "accept-ranges".
  16. virtual bool IsAcceptRangesBytes() const = 0;
  17. // Returns if the content encoded in response.
  18. virtual bool IsContentEncoded() const = 0;
  19. // Returns response content type.
  20. virtual std::string GetContentType() const = 0;
  21. // Returns response content disposition.
  22. virtual std::string GetContentDisposition() const = 0;
  23. // Returns response status code.
  24. virtual int GetStatusCode() const = 0;
  25. // Returns if the response contains multi parts.
  26. virtual bool IsMultipart() const = 0;
  27. // If true, `start` contains the start of the byte range.
  28. // If false, response contains full document and `start` will be undefined.
  29. virtual bool GetByteRangeStart(int* start) const = 0;
  30. // Close connection.
  31. virtual void Close() = 0;
  32. // Open new connection and send http range request.
  33. virtual void OpenRange(const std::string& url,
  34. const std::string& referrer_url,
  35. uint32_t position,
  36. uint32_t size,
  37. base::OnceCallback<void(int)> callback) = 0;
  38. // Read the response body. The size of the buffer must be large enough to
  39. // hold the specified number of bytes to read.
  40. // This function might perform a partial read.
  41. virtual void ReadResponseBody(char* buffer,
  42. int buffer_size,
  43. base::OnceCallback<void(int)> callback) = 0;
  44. };
  45. } // namespace chrome_pdf
  46. #endif // PDF_URL_LOADER_WRAPPER_H_