Commit 5ef8d0fb authored by Benoît Lizé's avatar Benoît Lizé Committed by Commit Bot

net/disk_cache/simple: Remove launched base::Feature.

kSimpleCacheEvictionWithSize was launched in M63, time to remove the
feature from the codebase :).

Bug: 736437
Change-Id: I7e1ffd378a011eca0c414ccf712e9aceb4297704
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066897Reviewed-by: default avatarMaksim Orlovich <morlovich@chromium.org>
Commit-Queue: Benoit L <lizeb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743148}
parent aaf6da23
......@@ -13,7 +13,6 @@
#include "base/bind_helpers.h"
#include "base/files/file_util.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/strings/string_number_conversions.h"
......@@ -59,9 +58,6 @@ static const int kEstimatedEntryOverhead = 512;
namespace disk_cache {
const base::Feature kSimpleCacheEvictionWithSize = {
"SimpleCacheEvictionWithSize", base::FEATURE_ENABLED_BY_DEFAULT};
EntryMetadata::EntryMetadata()
: last_used_time_seconds_since_epoch_(0),
entry_size_256b_chunks_(0),
......@@ -426,15 +422,14 @@ void SimpleIndex::StartEvictionIfNeeded() {
std::vector<std::pair<uint64_t, const EntrySet::value_type*>> entries;
entries.reserve(entries_set_.size());
uint32_t now = (base::Time::Now() - base::Time::UnixEpoch()).InSeconds();
bool use_size = base::FeatureList::IsEnabled(kSimpleCacheEvictionWithSize);
for (EntrySet::const_iterator i = entries_set_.begin();
i != entries_set_.end(); ++i) {
uint64_t sort_value = now - i->second.RawTimeForSorting();
if (use_size) {
// Will not overflow since we're multiplying two 32-bit values and storing
// them in a 64-bit variable.
sort_value *= i->second.GetEntrySize() + kEstimatedEntryOverhead;
}
// See crbug.com/736437 for context.
//
// Will not overflow since we're multiplying two 32-bit values and storing
// them in a 64-bit variable.
sort_value *= i->second.GetEntrySize() + kEstimatedEntryOverhead;
// Subtract so we don't need a custom comparator.
entries.emplace_back(std::numeric_limits<uint64_t>::max() - sort_value,
&*i);
......
......@@ -14,7 +14,6 @@
#include <vector>
#include "base/callback.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
......@@ -46,8 +45,6 @@ class SimpleIndexDelegate;
class SimpleIndexFile;
struct SimpleIndexLoadResult;
NET_EXPORT_PRIVATE extern const base::Feature kSimpleCacheEvictionWithSize;
class NET_EXPORT_PRIVATE EntryMetadata {
public:
EntryMetadata();
......
......@@ -13,13 +13,10 @@
#include "base/files/scoped_temp_dir.h"
#include "base/hash/hash.h"
#include "base/logging.h"
#include "base/metrics/field_trial.h"
#include "base/metrics/field_trial_param_associator.h"
#include "base/pickle.h"
#include "base/strings/stringprintf.h"
#include "base/task_runner.h"
#include "base/test/mock_entropy_provider.h"
#include "base/test/scoped_feature_list.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "net/base/cache_type.h"
......@@ -180,9 +177,6 @@ class SimpleIndexTest : public net::TestWithTaskEnvironment,
std::unique_ptr<SimpleIndex> index_;
base::WeakPtr<MockSimpleIndexFile> index_file_;
std::unique_ptr<base::FieldTrialList> field_trial_list_;
base::test::ScopedFeatureList scoped_feature_list_;
std::vector<uint64_t> last_doom_entry_hashes_;
int doom_entries_calls_ = 0;
};
......@@ -609,40 +603,6 @@ TEST_F(SimpleIndexTest, BasicEviction) {
ASSERT_EQ(2u, last_doom_entry_hashes().size());
}
TEST_F(SimpleIndexTest, EvictByLRU) {
base::test::ScopedFeatureList features;
features.InitAndDisableFeature(kSimpleCacheEvictionWithSize);
base::Time now(base::Time::Now());
index()->SetMaxSize(50000);
InsertIntoIndexFileReturn(hashes_.at<1>(), now - base::TimeDelta::FromDays(2),
475u);
InsertIntoIndexFileReturn(hashes_.at<2>(), now - base::TimeDelta::FromDays(1),
40000u);
ReturnIndexFile();
WaitForTimeChange();
index()->Insert(hashes_.at<3>());
// Confirm index is as expected: No eviction, everything there.
EXPECT_EQ(3, index()->GetEntryCount());
EXPECT_EQ(0, doom_entries_calls());
EXPECT_TRUE(index()->Has(hashes_.at<1>()));
EXPECT_TRUE(index()->Has(hashes_.at<2>()));
EXPECT_TRUE(index()->Has(hashes_.at<3>()));
// Trigger an eviction, and make sure the right things are tossed.
// TODO(morlovich): This is dependent on the innards of the implementation
// as to at exactly what point we trigger eviction. Not sure how to fix
// that.
index()->UpdateEntrySize(hashes_.at<3>(), 40000u);
EXPECT_EQ(1, doom_entries_calls());
EXPECT_EQ(1, index()->GetEntryCount());
EXPECT_FALSE(index()->Has(hashes_.at<1>()));
EXPECT_FALSE(index()->Has(hashes_.at<2>()));
EXPECT_TRUE(index()->Has(hashes_.at<3>()));
ASSERT_EQ(2u, last_doom_entry_hashes().size());
}
TEST_F(SimpleIndexTest, EvictBySize) {
base::Time now(base::Time::Now());
index()->SetMaxSize(50000);
......
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