Commit d223c2a7 authored by Wez's avatar Wez Committed by Commit Bot

Revert "appcache: delete appcache directory from profile when disabled"

This reverts commit bd17f198.

Reason for revert: Test is flaky, especially on Fuchsia bots.

Original change's description:
> appcache: delete appcache directory from profile when disabled
> 
> Once AppCache has been removed from Chrome, sites will have no way of
> cleaning up user data in local profiles.  To fix this, when a storage
> partition is accessed when AppCache has been disabled, we will delete
> the AppCache directory from that profile directory.
> 
> Bug: 1081897
> Change-Id: Iea404f7c83595ba1397fab4a5d3f97d1e3280916
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2343588
> Commit-Queue: enne <enne@chromium.org>
> Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
> Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#796938}

TBR=kinuko@chromium.org,mek@chromium.org,enne@chromium.org

Change-Id: Ic43fce0f9ad605a7bfb3a291a320e45d8c329b9d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: 1081897, 1115296
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2351834Reviewed-by: default avatarWez <wez@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797219}
parent 1170ac97
......@@ -170,8 +170,7 @@ const char kAppCacheName[] = "AppCache web API and browser backend";
const char kAppCacheDescription[] =
"When disabled, turns off all AppCache code so that developers "
"can test that their code works properly in the future when AppCache "
"has been removed. If disabled, this will also delete any AppCache data "
"from profile directories.";
"has been removed.";
const char kDnsHttpssvcName[] = "Support for HTTPSSVC records in DNS.";
const char kDnsHttpssvcDescription[] =
......
......@@ -451,14 +451,6 @@ void StoragePartitionImplMap::PostCreateInitialization(
in_memory ? base::FilePath()
: partition->GetPath().Append(kAppCacheDirname),
browser_context_, browser_context_->GetSpecialStoragePolicy());
} else if (!in_memory) {
// If AppCache is not enabled, clean up any on disk storage. This is the
// path that will execute once AppCache has been fully removed from Chrome.
base::ThreadPool::PostTask(
FROM_HERE, {base::MayBlock(), base::TaskPriority::BEST_EFFORT},
base::BindOnce(
[](const base::FilePath& dir) { base::DeletePathRecursively(dir); },
partition->GetPath().Append(kAppCacheDirname)));
}
// Check first to avoid memory leak in unittests.
......
......@@ -9,14 +9,11 @@
#include "base/files/file_util.h"
#include "base/run_loop.h"
#include "base/test/scoped_feature_list.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/common/content_constants.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "content/public/test/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
namespace content {
......@@ -49,48 +46,4 @@ TEST(StoragePartitionImplMapTest, GarbageCollect) {
EXPECT_FALSE(base::PathExists(inactive_path));
}
TEST(StoragePartitionImplMapTest, AppCacheCleanup) {
const auto kOnDiskConfig = content::StoragePartitionConfig::Create(
"foo", /*partition_name=*/"", /*in_memory=*/false);
base::test::ScopedFeatureList f;
f.InitAndDisableFeature(blink::features::kAppCache);
BrowserTaskEnvironment task_environment;
TestBrowserContext browser_context;
base::FilePath appcache_path;
{
base::RunLoop run_loop;
// Creating the partition in the map also does the deletion, so
// create it once, so we can find out what path the partition
// with this name is.
StoragePartitionImplMap map(&browser_context);
auto* partition = map.Get(kOnDiskConfig, true);
appcache_path = partition->GetPath().Append(kAppCacheDirname);
base::ThreadPool::PostTask(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
}
// Create an AppCache directory that would have existed.
EXPECT_FALSE(base::PathExists(appcache_path));
EXPECT_TRUE(base::CreateDirectory(appcache_path));
{
base::RunLoop run_loop;
StoragePartitionImplMap map(&browser_context);
auto* partition = map.Get(kOnDiskConfig, true);
ASSERT_EQ(appcache_path, partition->GetPath().Append(kAppCacheDirname));
base::ThreadPool::PostTask(FROM_HERE, run_loop.QuitClosure());
run_loop.Run();
// Verify that creating this partition deletes any AppCache directory it may
// have had.
EXPECT_FALSE(base::PathExists(appcache_path));
}
}
} // namespace content
......@@ -581,8 +581,7 @@ const base::FeatureParam<DelayAsyncScriptDelayType>
// The AppCache feature is a kill-switch for the entire AppCache feature,
// both backend and API. If disabled, then it will turn off the backend and
// api, regardless of the presence of valid origin trial tokens. Disabling
// AppCache will also delete any AppCache data from the profile directory.
// api, regardless of the presence of valid origin trial tokens.
const base::Feature kAppCache{"AppCache", base::FEATURE_ENABLED_BY_DEFAULT};
// If AppCacheRequireOriginTrial is enabled, then the AppCache backend in the
// browser will require origin trial tokens in order to load or store manifests
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment