#if defined(UNSAFE_BUFFERS_BUILD)
#pragma allow_unsafe_buffers
#endif
#include "pdf/loader/url_loader_wrapper_impl.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <memory>
#include <string>
#include <string_view>
#include <utility>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "net/http/http_util.h"
#include "pdf/loader/url_loader.h"
#include "ui/gfx/range/range.h"
namespace chrome_pdf {
namespace {
constexpr base::TimeDelta kReadDelayMs = …;
UrlRequest MakeRangeRequest(const std::string& url,
const std::string& referrer_url,
uint32_t position,
uint32_t size) { … }
bool GetByteRangeFromStr(const std::string& content_range_str,
int* start,
int* end) { … }
bool GetByteRangeFromHeaders(const std::string& headers, int* start, int* end) { … }
bool IsDoubleEndLineAtEnd(const char* buffer, int size) { … }
}
URLLoaderWrapperImpl::URLLoaderWrapperImpl(
std::unique_ptr<UrlLoader> url_loader)
: … { … }
URLLoaderWrapperImpl::~URLLoaderWrapperImpl() { … }
int URLLoaderWrapperImpl::GetContentLength() const { … }
bool URLLoaderWrapperImpl::IsAcceptRangesBytes() const { … }
bool URLLoaderWrapperImpl::IsContentEncoded() const { … }
std::string URLLoaderWrapperImpl::GetContentType() const { … }
std::string URLLoaderWrapperImpl::GetContentDisposition() const { … }
int URLLoaderWrapperImpl::GetStatusCode() const { … }
bool URLLoaderWrapperImpl::IsMultipart() const { … }
bool URLLoaderWrapperImpl::GetByteRangeStart(int* start) const { … }
void URLLoaderWrapperImpl::Close() { … }
void URLLoaderWrapperImpl::OpenRange(const std::string& url,
const std::string& referrer_url,
uint32_t position,
uint32_t size,
base::OnceCallback<void(int)> callback) { … }
void URLLoaderWrapperImpl::ReadResponseBody(
base::span<char> buffer,
base::OnceCallback<void(int)> callback) { … }
void URLLoaderWrapperImpl::ReadResponseBodyImpl(
base::OnceCallback<void(int)> callback) { … }
void URLLoaderWrapperImpl::ParseHeaders(const std::string& response_headers) { … }
void URLLoaderWrapperImpl::DidOpen(base::OnceCallback<void(int)> callback,
int32_t result) { … }
void URLLoaderWrapperImpl::DidRead(base::OnceCallback<void(int)> callback,
int32_t result) { … }
void URLLoaderWrapperImpl::SetHeadersFromLoader() { … }
}