Files
cromite/build/patches/Enable-network-isolation-features.patch

119 lines
5.6 KiB
Diff

From: csagan5 <32685696+csagan5@users.noreply.github.com>
Date: Thu, 10 Dec 2020 21:52:35 +0100
Subject: Enable network isolation features
Enable SplitCacheByNetworkIsolationKey, kSplitHostCacheByNetworkIsolationKey,
kPartitionConnectionsByNetworkIsolationKey, kPartitionHttpServerPropertiesByNetworkIsolationKey,
kPartitionSSLSessionsByNetworkIsolationKey, PartitionExpectCTStateByNetworkIsolationKey,
PartitionNelAndReportingByNetworkIsolationKey, kSplitCacheByNavigationInitiator
License: GPL-3.0-only - https://spdx.org/licenses/GPL-3.0-only.html
---
.../net/profile_network_context_service.cc | 4 ++--
.../Enable-network-isolation-features.inc | 7 +++++++
.../Enable-network-isolation-features.inc | 1 +
net/http/http_cache.cc | 15 ++++++++++-----
net/http/http_cache.h | 2 +-
5 files changed, 21 insertions(+), 8 deletions(-)
create mode 100644 cromite_flags/net/base/features_cc/Enable-network-isolation-features.inc
create mode 100644 cromite_flags/services/network/public/cpp/features_cc/Enable-network-isolation-features.inc
diff --git a/chrome/browser/net/profile_network_context_service.cc b/chrome/browser/net/profile_network_context_service.cc
--- a/chrome/browser/net/profile_network_context_service.cc
+++ b/chrome/browser/net/profile_network_context_service.cc
@@ -458,8 +458,8 @@ bool GetHttpCacheBackendResetParam(PrefService* local_state) {
experiment_parts.push_back(kDiskCacheExperimentNameNone);
// SplitCacheByIncludeCredentials experiment:
experiment_parts.push_back(credentials_field_trial
- ? credentials_field_trial->group_name()
- : kDiskCacheExperimentNameNone);
+ ? "EnableFeatureForTests"
+ : "EnableFeatureForTests");
// Add the disk cache backend experiment group if active.
if (backend_field_trial) {
diff --git a/cromite_flags/net/base/features_cc/Enable-network-isolation-features.inc b/cromite_flags/net/base/features_cc/Enable-network-isolation-features.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/net/base/features_cc/Enable-network-isolation-features.inc
@@ -0,0 +1,7 @@
+SET_CROMITE_FEATURE_ENABLED(kSplitCodeCacheByNetworkIsolationKey);
+SET_CROMITE_FEATURE_ENABLED(kPartitionConnectionsByNetworkIsolationKey);
+
+SET_CROMITE_FEATURE_ENABLED(kSplitCacheByIncludeCredentials);
+
+// enable http cache partition
+SET_CROMITE_FEATURE_ENABLED(kSplitCacheByNetworkIsolationKey);
diff --git a/cromite_flags/services/network/public/cpp/features_cc/Enable-network-isolation-features.inc b/cromite_flags/services/network/public/cpp/features_cc/Enable-network-isolation-features.inc
new file mode 100644
--- /dev/null
+++ b/cromite_flags/services/network/public/cpp/features_cc/Enable-network-isolation-features.inc
@@ -0,0 +1 @@
+SET_CROMITE_FEATURE_ENABLED(kSplitAuthCacheByNetworkIsolationKey);
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -795,7 +795,7 @@ bool HttpCache::CanGenerateCacheKeyForRequest(const HttpRequestInfo& request) {
// static
// Generate a key that can be used inside the cache.
-std::string HttpCache::GenerateCacheKey(
+std::string HttpCache::GenerateCacheKey2(
const GURL& url,
int load_flags,
const NetworkIsolationKey& network_isolation_key,
@@ -832,8 +832,9 @@ std::string HttpCache::GenerateCacheKey(
const bool is_initiator_cross_site =
!net::SchemefulSite::IsSameSite(*initiator, url::Origin::Create(url));
if (is_initiator_cross_site) {
- is_cross_site_main_frame_navigation_prefix =
- kCrossSiteMainFrameNavigationPrefix;
+ // disable cache for cross-site main frame navigation
+ // LOG(INFO) << "---initiator_site cs=" << base::StrCat({"ni_", initiator->Serialize(), " "});
+ return "";
}
}
isolation_key = base::StrCat(
@@ -852,10 +853,12 @@ std::string HttpCache::GenerateCacheKey(
// Strip out the reference, username, and password sections of the URL and
// concatenate with the credential_key, the post_key, and the network
// isolation key if we are splitting the cache.
- return base::StringPrintf(
+ auto key = base::StringPrintf(
"%c/%" PRId64 "/%s%s", credential_key, upload_data_identifier,
isolation_key.c_str(),
include_url ? HttpUtil::SpecForRequest(url).c_str() : "");
+ // LOG(INFO) << "---key=" << key;
+ return key;
}
// static
@@ -875,11 +878,13 @@ std::optional<std::string> HttpCache::GenerateCacheKeyInternal(
const int64_t upload_data_identifier =
request.upload_data_stream ? request.upload_data_stream->identifier()
: int64_t{0};
- return GenerateCacheKey(
+ auto key = GenerateCacheKey2(
request.url, request.load_flags, request.network_isolation_key,
upload_data_identifier, request.is_subframe_document_resource,
request.is_main_frame_navigation, request.is_shared_resource,
request.initiator, include_url);
+ if (key.empty()) return std::nullopt;
+ return key;
}
// static
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -591,7 +591,7 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory {
// Generates a cache key given the various pieces used to construct the key.
// Must not be called if a corresponding `CanGenerateCacheKeyForRequest`
// returns false.
- static std::string GenerateCacheKey(
+ static std::string GenerateCacheKey2(
const GURL& url,
int load_flags,
const NetworkIsolationKey& network_isolation_key,
--