• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "net/cookies/cookie_partition_key_collection.h"
6 
7 #include <vector>
8 
9 #include "base/containers/contains.h"
10 #include "base/containers/flat_map.h"
11 #include "base/containers/flat_set.h"
12 #include "base/functional/bind.h"
13 #include "base/functional/callback.h"
14 #include "net/base/schemeful_site.h"
15 #include "net/cookies/cookie_access_delegate.h"
16 #include "net/cookies/cookie_partition_key.h"
17 #include "net/first_party_sets/first_party_set_entry.h"
18 
19 namespace net {
20 
21 CookiePartitionKeyCollection::CookiePartitionKeyCollection() = default;
22 
23 CookiePartitionKeyCollection::CookiePartitionKeyCollection(
24     const CookiePartitionKeyCollection& other) = default;
25 
26 CookiePartitionKeyCollection::CookiePartitionKeyCollection(
27     CookiePartitionKeyCollection&& other) = default;
28 
CookiePartitionKeyCollection(const CookiePartitionKey & key)29 CookiePartitionKeyCollection::CookiePartitionKeyCollection(
30     const CookiePartitionKey& key)
31     : CookiePartitionKeyCollection(base::flat_set<CookiePartitionKey>({key})) {}
32 
CookiePartitionKeyCollection(base::flat_set<CookiePartitionKey> keys)33 CookiePartitionKeyCollection::CookiePartitionKeyCollection(
34     base::flat_set<CookiePartitionKey> keys)
35     : keys_(std::move(keys)) {}
36 
CookiePartitionKeyCollection(bool contains_all_keys)37 CookiePartitionKeyCollection::CookiePartitionKeyCollection(
38     bool contains_all_keys)
39     : contains_all_keys_(contains_all_keys) {}
40 
41 CookiePartitionKeyCollection& CookiePartitionKeyCollection::operator=(
42     const CookiePartitionKeyCollection& other) = default;
43 
44 CookiePartitionKeyCollection& CookiePartitionKeyCollection::operator=(
45     CookiePartitionKeyCollection&& other) = default;
46 
47 CookiePartitionKeyCollection::~CookiePartitionKeyCollection() = default;
48 
Contains(const CookiePartitionKey & key) const49 bool CookiePartitionKeyCollection::Contains(
50     const CookiePartitionKey& key) const {
51   return contains_all_keys_ || base::Contains(keys_, key);
52 }
53 
54 }  // namespace net
55