#ifndef CONTENT_COMMON_WEB_UI_LOADING_UTIL_H_
#define CONTENT_COMMON_WEB_UI_LOADING_UTIL_H_
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/types/expected.h"
#include "content/common/content_export.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "net/http/http_byte_range.h"
#include "net/http/http_request_headers.h"
#include "services/network/public/mojom/url_loader.mojom.h"
namespace content {
namespace webui {
enum class GetRequestedRangeError {
kNoRanges,
kMultipleRanges,
kParseFailed,
};
CONTENT_EXPORT void CallOnError(
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
int error_code);
CONTENT_EXPORT base::expected<net::HttpByteRange, GetRequestedRangeError>
GetRequestedRange(const net::HttpRequestHeaders& headers);
CONTENT_EXPORT bool SendData(
network::mojom::URLResponseHeadPtr headers,
mojo::PendingRemote<network::mojom::URLLoaderClient> client_remote,
std::optional<net::HttpByteRange> requested_range,
scoped_refptr<base::RefCountedMemory> bytes);
CONTENT_EXPORT std::pair<mojo::ScopedDataPipeConsumerHandle, size_t> GetPipe(
scoped_refptr<base::RefCountedMemory> bytes,
std::optional<net::HttpByteRange> requested_range);
}
}
#endif