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
|
// 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_SHARED_DICTIONARY_SHARED_DICTIONARY_ISOLATION_KEY_H_
#define NET_SHARED_DICTIONARY_SHARED_DICTIONARY_ISOLATION_KEY_H_
#include <optional>
#include "net/base/net_export.h"
#include "net/base/schemeful_site.h"
#include "url/origin.h"
namespace net {
class IsolationInfo;
class NetworkIsolationKey;
// Key used to isolate shared dictionary storages.
class NET_EXPORT SharedDictionaryIsolationKey {
public:
// Creates a SharedDictionaryIsolationKey. Returns nullopt when
// `frame_origin` or `top_frame_origin` of `isolation_info` is not set or
// opaque, or `nonce` is set.
static std::optional<SharedDictionaryIsolationKey> MaybeCreate(
const IsolationInfo& isolation_info);
// Creates a SharedDictionaryIsolationKey. Returns nullopt when
// `frame_origin` or `top_frame_origin` of `network_isolation_key` is not set
// or opaque, or `nonce` of `network_isolation_key` is set.
static std::optional<SharedDictionaryIsolationKey> MaybeCreate(
const NetworkIsolationKey& network_isolation_key,
const std::optional<url::Origin>& frame_origin);
SharedDictionaryIsolationKey() = default;
SharedDictionaryIsolationKey(const url::Origin& frame_origin,
const SchemefulSite& top_frame_site);
const url::Origin& frame_origin() const { return frame_origin_; }
const SchemefulSite& top_frame_site() const { return top_frame_site_; }
~SharedDictionaryIsolationKey();
SharedDictionaryIsolationKey(const SharedDictionaryIsolationKey& other);
SharedDictionaryIsolationKey(SharedDictionaryIsolationKey&& other);
SharedDictionaryIsolationKey& operator=(
const SharedDictionaryIsolationKey& other);
SharedDictionaryIsolationKey& operator=(SharedDictionaryIsolationKey&& other);
friend bool operator==(const SharedDictionaryIsolationKey&,
const SharedDictionaryIsolationKey&) = default;
friend auto operator<=>(const SharedDictionaryIsolationKey&,
const SharedDictionaryIsolationKey&) = default;
private:
url::Origin frame_origin_;
SchemefulSite top_frame_site_;
};
} // namespace net
#endif // NET_SHARED_DICTIONARY_SHARED_DICTIONARY_ISOLATION_KEY_H_
|