117 lines
5.6 KiB
Diff
117 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
|
|
---
|
|
.../browser/net/profile_network_context_service.cc | 2 +-
|
|
.../Enable-network-isolation-features.inc | 9 +++++++++
|
|
.../Enable-network-isolation-features.inc | 1 +
|
|
net/http/http_cache.cc | 14 +++++++++-----
|
|
net/http/http_cache.h | 2 +-
|
|
5 files changed, 21 insertions(+), 7 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
|
|
@@ -1264,7 +1264,7 @@ bool GetHttpCacheBackendResetParam(PrefService* local_state) {
|
|
field_trial = base::FeatureList::GetFieldTrial(
|
|
net::features::kSplitCacheByIncludeCredentials);
|
|
current_field_trial_status +=
|
|
- (field_trial ? field_trial->group_name() : "None");
|
|
+ (field_trial ? field_trial->group_name() : "EnableFeatureForTests");
|
|
|
|
if (disk_cache::InBackendExperiment()) {
|
|
if (disk_cache::InSimpleBackendExperimentGroup()) {
|
|
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,9 @@
|
|
+SET_CROMITE_FEATURE_ENABLED(kSplitCodeCacheByNetworkIsolationKey);
|
|
+SET_CROMITE_FEATURE_ENABLED(kPartitionConnectionsByNetworkIsolationKey);
|
|
+
|
|
+SET_CROMITE_FEATURE_ENABLED(kSplitCacheByIncludeCredentials);
|
|
+
|
|
+// enable http cache partition
|
|
+SET_CROMITE_FEATURE_ENABLED(kSplitCacheByNetworkIsolationKey);
|
|
+// but disable cache for cross-site main frame navigation
|
|
+SET_CROMITE_FEATURE_ENABLED(kSplitCacheByCrossSiteMainFrameNavigationBoolean);
|
|
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
|
|
@@ -652,7 +652,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,
|
|
@@ -690,8 +690,8 @@ 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;
|
|
+ // LOG(INFO) << "---initiator_site cs=" << base::StrCat({"ni_", initiator->Serialize(), " "});
|
|
+ return "";
|
|
}
|
|
}
|
|
isolation_key = base::StrCat(
|
|
@@ -706,9 +706,11 @@ 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("%c/%" PRId64 "/%s%s", credential_key,
|
|
+ auto key = base::StringPrintf("%c/%" PRId64 "/%s%s", credential_key,
|
|
upload_data_identifier, isolation_key.c_str(),
|
|
HttpUtil::SpecForRequest(url).c_str());
|
|
+ // LOG(INFO) << "---key=" << key;
|
|
+ return key;
|
|
}
|
|
|
|
// static
|
|
@@ -731,11 +733,13 @@ HttpCache::GenerateCacheKeyForRequestWithAlternateURL(
|
|
const int64_t upload_data_identifier =
|
|
request->upload_data_stream ? request->upload_data_stream->identifier()
|
|
: int64_t(0);
|
|
- return GenerateCacheKey(
|
|
+ auto key = GenerateCacheKey2(
|
|
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);
|
|
+ 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
|
|
@@ -529,7 +529,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,
|
|
--
|