1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NET_FIRST_PARTY_SETS_SETS_MUTATION_H_
#define NET_FIRST_PARTY_SETS_SETS_MUTATION_H_
#include "base/containers/flat_map.h"
#include "net/base/net_export.h"
#include "net/base/schemeful_site.h"
#include "net/first_party_sets/first_party_set_entry.h"
namespace net {
// SetsMutation represents a mutation to be applied to the list of global
// Related Website Sets. A mutation can come from the
// RelatedWebsiteSetsOverrides policy.
//
// See `GlobalFirstPartySets` for how SetsMutations are layered on top of the
// public sets and the local set declaration (if any).
class NET_EXPORT SetsMutation {
public:
SetsMutation();
// Preconditions:
// * Sets defined by `replacement_sets` and `addition_sets` must be disjoint.
// * All of the canonical sites in `aliases` (the "values") must occur in
// (exactly) one of the replacement or addition sets, and have an identical
// entry to that of the alias (the "key").
SetsMutation(std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>>
replacement_sets,
std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>>
addition_sets,
base::flat_map<SchemefulSite, SchemefulSite> aliases);
~SetsMutation();
SetsMutation(const SetsMutation&);
SetsMutation& operator=(const SetsMutation&);
SetsMutation(SetsMutation&&);
SetsMutation& operator=(SetsMutation&&);
bool operator==(const SetsMutation& other) const;
const std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>>&
replacements() const {
return replacements_;
}
const std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>>&
additions() const {
return additions_;
}
const base::flat_map<SchemefulSite, SchemefulSite>& aliases() const {
return aliases_;
}
private:
// The list of "replacement" sets.
std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>> replacements_;
// The list of "addition" sets.
std::vector<base::flat_map<SchemefulSite, FirstPartySetEntry>> additions_;
// Any aliases to be used in this mutation.
base::flat_map<SchemefulSite, SchemefulSite> aliases_;
};
NET_EXPORT std::ostream& operator<<(std::ostream& os,
const SetsMutation& mutation);
} // namespace net
#endif // NET_FIRST_PARTY_SETS_SETS_MUTATION_H_
|