#include "components/trusted_vault/trusted_vault_request.h"
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/time/time.h"
#include "components/signin/public/identity_manager/access_token_info.h"
#include "components/trusted_vault/trusted_vault_access_token_fetcher.h"
#include "components/trusted_vault/trusted_vault_server_constants.h"
#include "google_apis/credentials_mode.h"
#include "google_apis/gaia/core_account_id.h"
#include "net/base/backoff_entry.h"
#include "net/base/url_util.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_status_code.h"
#include "net/traffic_annotation/network_traffic_annotation.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"
namespace trusted_vault {
namespace {
const char kAuthorizationHeader[] = …;
const char kProtobufContentType[] = …;
constexpr net::BackoffEntry::Policy kRetryPolicy = …;
net::NetworkTrafficAnnotationTag CreateTrafficAnnotationTag() { … }
std::string GetHttpMethodString(TrustedVaultRequest::HttpMethod http_method) { … }
TrustedVaultRequest::HttpStatus AccessTokenFetchingErrorToRequestHttpStatus(
TrustedVaultAccessTokenFetcher::FetchingError access_token_error) { … }
}
TrustedVaultRequest::TrustedVaultRequest(
const CoreAccountId& account_id,
HttpMethod http_method,
const GURL& request_url,
const std::optional<std::string>& serialized_request_proto,
base::TimeDelta max_retry_duration,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
std::unique_ptr<TrustedVaultAccessTokenFetcher> access_token_fetcher,
RecordFetchStatusCallback record_fetch_status_callback)
: … { … }
TrustedVaultRequest::~TrustedVaultRequest() = default;
void TrustedVaultRequest::FetchAccessTokenAndSendRequest(
CompletionCallback callback) { … }
void TrustedVaultRequest::OnAccessTokenFetched(
TrustedVaultAccessTokenFetcher::AccessTokenInfoOrError
access_token_info_or_error) { … }
void TrustedVaultRequest::OnURLLoadComplete(
std::unique_ptr<std::string> response_body) { … }
std::unique_ptr<network::SimpleURLLoader> TrustedVaultRequest::CreateURLLoader(
const std::string& access_token) const { … }
bool TrustedVaultRequest::CanRetry() const { … }
void TrustedVaultRequest::ScheduleRetry() { … }
void TrustedVaultRequest::Retry() { … }
void TrustedVaultRequest::RunCompletionCallbackAndMaybeDestroySelf(
HttpStatus status,
const std::string& response_body) { … }
}