Skip to content

Commit

Permalink
[FLEDGE] Move prev_wins update code to InterestGroupAuctionReporter.
Browse files Browse the repository at this point in the history
This both allows it to be updated immediately upon navigation, instead
of only after reporting scripts have run, and separates it more from
the frame-scoped AdAuctionServiceImpl class.

Bug: 1410791
Change-Id: If55f2058b73a3f4c3ad45b339f854ca6c8b5149d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4215632
Reviewed-by: Maks Orlovich <morlovich@chromium.org>
Commit-Queue: Matt Menke <mmenke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1101005}
  • Loading branch information
Matt Menke authored and Chromium LUCI CQ committed Feb 3, 2023
1 parent 238548c commit 0451308
Show file tree
Hide file tree
Showing 13 changed files with 186 additions and 136 deletions.
16 changes: 3 additions & 13 deletions content/browser/interest_group/ad_auction_service_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,12 @@ void SendSuccessfulAuctionReportsAndUpdateInterestGroups(
PrivateAggregationManager* private_aggregation_manager,
InterestGroupManagerImpl* interest_group_manager,
const url::Origin& main_frame_origin,
const blink::InterestGroupKey& winning_group_key,
const std::string& winning_group_ad_metadata,
std::map<url::Origin,
std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr>>
private_aggregation_requests,
base::flat_set<std::string> k_anon_keys_to_join) {
DCHECK(interest_group_manager);

interest_group_manager->RecordInterestGroupWin(winning_group_key,
winning_group_ad_metadata);
interest_group_manager->RegisterAdKeysAsJoined(
std::move(k_anon_keys_to_join));

Expand Down Expand Up @@ -590,7 +586,6 @@ void AdAuctionServiceImpl::OnAuctionComplete(
absl::optional<blink::InterestGroupKey> winning_group_key,
absl::optional<GURL> render_url,
std::vector<GURL> ad_component_urls,
std::string winning_group_ad_metadata,
std::map<url::Origin,
std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr>>
private_aggregation_requests,
Expand Down Expand Up @@ -627,7 +622,6 @@ void AdAuctionServiceImpl::OnAuctionComplete(
std::move(k_anon_keys_to_join));
}

DCHECK(winning_group_ad_metadata.empty());
std::move(callback).Run(manually_aborted, /*config=*/absl::nullopt);
if (auction_result_metrics) {
// `auction_result_metrics` can be null since PageUserData like
Expand All @@ -647,7 +641,6 @@ void AdAuctionServiceImpl::OnAuctionComplete(
DCHECK(private_aggregation_requests.empty());
// Should always be present with a render_url.
DCHECK(winning_group_key);
DCHECK(!winning_group_ad_metadata.empty());
DCHECK(blink::IsValidFencedFrameURL(*render_url));
DCHECK(urn_uuid.is_valid());

Expand Down Expand Up @@ -681,8 +674,7 @@ void AdAuctionServiceImpl::OnAuctionComplete(
reporters_.emplace_front(std::move(reporter));
reporters_.front()->Start(base::BindOnce(
&AdAuctionServiceImpl::OnReporterComplete, base::Unretained(this),
reporters_.begin(), std::move(urn_uuid), std::move(*winning_group_key),
std::move(winning_group_ad_metadata), std::move(fenced_frame_reporter),
reporters_.begin(), std::move(urn_uuid), std::move(fenced_frame_reporter),
std::move(k_anon_keys_to_join)));
if (auction_result_metrics) {
auction_result_metrics->ReportAuctionResult(
Expand All @@ -693,8 +685,6 @@ void AdAuctionServiceImpl::OnAuctionComplete(
void AdAuctionServiceImpl::OnReporterComplete(
ReporterList::iterator reporter_it,
GURL urn_uuid,
blink::InterestGroupKey winning_group_key,
std::string winning_group_ad_metadata,
scoped_refptr<FencedFrameReporter> fenced_frame_reporter,
base::flat_set<std::string> k_anon_keys_to_join) {
// Forward debug information to devtools.
Expand Down Expand Up @@ -726,8 +716,8 @@ void AdAuctionServiceImpl::OnReporterComplete(
// another issue).
SendSuccessfulAuctionReportsAndUpdateInterestGroups(
private_aggregation_manager_, &GetInterestGroupManager(),
main_frame_origin_, winning_group_key, winning_group_ad_metadata,
std::move(private_aggregation_requests), std::move(k_anon_keys_to_join));
main_frame_origin_, std::move(private_aggregation_requests),
std::move(k_anon_keys_to_join));

// Pass reporting map to the FencedFrameReporter.
// TODO(mmenke): move this into InterestGroupReporter.
Expand Down
3 changes: 0 additions & 3 deletions content/browser/interest_group/ad_auction_service_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ class CONTENT_EXPORT AdAuctionServiceImpl final
absl::optional<blink::InterestGroupKey> winning_group_key,
absl::optional<GURL> render_url,
std::vector<GURL> ad_component_urls,
std::string winning_group_ad_metadata,
std::map<
url::Origin,
std::vector<auction_worklet::mojom::PrivateAggregationRequestPtr>>
Expand All @@ -139,8 +138,6 @@ class CONTENT_EXPORT AdAuctionServiceImpl final
void OnReporterComplete(
ReporterList::iterator reporter_it,
GURL urn_uuid,
blink::InterestGroupKey winning_group_key,
std::string winning_group_ad_metadata,
scoped_refptr<FencedFrameReporter> fenced_frame_reporter,
base::flat_set<std::string> k_anon_keys_to_join);

Expand Down
15 changes: 0 additions & 15 deletions content/browser/interest_group/auction_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ void AuctionRunner::FailAuction(
/*winning_group_key=*/absl::nullopt,
/*render_url=*/absl::nullopt,
/*ad_component_urls=*/{},
/*winning_group_ad_metadata=*/std::string(),
auction_.TakePrivateAggregationRequests(),
auction_.GetKAnonKeysToJoin(), auction_.TakeErrors(),
/*reporter=*/nullptr);
Expand Down Expand Up @@ -278,19 +277,6 @@ void AuctionRunner::OnBidsGeneratedAndScored(bool success) {
return;
}

std::string winning_group_ad_metadata;
if (auction_.top_bid()->bid->bid_ad->metadata) {
//`metadata` is already in JSON so no quotes are needed.
winning_group_ad_metadata = base::StringPrintf(
R"({"render_url":"%s","metadata":%s})",
auction_.top_bid()->bid->render_url.spec().c_str(),
auction_.top_bid()->bid->bid_ad->metadata.value().c_str());
} else {
winning_group_ad_metadata =
base::StringPrintf(R"({"render_url":"%s"})",
auction_.top_bid()->bid->render_url.spec().c_str());
}

DCHECK(auction_.top_bid()->bid->interest_group);
const blink::InterestGroup& winning_group =
*auction_.top_bid()->bid->interest_group;
Expand All @@ -313,7 +299,6 @@ void AuctionRunner::OnBidsGeneratedAndScored(bool success) {
this, /*manually_aborted=*/false, std::move(winning_group_key),
auction_.top_bid()->bid->render_url,
auction_.top_bid()->bid->ad_components,
std::move(winning_group_ad_metadata),
// In this case, the reporter has all the private aggregation requests.
std::map<url::Origin, PrivateAggregationRequests>(),
auction_.GetKAnonKeysToJoin(), std::move(errors), std::move(reporter));
Expand Down
5 changes: 0 additions & 5 deletions content/browser/interest_group/auction_runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ class CONTENT_EXPORT AuctionRunner : public blink::mojom::AbortableAdAuction {
// `ad_component_urls` is the list of ad component URLs returned by the
// winning bidder. Null if there is no winner or no list was returned.
//
// `winning_group_ad_metadata` is the metadata associated with the winning ad,
// to be made available to the interest group in future auctions in the
// `prevWins` field. Empty if there was no winner.
//
// `report_urls` Reporting URLs returned by seller worklet reportResult()
// methods and the winning bidder's reportWin() methods, if any.
//
Expand All @@ -88,7 +84,6 @@ class CONTENT_EXPORT AuctionRunner : public blink::mojom::AbortableAdAuction {
absl::optional<blink::InterestGroupKey> winning_group_id,
absl::optional<GURL> render_url,
std::vector<GURL> ad_component_urls,
std::string winning_group_ad_metadata,
std::map<url::Origin, PrivateAggregationRequests>
private_aggregation_requests,
base::flat_set<std::string> k_anon_keys_to_join,
Expand Down

0 comments on commit 0451308

Please sign in to comment.