0

Change owner to entry

Change instances of Owner to Entry in FirstPartySetsManager and related
files to reflect the change of FirstPartySetsManager::FindOwners, which
now returns the full FirstPartySetEntries, not just owner domains

Bug: 1360890
Change-Id: Iefb71afbba805a3b222237ec4ade90a37c3868b8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3879927
Reviewed-by: Chris Fredrickson <cfredric@chromium.org>
Reviewed-by: Dylan Cutler <dylancutler@google.com>
Commit-Queue: Sam LeDoux <sledoux@google.com>
Cr-Commit-Position: refs/heads/main@{#1046902}
This commit is contained in:
Sam LeDoux
2022-09-14 15:18:48 +00:00
committed by Chromium LUCI CQ
parent 2ce3fcd3e5
commit dde1ba29cf
15 changed files with 114 additions and 119 deletions

@ -48,7 +48,7 @@ CookieAccessDelegate::FirstPartySetifyPartitionKey(
}
absl::optional<base::flat_map<net::SchemefulSite, FirstPartySetEntry>>
maybe_entries = delegate->FindFirstPartySetOwners(
maybe_entries = delegate->FindFirstPartySetEntries(
{cookie_partition_key.site()},
base::BindOnce(&CreateCookiePartitionKeyFromFirstPartySetEntry,
cookie_partition_key)

@ -78,7 +78,7 @@ class NET_EXPORT CookieAccessDelegate {
// not both, and not neither.
[[nodiscard]] virtual absl::optional<
base::flat_map<net::SchemefulSite, net::FirstPartySetEntry>>
FindFirstPartySetOwners(
FindFirstPartySetEntries(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<
void(base::flat_map<net::SchemefulSite, net::FirstPartySetEntry>)>

@ -2263,7 +2263,7 @@ bool CookieMonster::DoRecordPeriodicStats() {
}
}
absl::optional<base::flat_map<SchemefulSite, FirstPartySetEntry>>
maybe_sets = cookie_access_delegate()->FindFirstPartySetOwners(
maybe_sets = cookie_access_delegate()->FindFirstPartySetEntries(
sites,
base::BindOnce(&CookieMonster::RecordPeriodicFirstPartySetsStats,
weak_ptr_factory_.GetWeakPtr()));

@ -82,7 +82,7 @@ CookiePartitionKeyCollection::FirstPartySetify(
if (sites.empty())
return *this;
absl::optional<base::flat_map<SchemefulSite, FirstPartySetEntry>>
maybe_sites_to_entries = cookie_access_delegate->FindFirstPartySetOwners(
maybe_sites_to_entries = cookie_access_delegate->FindFirstPartySetEntries(
sites,
base::BindOnce(&TransformWithFirstPartySetEntries, PartitionKeys())
.Then(std::move(callback)));

@ -56,18 +56,16 @@ TestCookieAccessDelegate::ComputeFirstPartySetMetadataMaybeAsync(
const std::set<SchemefulSite>& party_context,
base::OnceCallback<void(FirstPartySetMetadata)> callback) const {
absl::optional<FirstPartySetEntry> top_frame_owner =
top_frame_site ? FindFirstPartySetOwnerSync(*top_frame_site)
: absl::nullopt;
top_frame_site ? FindFirstPartySetEntry(*top_frame_site) : absl::nullopt;
return RunMaybeAsync(
FirstPartySetMetadata(
SamePartyContext(),
base::OptionalToPtr(FindFirstPartySetOwnerSync(site)),
base::OptionalToPtr(top_frame_owner)),
FirstPartySetMetadata(SamePartyContext(),
base::OptionalToPtr(FindFirstPartySetEntry(site)),
base::OptionalToPtr(top_frame_owner)),
std::move(callback));
}
absl::optional<FirstPartySetEntry>
TestCookieAccessDelegate::FindFirstPartySetOwnerSync(
TestCookieAccessDelegate::FindFirstPartySetEntry(
const SchemefulSite& site) const {
auto entry = first_party_sets_.find(site);
@ -76,13 +74,13 @@ TestCookieAccessDelegate::FindFirstPartySetOwnerSync(
}
absl::optional<base::flat_map<SchemefulSite, FirstPartySetEntry>>
TestCookieAccessDelegate::FindFirstPartySetOwners(
TestCookieAccessDelegate::FindFirstPartySetEntries(
const base::flat_set<SchemefulSite>& sites,
base::OnceCallback<void(base::flat_map<SchemefulSite, FirstPartySetEntry>)>
callback) const {
std::vector<std::pair<SchemefulSite, FirstPartySetEntry>> mapping;
for (const SchemefulSite& site : sites) {
absl::optional<FirstPartySetEntry> entry = FindFirstPartySetOwnerSync(site);
absl::optional<FirstPartySetEntry> entry = FindFirstPartySetEntry(site);
if (entry)
mapping.emplace_back(site, *entry);
}

@ -47,7 +47,7 @@ class TestCookieAccessDelegate : public CookieAccessDelegate {
const std::set<SchemefulSite>& party_context,
base::OnceCallback<void(FirstPartySetMetadata)> callback) const override;
absl::optional<base::flat_map<SchemefulSite, FirstPartySetEntry>>
FindFirstPartySetOwners(
FindFirstPartySetEntries(
const base::flat_set<SchemefulSite>& sites,
base::OnceCallback<
void(base::flat_map<SchemefulSite, FirstPartySetEntry>)> callback)
@ -67,7 +67,7 @@ class TestCookieAccessDelegate : public CookieAccessDelegate {
bool require_secure_origin);
// Set the test delegate's First-Party Sets. The map's keys are the sites in
// the sets. Owner sites must be included among the keys for a given set.
// the sets. Primary sites must be included among the keys for a given set.
void SetFirstPartySets(
const base::flat_map<SchemefulSite, FirstPartySetEntry>& sets);
@ -76,8 +76,8 @@ class TestCookieAccessDelegate : public CookieAccessDelegate {
}
private:
// Synchronous version of FindFirstPartySetOwner, for convenience.
absl::optional<FirstPartySetEntry> FindFirstPartySetOwnerSync(
// Finds a FirstPartySetEntry for the given site, if one exists.
absl::optional<FirstPartySetEntry> FindFirstPartySetEntry(
const SchemefulSite& site) const;
// Discard any leading dot in the domain string.

@ -72,15 +72,15 @@ CookieAccessDelegateImpl::ComputeFirstPartySetMetadataMaybeAsync(
site, top_frame_site, party_context, std::move(callback));
}
absl::optional<FirstPartySetsAccessDelegate::OwnersResult>
CookieAccessDelegateImpl::FindFirstPartySetOwners(
absl::optional<FirstPartySetsAccessDelegate::EntriesResult>
CookieAccessDelegateImpl::FindFirstPartySetEntries(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>
callback) const {
if (!first_party_sets_access_delegate_)
return {{}};
return first_party_sets_access_delegate_->FindOwners(sites,
std::move(callback));
return first_party_sets_access_delegate_->FindEntries(sites,
std::move(callback));
}
} // namespace network

@ -62,10 +62,10 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieAccessDelegateImpl
const std::set<net::SchemefulSite>& party_context,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback)
const override;
[[nodiscard]] absl::optional<FirstPartySetsAccessDelegate::OwnersResult>
FindFirstPartySetOwners(
[[nodiscard]] absl::optional<FirstPartySetsAccessDelegate::EntriesResult>
FindFirstPartySetEntries(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>
callback) const override;
private:

@ -53,9 +53,9 @@ TEST_F(CookieAccessDelegateImplTest, NullFirstPartySetsManager) {
Optional(std::ref(expected_metadata)));
EXPECT_THAT(
delegate().FindFirstPartySetOwners(
delegate().FindFirstPartySetEntries(
{site},
base::BindOnce([](FirstPartySetsManager::OwnersResult) { FAIL(); })),
base::BindOnce([](FirstPartySetsManager::EntriesResult) { FAIL(); })),
Optional(IsEmpty()));
}

@ -71,10 +71,10 @@ FirstPartySetsAccessDelegate::ComputeMetadata(
context_config_, std::move(callback));
}
absl::optional<FirstPartySetsAccessDelegate::OwnersResult>
FirstPartySetsAccessDelegate::FindOwners(
absl::optional<FirstPartySetsAccessDelegate::EntriesResult>
FirstPartySetsAccessDelegate::FindEntries(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>
callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@ -86,12 +86,12 @@ FirstPartySetsAccessDelegate::FindOwners(
// `pending_queries_` will not run the enqueued callbacks after `this` is
// destroyed.
EnqueuePendingQuery(
base::BindOnce(&FirstPartySetsAccessDelegate::FindOwnersAndInvoke,
base::BindOnce(&FirstPartySetsAccessDelegate::FindEntriesAndInvoke,
base::Unretained(this), sites, std::move(callback)));
return absl::nullopt;
}
return manager_->FindOwners(sites, context_config_, std::move(callback));
return manager_->FindEntries(sites, context_config_, std::move(callback));
}
void FirstPartySetsAccessDelegate::ComputeMetadataAndInvoke(
@ -115,20 +115,20 @@ void FirstPartySetsAccessDelegate::ComputeMetadataAndInvoke(
std::move(callbacks.second).Run(std::move(sync_result.value()));
}
void FirstPartySetsAccessDelegate::FindOwnersAndInvoke(
void FirstPartySetsAccessDelegate::FindEntriesAndInvoke(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>
callback) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(enabled_);
std::pair<
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>,
base::OnceCallback<void(FirstPartySetsAccessDelegate::OwnersResult)>>
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>,
base::OnceCallback<void(FirstPartySetsAccessDelegate::EntriesResult)>>
callbacks = base::SplitOnceCallback(std::move(callback));
absl::optional<FirstPartySetsAccessDelegate::OwnersResult> sync_result =
manager_->FindOwners(sites, context_config_, std::move(callbacks.first));
absl::optional<FirstPartySetsAccessDelegate::EntriesResult> sync_result =
manager_->FindEntries(sites, context_config_, std::move(callbacks.first));
if (sync_result.has_value())
std::move(callbacks.second).Run(sync_result.value());

@ -31,7 +31,7 @@ namespace network {
class FirstPartySetsAccessDelegate
: public mojom::FirstPartySetsAccessDelegate {
public:
using OwnersResult = FirstPartySetsManager::OwnersResult;
using EntriesResult = FirstPartySetsManager::EntriesResult;
using FlattenedSets = FirstPartySetsManager::FlattenedSets;
// Construct a FirstPartySetsAccessDelegate that provides customizations
@ -68,21 +68,16 @@ class FirstPartySetsAccessDelegate
const std::set<net::SchemefulSite>& party_context,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback);
// Batched version of `FindOwner`. Returns the mapping of sites to owners for
// the given input sites (if an owner exists).
//
// When FPS is disabled, returns an empty map.
// When FPS is enabled, this maps each input site to its owner (if one
// exists), and returns the resulting mapping. If a site isn't in a
// non-trivial First-Party Set, it is not added to the output map.
// Calls FirstPartySetsManager::FindEntries either asynchronously or
// synchronously, once initialization is complete.
//
// This may return a result synchronously, or asynchronously invoke `callback`
// with the result. The callback will be invoked iff the return value is
// nullopt; i.e. a result will be provided via return value or callback, but
// not both, and not neither.
[[nodiscard]] absl::optional<OwnersResult> FindOwners(
[[nodiscard]] absl::optional<EntriesResult> FindEntries(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(OwnersResult)> callback);
base::OnceCallback<void(EntriesResult)> callback);
private:
// Same as `ComputeMetadata`, but plumbs the result into the callback. Must
@ -93,11 +88,11 @@ class FirstPartySetsAccessDelegate
const std::set<net::SchemefulSite>& party_context,
base::OnceCallback<void(net::FirstPartySetMetadata)> callback) const;
// Same as `FindOwners`, but plumbs the result into the callback. Must only be
// called once the instance is fully initialized.
void FindOwnersAndInvoke(
// Same as `FindEntries`, but plumbs the result into the callback. Must only
// be called once the instance is fully initialized.
void FindEntriesAndInvoke(
const base::flat_set<net::SchemefulSite>& sites,
base::OnceCallback<void(OwnersResult)> callback) const;
base::OnceCallback<void(EntriesResult)> callback) const;
// Runs all pending queries. Must not be called until the instance is fully
// initialized.

@ -111,10 +111,11 @@ TEST_F(NoopFirstPartySetsAccessDelegateTest, ComputeMetadata) {
net::SamePartyContext(Type::kSameParty));
}
TEST_F(NoopFirstPartySetsAccessDelegateTest, FindOwners) {
TEST_F(NoopFirstPartySetsAccessDelegateTest, FindEntries) {
EXPECT_THAT(
delegate().FindOwners({kSet1Member1, kSet2Member1}, base::NullCallback()),
FirstPartySetsAccessDelegate::OwnersResult({
delegate().FindEntries({kSet1Member1, kSet2Member1},
base::NullCallback()),
FirstPartySetsAccessDelegate::EntriesResult({
{kSet1Member1,
net::FirstPartySetEntry(kSet1Owner, net::SiteType::kAssociated, 0)},
{kSet2Member1,
@ -159,11 +160,11 @@ class FirstPartySetsAccessDelegateTest : public ::testing::Test {
return result.has_value() ? std::move(result).value() : future.Take();
}
FirstPartySetsAccessDelegate::OwnersResult FindOwnersAndWait(
FirstPartySetsAccessDelegate::EntriesResult FindEntriesAndWait(
const base::flat_set<net::SchemefulSite>& site) {
base::test::TestFuture<FirstPartySetsAccessDelegate::OwnersResult> future;
absl::optional<FirstPartySetsAccessDelegate::OwnersResult> result =
delegate_.FindOwners(site, future.GetCallback());
base::test::TestFuture<FirstPartySetsAccessDelegate::EntriesResult> future;
absl::optional<FirstPartySetsAccessDelegate::EntriesResult> result =
delegate_.FindEntries(site, future.GetCallback());
return result.has_value() ? result.value() : future.Get();
}
@ -201,11 +202,11 @@ TEST_F(FirstPartySetsAccessDelegateDisabledTest, ComputeMetadata) {
Optional(std::ref(expected_metadata)));
}
TEST_F(FirstPartySetsAccessDelegateDisabledTest, FindOwners) {
TEST_F(FirstPartySetsAccessDelegateDisabledTest, FindEntries) {
EXPECT_THAT(
delegate().FindOwners(
delegate().FindEntries(
{kSet1Member1, kSet2Member1},
base::BindOnce([](FirstPartySetsManager::OwnersResult) { FAIL(); })),
base::BindOnce([](FirstPartySetsManager::EntriesResult) { FAIL(); })),
Optional(IsEmpty()));
}
@ -236,16 +237,16 @@ TEST_F(AsyncFirstPartySetsAccessDelegateTest,
&entry, &entry));
}
TEST_F(AsyncFirstPartySetsAccessDelegateTest, QueryBeforeReady_FindOwners) {
base::test::TestFuture<FirstPartySetsAccessDelegate::OwnersResult> future;
EXPECT_FALSE(delegate().FindOwners({kSet1Member1, kSet2Member1},
future.GetCallback()));
TEST_F(AsyncFirstPartySetsAccessDelegateTest, QueryBeforeReady_FindEntries) {
base::test::TestFuture<FirstPartySetsAccessDelegate::EntriesResult> future;
EXPECT_FALSE(delegate().FindEntries({kSet1Member1, kSet2Member1},
future.GetCallback()));
delegate_remote()->NotifyReady(mojom::FirstPartySetsReadyEvent::New());
EXPECT_THAT(
future.Get(),
FirstPartySetsAccessDelegate::OwnersResult({
FirstPartySetsAccessDelegate::EntriesResult({
{kSet1Member1,
net::FirstPartySetEntry(kSet1Owner, net::SiteType::kAssociated, 0)},
{kSet2Member1,
@ -271,14 +272,14 @@ TEST_F(AsyncFirstPartySetsAccessDelegateTest, OverrideSets_ComputeMetadata) {
&primary_entry, &associated_entry));
}
TEST_F(AsyncFirstPartySetsAccessDelegateTest, OverrideSets_FindOwners) {
TEST_F(AsyncFirstPartySetsAccessDelegateTest, OverrideSets_FindEntries) {
delegate_remote()->NotifyReady(CreateFirstPartySetsReadyEvent({
{kSet3Owner,
{net::FirstPartySetEntry(kSet3Owner, net::SiteType::kPrimary,
absl::nullopt)}},
}));
EXPECT_THAT(FindOwnersAndWait({kSet3Owner}),
EXPECT_THAT(FindEntriesAndWait({kSet3Owner}),
UnorderedElementsAre(Pair(kSet3Owner, _)));
}
@ -303,10 +304,10 @@ TEST_F(SyncFirstPartySetsAccessDelegateTest, ComputeMetadata) {
&entry, &entry));
}
TEST_F(SyncFirstPartySetsAccessDelegateTest, FindOwners) {
TEST_F(SyncFirstPartySetsAccessDelegateTest, FindEntries) {
EXPECT_THAT(
FindOwnersAndWait({kSet1Member1, kSet2Member1, kSet3Member1}),
FirstPartySetsAccessDelegate::OwnersResult({
FindEntriesAndWait({kSet1Member1, kSet2Member1, kSet3Member1}),
FirstPartySetsAccessDelegate::EntriesResult({
{kSet1Member1,
net::FirstPartySetEntry(kSet1Owner, net::SiteType::kAssociated, 0)},
{kSet2Member1,

@ -137,13 +137,13 @@ net::FirstPartySetMetadata FirstPartySetsManager::ComputeMetadataInternal(
"Cookie.FirstPartySets.ComputeContext.Latency", timer.Elapsed(),
base::Microseconds(1), base::Milliseconds(100), 50);
absl::optional<net::FirstPartySetEntry> top_frame_owner =
absl::optional<net::FirstPartySetEntry> top_frame_entry =
top_frame_site ? FindEntry(*top_frame_site, fps_context_config)
: absl::nullopt;
return net::FirstPartySetMetadata(
context, base::OptionalToPtr(FindEntry(site, fps_context_config)),
base::OptionalToPtr(top_frame_owner));
base::OptionalToPtr(top_frame_entry));
}
absl::optional<net::FirstPartySetEntry> FirstPartySetsManager::FindEntry(
@ -163,27 +163,28 @@ absl::optional<net::FirstPartySetEntry> FirstPartySetsManager::FindEntry(
return entry;
}
absl::optional<FirstPartySetsManager::OwnersResult>
FirstPartySetsManager::FindOwners(
absl::optional<FirstPartySetsManager::EntriesResult>
FirstPartySetsManager::FindEntries(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config,
base::OnceCallback<void(FirstPartySetsManager::OwnersResult)> callback) {
base::OnceCallback<void(FirstPartySetsManager::EntriesResult)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (!sets_.has_value()) {
EnqueuePendingQuery(base::BindOnce(
&FirstPartySetsManager::FindOwnersAndInvoke, weak_factory_.GetWeakPtr(),
sites, fps_context_config, std::move(callback), base::ElapsedTimer()));
EnqueuePendingQuery(
base::BindOnce(&FirstPartySetsManager::FindEntriesAndInvoke,
weak_factory_.GetWeakPtr(), sites, fps_context_config,
std::move(callback), base::ElapsedTimer()));
return absl::nullopt;
}
return FindOwnersInternal(sites, fps_context_config);
return FindEntriesInternal(sites, fps_context_config);
}
void FirstPartySetsManager::FindOwnersAndInvoke(
void FirstPartySetsManager::FindEntriesAndInvoke(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config,
base::OnceCallback<void(FirstPartySetsManager::OwnersResult)> callback,
base::OnceCallback<void(FirstPartySetsManager::EntriesResult)> callback,
base::ElapsedTimer timer) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(sets_.has_value());
@ -191,10 +192,10 @@ void FirstPartySetsManager::FindOwnersAndInvoke(
UMA_HISTOGRAM_TIMES("Cookie.FirstPartySets.EnqueueingDelay.FindOwners",
timer.Elapsed());
std::move(callback).Run(FindOwnersInternal(sites, fps_context_config));
std::move(callback).Run(FindEntriesInternal(sites, fps_context_config));
}
FirstPartySetsManager::OwnersResult FirstPartySetsManager::FindOwnersInternal(
FirstPartySetsManager::EntriesResult FirstPartySetsManager::FindEntriesInternal(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config) const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);

@ -30,7 +30,7 @@ namespace network {
// answers queries about First-Party Sets after they've been loaded.
class FirstPartySetsManager {
public:
using OwnersResult =
using EntriesResult =
base::flat_map<net::SchemefulSite, net::FirstPartySetEntry>;
using FlattenedSets =
base::flat_map<net::SchemefulSite, net::FirstPartySetEntry>;
@ -80,10 +80,10 @@ class FirstPartySetsManager {
// with the result. The callback will be invoked iff the return value is
// nullopt; i.e. a result will be provided via return value or callback, but
// not both, and not neither.
[[nodiscard]] absl::optional<OwnersResult> FindOwners(
[[nodiscard]] absl::optional<EntriesResult> FindEntries(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config,
base::OnceCallback<void(OwnersResult)> callback);
base::OnceCallback<void(EntriesResult)> callback);
private:
// Same as `ComputeMetadata`, but plumbs the result into the callback. Must
@ -125,17 +125,17 @@ class FirstPartySetsManager {
const net::SchemefulSite& site,
const net::FirstPartySetsContextConfig& fps_context_config) const;
// Same as `FindOwners`, but plumbs the result into the callback. Must only be
// called once the instance is fully initialized.
void FindOwnersAndInvoke(
// Same as `FindEntries`, but plumbs the result into the callback. Must only
// be called once the instance is fully initialized.
void FindEntriesAndInvoke(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config,
base::OnceCallback<void(OwnersResult)> callback,
base::OnceCallback<void(EntriesResult)> callback,
base::ElapsedTimer timer) const;
// Synchronous version of `FindOwners`, to be run only once the instance is
// Synchronous version of `FindEntries`, to be run only once the instance is
// initialized.
OwnersResult FindOwnersInternal(
EntriesResult FindEntriesInternal(
const base::flat_set<net::SchemefulSite>& sites,
const net::FirstPartySetsContextConfig& fps_context_config) const;

@ -60,11 +60,11 @@ class FirstPartySetsManagerTest : public ::testing::Test {
return result.has_value() ? std::move(result).value() : future.Take();
}
FirstPartySetsManager::OwnersResult FindOwnersAndWait(
FirstPartySetsManager::EntriesResult FindEntriesAndWait(
const base::flat_set<net::SchemefulSite>& site) {
base::test::TestFuture<FirstPartySetsManager::OwnersResult> future;
absl::optional<FirstPartySetsManager::OwnersResult> result =
manager_.FindOwners(site, fps_context_config_, future.GetCallback());
base::test::TestFuture<FirstPartySetsManager::EntriesResult> future;
absl::optional<FirstPartySetsManager::EntriesResult> result =
manager_.FindEntries(site, fps_context_config_, future.GetCallback());
return result.has_value() ? result.value() : future.Get();
}
@ -105,7 +105,7 @@ TEST_F(FirstPartySetsManagerDisabledTest, SetCompleteSets) {
example_test, net::SiteType::kPrimary, absl::nullopt)}},
{{example_cctld, example_test}});
EXPECT_THAT(FindOwnersAndWait({
EXPECT_THAT(FindEntriesAndWait({
aaaa,
example_test,
example_cctld,
@ -113,11 +113,11 @@ TEST_F(FirstPartySetsManagerDisabledTest, SetCompleteSets) {
IsEmpty());
}
TEST_F(FirstPartySetsManagerDisabledTest, FindOwners) {
TEST_F(FirstPartySetsManagerDisabledTest, FindEntries) {
net::SchemefulSite kExample =
net::SchemefulSite(GURL("https://example.test"));
EXPECT_THAT(FindOwnersAndWait({kExample}), IsEmpty());
EXPECT_THAT(FindEntriesAndWait({kExample}), IsEmpty());
}
TEST_F(FirstPartySetsManagerDisabledTest, ComputeMetadata_InfersSingletons) {
@ -168,7 +168,7 @@ TEST_F(FirstPartySetsEnabledTest, SetCompleteSets) {
{{example_cctld, example_test}});
EXPECT_THAT(
FindOwnersAndWait({
FindEntriesAndWait({
aaaa,
example_test,
example_cctld,
@ -186,7 +186,7 @@ TEST_F(FirstPartySetsEnabledTest, SetCompleteSets) {
TEST_F(FirstPartySetsEnabledTest, SetCompleteSets_Idempotent) {
SetCompleteSets({}, {});
EXPECT_THAT(FindOwnersAndWait({}), IsEmpty());
EXPECT_THAT(FindEntriesAndWait({}), IsEmpty());
// The second call to SetCompleteSets should have no effect.
SetCompleteSets({{net::SchemefulSite(GURL("https://aaaa.test")),
@ -198,7 +198,7 @@ TEST_F(FirstPartySetsEnabledTest, SetCompleteSets_Idempotent) {
net::SchemefulSite(GURL("https://example.test")),
net::SiteType::kPrimary, absl::nullopt)}},
{});
EXPECT_THAT(FindOwnersAndWait({
EXPECT_THAT(FindEntriesAndWait({
net::SchemefulSite(GURL("https://aaaa.test")),
net::SchemefulSite(GURL("https://example.test")),
}),
@ -276,9 +276,9 @@ TEST_F(AsyncPopulatedFirstPartySetsManagerTest,
}
}
TEST_F(AsyncPopulatedFirstPartySetsManagerTest, QueryBeforeReady_FindOwners) {
base::test::TestFuture<FirstPartySetsManager::OwnersResult> future;
EXPECT_FALSE(manager().FindOwners(
TEST_F(AsyncPopulatedFirstPartySetsManagerTest, QueryBeforeReady_FindEntries) {
base::test::TestFuture<FirstPartySetsManager::EntriesResult> future;
EXPECT_FALSE(manager().FindEntries(
{
net::SchemefulSite(GURL("https://member1.test")),
net::SchemefulSite(GURL("https://member2.test")),
@ -793,41 +793,41 @@ TEST_F(PopulatedFirstPartySetsManagerTest, ComputeMetadata) {
&associated_entry, &associated_entry));
}
TEST_F(PopulatedFirstPartySetsManagerTest, FindOwners) {
TEST_F(PopulatedFirstPartySetsManagerTest, FindEntries) {
net::SchemefulSite kExample(GURL("https://example.test"));
net::SchemefulSite kFoo(GURL("https://foo.test"));
net::SchemefulSite kMember1(GURL("https://member1.test"));
net::SchemefulSite kMember2(GURL("https://member2.test"));
net::SchemefulSite kNonmember(GURL("https://nonmember.test"));
EXPECT_THAT(FindOwnersAndWait({kExample}),
EXPECT_THAT(FindEntriesAndWait({kExample}),
UnorderedElementsAre(
Pair(SerializesTo("https://example.test"),
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://example.test")),
net::SiteType::kPrimary, absl::nullopt))));
EXPECT_THAT(FindOwnersAndWait({kMember1}),
EXPECT_THAT(FindEntriesAndWait({kMember1}),
UnorderedElementsAre(
Pair(SerializesTo("https://member1.test"),
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://example.test")),
net::SiteType::kAssociated, 0))));
EXPECT_THAT(FindOwnersAndWait({kNonmember}), IsEmpty());
EXPECT_THAT(FindEntriesAndWait({kNonmember}), IsEmpty());
EXPECT_THAT(FindOwnersAndWait({kExample, kNonmember}),
EXPECT_THAT(FindEntriesAndWait({kExample, kNonmember}),
UnorderedElementsAre(
Pair(SerializesTo("https://example.test"),
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://example.test")),
net::SiteType::kPrimary, absl::nullopt))));
EXPECT_THAT(FindOwnersAndWait({kMember1, kNonmember}),
EXPECT_THAT(FindEntriesAndWait({kMember1, kNonmember}),
UnorderedElementsAre(
Pair(SerializesTo("https://member1.test"),
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://example.test")),
net::SiteType::kAssociated, 0))));
EXPECT_THAT(FindOwnersAndWait({kExample, kFoo}),
EXPECT_THAT(FindEntriesAndWait({kExample, kFoo}),
UnorderedElementsAre(
Pair(SerializesTo("https://example.test"),
net::FirstPartySetEntry(
@ -837,7 +837,7 @@ TEST_F(PopulatedFirstPartySetsManagerTest, FindOwners) {
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://foo.test")),
net::SiteType::kPrimary, absl::nullopt))));
EXPECT_THAT(FindOwnersAndWait({kMember1, kFoo}),
EXPECT_THAT(FindEntriesAndWait({kMember1, kFoo}),
UnorderedElementsAre(
Pair(SerializesTo("https://member1.test"),
net::FirstPartySetEntry(
@ -847,7 +847,7 @@ TEST_F(PopulatedFirstPartySetsManagerTest, FindOwners) {
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://foo.test")),
net::SiteType::kPrimary, absl::nullopt))));
EXPECT_THAT(FindOwnersAndWait({kExample, kMember2}),
EXPECT_THAT(FindEntriesAndWait({kExample, kMember2}),
UnorderedElementsAre(
Pair(SerializesTo("https://example.test"),
net::FirstPartySetEntry(
@ -857,7 +857,7 @@ TEST_F(PopulatedFirstPartySetsManagerTest, FindOwners) {
net::FirstPartySetEntry(
net::SchemefulSite(GURL("https://foo.test")),
net::SiteType::kAssociated, 0))));
EXPECT_THAT(FindOwnersAndWait({kMember1, kMember2}),
EXPECT_THAT(FindEntriesAndWait({kMember1, kMember2}),
UnorderedElementsAre(
Pair(SerializesTo("https://member1.test"),
net::FirstPartySetEntry(
@ -907,13 +907,13 @@ class OverrideSetsFirstPartySetsManagerTest : public FirstPartySetsEnabledTest {
}
};
TEST_F(OverrideSetsFirstPartySetsManagerTest, FindOwners) {
TEST_F(OverrideSetsFirstPartySetsManagerTest, FindEntries) {
net::SchemefulSite foo(GURL("https://foo.test"));
net::SchemefulSite example_test(GURL("https://example.test"));
net::SchemefulSite example_cctld(GURL("https://example.cctld"));
net::SchemefulSite member2(GURL("https://member2.test"));
EXPECT_THAT(FindOwnersAndWait({
EXPECT_THAT(FindEntriesAndWait({
net::SchemefulSite(GURL("https://member1.test")),
member2,
foo,