Skip to content

Commit

Permalink
Remove Cache Transparency implementation from //net
Browse files Browse the repository at this point in the history
Remove Cache Transparency code from net::HttpCache::Transaction and
related classes.

Remove the histograms.xml entries for histograms that have been removed.

Remove CacheTransparencyNavigationBrowserTest.* and
URLLoaderCacheTransparencyTest.Redirect tests as they depend on
histograms that no longer exist. Remove files used by the browser tests.

Other parts of the cache transparency implementation outside //net still
remain.

OBSOLETE_HISTOGRAMS=Removed along with Cache Transparency implementation
BUG=1466829

Change-Id: I7a976bca695d6508ebceb944ed01e54d5db09031
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4707374
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Commit-Queue: Adam Rice <ricea@chromium.org>
Reviewed-by: Rakina Zata Amni <rakina@chromium.org>
Reviewed-by: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1174065}
  • Loading branch information
ricea authored and Chromium LUCI CQ committed Jul 24, 2023
1 parent 739e2c8 commit a7e8254
Show file tree
Hide file tree
Showing 21 changed files with 29 additions and 1,069 deletions.
58 changes: 0 additions & 58 deletions content/browser/navigation_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6995,64 +6995,6 @@ IN_PROC_BROWSER_TEST_F(NavigationBrowserTest,
EXPECT_FALSE(site_instance->GetProcess()->IsUnused());
}

class CacheTransparencyNavigationBrowserTest : public ContentBrowserTest {
public:
CacheTransparencyNavigationBrowserTest() {
EXPECT_TRUE(embedded_test_server()->Start());

pervasive_payload_url_ = embedded_test_server()->GetURL(kPervasivePayload);
std::string pervasive_payloads_params = base::StrCat(
{"1,", pervasive_payload_url_.spec(),
",2478392C652868C0AAF0316A28284610DBDACF02D66A00B39F3BA75D887F4829"});

feature_list_.InitWithFeaturesAndParameters(
{{network::features::kPervasivePayloadsList,
{{"pervasive-payloads", pervasive_payloads_params}}},
{network::features::kCacheTransparency, {}},
{net::features::kSplitCacheByNetworkIsolationKey, {}}},
{/* disabled_features */});
ForceInProcessNetworkService();
}

void ExpectCacheUsed() const {
histogram_tester_.ExpectUniqueSample(kCacheUsedHistogram, 0, 1);
}

void ExpectCacheNotUsed() const {
histogram_tester_.ExpectTotalCount(kCacheUsedHistogram, 0);
}

private:
static constexpr char kPervasivePayload[] =
"/cache_transparency/pervasive.js";
static constexpr char kCacheUsedHistogram[] =
"Network.CacheTransparency2.SingleKeyedCacheIsUsed";

base::test::ScopedFeatureList feature_list_;
GURL pervasive_payload_url_;
base::HistogramTester histogram_tester_;
};

IN_PROC_BROWSER_TEST_F(CacheTransparencyNavigationBrowserTest,
SuccessfulPervasivePayload) {
GURL url_main_document =
embedded_test_server()->GetURL("/cache_transparency/pervasive.html");

EXPECT_TRUE(NavigateToURL(shell(), url_main_document));

ExpectCacheUsed();
}

IN_PROC_BROWSER_TEST_F(CacheTransparencyNavigationBrowserTest,
NotAPervasivePayload) {
GURL url_main_document =
embedded_test_server()->GetURL("/cache_transparency/cacheable.html");

EXPECT_TRUE(NavigateToURL(shell(), url_main_document));

ExpectCacheNotUsed();
}

