#include "components/image_fetcher/core/image_data_fetcher.h"
#include <utility>
#include "base/functional/bind.h"
#include "base/not_fatal_until.h"
#include "components/image_fetcher/core/image_fetcher_metrics_reporter.h"
#include "net/base/data_url.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "url/gurl.h"
#include "url/url_constants.h"
namespace {
const char kContentLocationHeader[] = …;
const char kNoUmaClient[] = …;
const int kDownloadTimeoutSeconds = …;
}
namespace image_fetcher {
struct ImageDataFetcher::ImageDataFetcherRequest { … };
ImageDataFetcher::ImageDataFetcher(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: … { … }
ImageDataFetcher::~ImageDataFetcher() { … }
void ImageDataFetcher::SetImageDownloadLimit(
std::optional<int64_t> max_download_bytes) { … }
void ImageDataFetcher::FetchImageData(const GURL& image_url,
ImageDataFetcherCallback callback,
ImageFetcherParams params,
bool send_cookies) { … }
void ImageDataFetcher::FetchImageData(
const GURL& image_url,
ImageDataFetcherCallback callback,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
bool send_cookies) { … }
void ImageDataFetcher::FetchImageData(
const GURL& image_url,
ImageDataFetcherCallback callback,
const std::string& referrer,
net::ReferrerPolicy referrer_policy,
const net::NetworkTrafficAnnotationTag& traffic_annotation,
bool send_cookies) { … }
void ImageDataFetcher::FetchImageData(const GURL& image_url,
ImageDataFetcherCallback callback,
ImageFetcherParams params,
const std::string& referrer,
net::ReferrerPolicy referrer_policy,
bool send_cookies) { … }
void ImageDataFetcher::OnURLLoaderComplete(
const network::SimpleURLLoader* source,
ImageFetcherParams params,
std::unique_ptr<std::string> response_body) { … }
void ImageDataFetcher::FinishRequest(const network::SimpleURLLoader* source,
const RequestMetadata& metadata,
const std::string& image_data) { … }
void ImageDataFetcher::InjectResultForTesting(const RequestMetadata& metadata,
const std::string& image_data) { … }
}