summaryrefslogtreecommitdiff
path: root/chromium/net/base/network_isolation_key.h
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-16 11:45:35 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-07-17 08:59:23 +0000
commit552906b0f222c5d5dd11b9fd73829d510980461a (patch)
tree3a11e6ed0538a81dd83b20cf3a4783e297f26d91 /chromium/net/base/network_isolation_key.h
parent1b05827804eaf047779b597718c03e7d38344261 (diff)
downloadqtwebengine-chromium-552906b0f222c5d5dd11b9fd73829d510980461a.tar.gz
BASELINE: Update Chromium to 83.0.4103.122
Change-Id: Ie3a82f5bb0076eec2a7c6a6162326b4301ee291e Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/net/base/network_isolation_key.h')
-rw-r--r--chromium/net/base/network_isolation_key.h50
1 files changed, 41 insertions, 9 deletions
diff --git a/chromium/net/base/network_isolation_key.h b/chromium/net/base/network_isolation_key.h
index 488860702f1..ddfe1e52216 100644
--- a/chromium/net/base/network_isolation_key.h
+++ b/chromium/net/base/network_isolation_key.h
@@ -14,6 +14,17 @@
#include "net/base/net_export.h"
#include "url/origin.h"
+namespace network {
+namespace mojom {
+class NetworkIsolationKeyDataView;
+} // namespace mojom
+} // namespace network
+
+namespace mojo {
+template <typename DataViewType, typename T>
+struct StructTraits;
+} // namespace mojo
+
namespace net {
// Key used to isolate shared network stack resources used by requests based on
@@ -22,8 +33,8 @@ class NET_EXPORT NetworkIsolationKey {
public:
// Full constructor. When a request is initiated by the top frame, it must
// also populate the |frame_origin| parameter when calling this constructor.
- explicit NetworkIsolationKey(const url::Origin& top_frame_origin,
- const url::Origin& frame_origin);
+ NetworkIsolationKey(const url::Origin& top_frame_origin,
+ const url::Origin& frame_origin);
// Construct an empty key.
NetworkIsolationKey();
@@ -42,6 +53,11 @@ class NET_EXPORT NetworkIsolationKey {
// persisted to disk.
static NetworkIsolationKey CreateTransient();
+ // Creates a non-empty NetworkIsolationKey with an opaque origin that is not
+ // considered transient. The returned NetworkIsolationKey will be cross-origin
+ // with all other keys and associated data is able to be persisted to disk.
+ static NetworkIsolationKey CreateOpaqueAndNonTransient();
+
// Creates a new key using |top_frame_origin_| and |new_frame_origin|.
NetworkIsolationKey CreateWithNewFrameOrigin(
const url::Origin& new_frame_origin) const;
@@ -55,21 +71,23 @@ class NET_EXPORT NetworkIsolationKey {
// Compare keys for equality, true if all enabled fields are equal.
bool operator==(const NetworkIsolationKey& other) const {
- return top_frame_origin_ == other.top_frame_origin_ &&
- frame_origin_ == other.frame_origin_;
+ return std::tie(top_frame_origin_, frame_origin_,
+ opaque_and_non_transient_) ==
+ std::tie(other.top_frame_origin_, other.frame_origin_,
+ other.opaque_and_non_transient_);
}
// Compare keys for inequality, true if any enabled field varies.
bool operator!=(const NetworkIsolationKey& other) const {
- return (top_frame_origin_ != other.top_frame_origin_) ||
- (frame_origin_ != other.frame_origin_);
+ return !(*this == other);
}
// Provide an ordering for keys based on all enabled fields.
bool operator<(const NetworkIsolationKey& other) const {
- return top_frame_origin_ < other.top_frame_origin_ ||
- (top_frame_origin_ == other.top_frame_origin_ &&
- frame_origin_ < other.frame_origin_);
+ return std::tie(top_frame_origin_, frame_origin_,
+ opaque_and_non_transient_) <
+ std::tie(other.top_frame_origin_, other.frame_origin_,
+ other.opaque_and_non_transient_);
}
// Returns the string representation of the key, which is the string
@@ -121,11 +139,25 @@ class NET_EXPORT NetworkIsolationKey {
WARN_UNUSED_RESULT;
private:
+ // These classes need to be able to set |opaque_and_non_transient_|
+ friend class IsolationInfo;
+ friend struct mojo::StructTraits<network::mojom::NetworkIsolationKeyDataView,
+ net::NetworkIsolationKey>;
FRIEND_TEST_ALL_PREFIXES(NetworkIsolationKeyWithFrameOriginTest,
UseRegistrableDomain);
+ NetworkIsolationKey(const url::Origin& top_frame_origin,
+ const url::Origin& frame_origin,
+ bool opaque_and_non_transient);
+
void ReplaceOriginsWithRegistrableDomains();
+ bool IsOpaque() const;
+
+ // Whether opaque origins cause the key to be transient. Always false, unless
+ // created with |CreateOpaqueAndNonTransient|.
+ bool opaque_and_non_transient_ = false;
+
// Whether or not to use the |frame_origin_| as part of the key.
bool use_frame_origin_;