#include "content/browser/attribution_reporting/attribution_report_network_sender.h"
#include <optional>
#include <string>
#include <string_view>
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/functional/overloaded.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"
#include "base/values.h"
#include "components/attribution_reporting/suitable_origin.h"
#include "content/browser/attribution_reporting/aggregatable_debug_report.h"
#include "content/browser/attribution_reporting/attribution_debug_report.h"
#include "content/browser/attribution_reporting/attribution_report.h"
#include "content/browser/attribution_reporting/attribution_utils.h"
#include "content/browser/attribution_reporting/send_result.h"
#include "net/base/isolation_info.h"
#include "net/base/load_flags.h"
#include "net/base/net_errors.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/resource_request_body.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/fetch_api.mojom-shared.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "url/gurl.h"
#include "url/origin.h"
namespace content {
namespace {
enum class Status { … };
template <typename T>
void NetworkHistogram(std::string_view suffix,
void (*hist_func)(const std::string&, T value),
bool is_debug_report,
std::optional<bool> has_trigger_context_id,
T value) { … }
}
AttributionReportNetworkSender::AttributionReportNetworkSender(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory)
: … { … }
AttributionReportNetworkSender::~AttributionReportNetworkSender() = default;
void AttributionReportNetworkSender::SendReport(
AttributionReport report,
bool is_debug_report,
ReportSentCallback sent_callback) { … }
void AttributionReportNetworkSender::SendReport(
AttributionDebugReport report,
DebugReportSentCallback callback) { … }
void AttributionReportNetworkSender::SendReport(
AggregatableDebugReport report,
base::Value::Dict report_body,
AggregatableDebugReportSentCallback callback) { … }
void AttributionReportNetworkSender::SendReport(GURL url,
url::Origin origin,
const std::string& body,
UrlLoaderCallback callback) { … }
void AttributionReportNetworkSender::OnReportSent(
const AttributionReport& report,
bool is_debug_report,
ReportSentCallback sent_callback,
UrlLoaderList::iterator it,
scoped_refptr<net::HttpResponseHeaders> headers) { … }
void AttributionReportNetworkSender::OnVerboseDebugReportSent(
base::OnceCallback<void(int status)> callback,
UrlLoaderList::iterator it,
scoped_refptr<net::HttpResponseHeaders> headers) { … }
void AttributionReportNetworkSender::OnAggregatableDebugReportSent(
base::OnceCallback<void(int status)> callback,
UrlLoaderList::iterator it,
scoped_refptr<net::HttpResponseHeaders> headers) { … }
}