class NavigationBrowserTestWarnSandboxIneffective
: public NavigationBrowserTest {
public:
Expand Down
2 changes: 0 additions & 2 deletions content/test/content_test_bundle_data.filelist
Original file line number Diff line number Diff line change
Expand Up @@ -5296,11 +5296,9 @@ data/cache_storage/storage_key/0430f1a484a0ea6d8de562488c5fbeec0111d16f/ba31f73b
data/cache_storage/storage_key/0430f1a484a0ea6d8de562488c5fbeec0111d16f/ba31f73b-95e8-44fb-a273-265e7e76f5ab/index
data/cache_storage/storage_key/0430f1a484a0ea6d8de562488c5fbeec0111d16f/ba31f73b-95e8-44fb-a273-265e7e76f5ab/index-dir/the-real-index
data/cache_storage/storage_key/0430f1a484a0ea6d8de562488c5fbeec0111d16f/index.txt
data/cache_transparency/cacheable.html
data/cache_transparency/cacheable.js
data/cache_transparency/cacheable.js.mock-http-headers
data/cache_transparency/cacheable2.html
data/cache_transparency/pervasive.html
data/cache_transparency/pervasive.js
data/cache_transparency/pervasive.js.mock-http-headers
data/cache_transparency/pervasive2.html
Expand Down
6 changes: 0 additions & 6 deletions content/test/data/cache_transparency/cacheable.html

This file was deleted.

6 changes: 0 additions & 6 deletions content/test/data/cache_transparency/pervasive.html

This file was deleted.

52 changes: 12 additions & 40 deletions net/http/http_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ bool g_enable_split_cache = false;
const char HttpCache::kDoubleKeyPrefix[] = "_dk_";
const char HttpCache::kDoubleKeySeparator[] = " ";
const char HttpCache::kSubframeDocumentResourcePrefix[] = "s_";
const char HttpCache::kSingleKeyPrefix[] = "_sk_";
const char HttpCache::kSingleKeySeparator[] = " ";

HttpCache::DefaultBackend::DefaultBackend(
CacheType type,
Expand Down Expand Up @@ -366,8 +364,7 @@ void HttpCache::OnExternalCacheHit(
request_info.load_flags |= ~LOAD_DO_NOT_SAVE_COOKIES;
}

std::string key = *GenerateCacheKeyForRequest(
&request_info, /*use_single_keyed_cache=*/false);
std::string key = *GenerateCacheKeyForRequest(&request_info);
disk_cache_->OnExternalCacheHit(key);
}

Expand Down Expand Up @@ -439,11 +436,6 @@ std::string HttpCache::GetResourceURLFromHttpCacheKey(const std::string& key) {
DCHECK_NE(pos, std::string::npos);
pos += strlen(kDoubleKeySeparator);
DCHECK_LE(pos, key.size() - 1);
} else if (pos == key.find(kSingleKeyPrefix, pos)) {
pos = key.rfind(kSingleKeySeparator);
DCHECK_NE(pos, std::string::npos);
pos += strlen(kSingleKeySeparator);
DCHECK_LE(pos, key.size() - 1);
}
return key.substr(pos);
}
Expand All @@ -455,32 +447,18 @@ absl::optional<std::string> HttpCache::GenerateCacheKey(
int load_flags,
const NetworkIsolationKey& network_isolation_key,
int64_t upload_data_identifier,
bool is_subframe_document_resource,
bool use_single_keyed_cache,
const std::string& single_key_checksum) {
bool is_subframe_document_resource) {
// The first character of the key may vary depending on whether or not sending
// credentials is permitted for this request. This only happens if the
// SplitCacheByIncludeCredentials feature is enabled, or if the single-keyed
// cache is enabled. The single-keyed cache must always be split by
// credentials in order to make coep:credentialless work safely.
const char credential_key =
((base::FeatureList::IsEnabled(
features::kSplitCacheByIncludeCredentials) ||
use_single_keyed_cache) &&
(load_flags & LOAD_DO_NOT_SAVE_COOKIES))
? '0'
: '1';
// SplitCacheByIncludeCredentials feature is enabled.
const char credential_key = (base::FeatureList::IsEnabled(
features::kSplitCacheByIncludeCredentials) &&
(load_flags & LOAD_DO_NOT_SAVE_COOKIES))
? '0'
: '1';

std::string isolation_key;
if (use_single_keyed_cache) {
DCHECK(IsSplitCacheEnabled());
DCHECK(!(load_flags &
(net::LOAD_VALIDATE_CACHE | net::LOAD_BYPASS_CACHE |
net::LOAD_SKIP_CACHE_VALIDATION | net::LOAD_ONLY_FROM_CACHE |
net::LOAD_DISABLE_CACHE | net::LOAD_SKIP_VARY_CHECK)));
isolation_key = base::StrCat(
{kSingleKeyPrefix, single_key_checksum, kSingleKeySeparator});
} else if (IsSplitCacheEnabled()) {
if (IsSplitCacheEnabled()) {
// Prepend the key with |kDoubleKeyPrefix| = "_dk_" to mark it as
// double-keyed (and makes it an invalid url so that it doesn't get
// confused with a single-keyed entry). Separate the origin and url
Expand All @@ -507,16 +485,14 @@ absl::optional<std::string> HttpCache::GenerateCacheKey(

// static
absl::optional<std::string> HttpCache::GenerateCacheKeyForRequest(
const HttpRequestInfo* request,
bool use_single_keyed_cache) {
const HttpRequestInfo* request) {
DCHECK(request);
const int64_t upload_data_identifier =
request->upload_data_stream ? request->upload_data_stream->identifier()
: int64_t(0);
return GenerateCacheKey(
request->url, request->load_flags, request->network_isolation_key,
upload_data_identifier, request->is_subframe_document_resource,
use_single_keyed_cache, request->checksum);
upload_data_identifier, request->is_subframe_document_resource);
}

// static
Expand Down Expand Up @@ -694,11 +670,7 @@ void HttpCache::DoomMainEntryForUrl(const GURL& url,
net::NetworkAnonymizationKey::CreateFromNetworkIsolationKey(
isolation_key);
temp_info.is_subframe_document_resource = is_subframe_document_resource;
// This method is always used for "POST" requests, which never use the
// single-keyed cache, so therefore it is correct that use_single_keyed_cache
// be false.
std::string key =
*GenerateCacheKeyForRequest(&temp_info, /*use_single_keyed_cache=*/false);
std::string key = *GenerateCacheKeyForRequest(&temp_info);

// Defer to DoomEntry if there is an active entry, otherwise call
// AsyncDoomEntry without triggering a callback.
Expand Down
7 changes: 2 additions & 5 deletions net/http/http_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,9 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory {
int load_flags,
const NetworkIsolationKey& network_isolation_key,
int64_t upload_data_identifier,
bool is_subframe_document_resource,
bool use_single_keyed_cache,
const std::string& single_key_checksum);
bool is_subframe_document_resource);
static absl::optional<std::string> GenerateCacheKeyForRequest(
const HttpRequestInfo* request,
bool use_single_keyed_cache = false);
const HttpRequestInfo* request);

// Enable split cache feature if not already overridden in the feature list.
// Should only be invoked during process initialization before the HTTP
Expand Down
Loading

0 comments on commit a7e8254

Please sign in to comment.