#include "services/network/test/test_url_loader_factory.h"
#include <string_view>
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/test/test_future.h"
#include "net/http/http_status_code.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_request_body.h"
#include "services/network/public/cpp/weak_wrapper_shared_url_loader_factory.h"
#include "services/network/public/mojom/url_loader.mojom.h"
#include "services/network/public/mojom/url_response_head.mojom.h"
#include "services/network/test/test_utils.h"
namespace network {
TestURLLoaderFactory::TestURLLoader::FollowRedirectParams::
FollowRedirectParams() = default;
TestURLLoaderFactory::TestURLLoader::FollowRedirectParams::
~FollowRedirectParams() = default;
TestURLLoaderFactory::TestURLLoader::FollowRedirectParams::FollowRedirectParams(
FollowRedirectParams&& other) = default;
TestURLLoaderFactory::TestURLLoader::FollowRedirectParams&
TestURLLoaderFactory::TestURLLoader::FollowRedirectParams::operator=(
FollowRedirectParams&& other) = default;
TestURLLoaderFactory::TestURLLoader::TestURLLoader(
mojo::PendingReceiver<network::mojom::URLLoader> url_loader_receiver)
: … { … }
TestURLLoaderFactory::TestURLLoader::~TestURLLoader() = default;
void TestURLLoaderFactory::TestURLLoader::FollowRedirect(
const std::vector<std::string>& removed_headers,
const net::HttpRequestHeaders& modified_headers,
const net::HttpRequestHeaders& modified_cors_exempt_headers,
const std::optional<GURL>& new_url) { … }
TestURLLoaderFactory::PendingRequest::PendingRequest() = default;
TestURLLoaderFactory::PendingRequest::~PendingRequest() = default;
TestURLLoaderFactory::PendingRequest::PendingRequest(PendingRequest&& other) =
default;
TestURLLoaderFactory::PendingRequest& TestURLLoaderFactory::PendingRequest::
operator=(PendingRequest&& other) = default;
TestURLLoaderFactory::Response::Response() = default;
TestURLLoaderFactory::Response::~Response() = default;
TestURLLoaderFactory::Response::Response(Response&&) = default;
TestURLLoaderFactory::Response& TestURLLoaderFactory::Response::operator=(
Response&&) = default;
TestURLLoaderFactory::TestURLLoaderFactory(bool observe_loader_requests)
: … { … }
TestURLLoaderFactory::~TestURLLoaderFactory() { … }
void TestURLLoaderFactory::AddResponse(const GURL& url,
mojom::URLResponseHeadPtr head,
std::string_view content,
const URLLoaderCompletionStatus& status,
Redirects redirects,
ResponseProduceFlags flags) { … }
void TestURLLoaderFactory::AddResponse(std::string_view url,
std::string_view content,
net::HttpStatusCode http_status) { … }
bool TestURLLoaderFactory::IsPending(std::string_view url,
const ResourceRequest** request_out) { … }
int TestURLLoaderFactory::NumPending() { … }
TestURLLoaderFactory::PendingRequest* TestURLLoaderFactory::GetPendingRequest(
size_t index) { … }
void TestURLLoaderFactory::ClearResponses() { … }
void TestURLLoaderFactory::SetInterceptor(const Interceptor& interceptor) { … }
void TestURLLoaderFactory::CreateLoaderAndStart(
mojo::PendingReceiver<mojom::URLLoader> receiver,
int32_t request_id,
uint32_t options,
const ResourceRequest& url_request,
mojo::PendingRemote<mojom::URLLoaderClient> client,
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) { … }
void TestURLLoaderFactory::Clone(
mojo::PendingReceiver<mojom::URLLoaderFactory> receiver) { … }
scoped_refptr<network::WeakWrapperSharedURLLoaderFactory>
TestURLLoaderFactory::GetSafeWeakWrapper() { … }
bool TestURLLoaderFactory::CreateLoaderAndStartInternal(
const GURL& url,
mojom::URLLoaderClient* client) { … }
std::optional<network::TestURLLoaderFactory::PendingRequest>
TestURLLoaderFactory::FindPendingRequest(const GURL& url,
ResponseMatchFlags flags) { … }
bool TestURLLoaderFactory::SimulateResponseForPendingRequest(
const GURL& url,
const network::URLLoaderCompletionStatus& completion_status,
mojom::URLResponseHeadPtr response_head,
std::string_view content,
ResponseMatchFlags flags) { … }
bool TestURLLoaderFactory::SimulateResponseForPendingRequest(
std::string_view url,
std::string_view content,
net::HttpStatusCode http_status,
ResponseMatchFlags flags) { … }
void TestURLLoaderFactory::SimulateResponseWithoutRemovingFromPendingList(
PendingRequest* request,
mojom::URLResponseHeadPtr head,
std::string_view content,
const URLLoaderCompletionStatus& completion_status) { … }
void TestURLLoaderFactory::SimulateResponseWithoutRemovingFromPendingList(
PendingRequest* request,
std::string_view content) { … }
void TestURLLoaderFactory::SimulateResponse(
mojom::URLLoaderClient* client,
TestURLLoaderFactory::Redirects redirects,
mojom::URLResponseHeadPtr head,
std::string_view content,
URLLoaderCompletionStatus status,
ResponseProduceFlags response_flags) { … }
}