summaryrefslogtreecommitdiff
path: root/chromium/net/disk_cache
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-06 12:48:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:33:43 +0000
commit7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (patch)
treefa14ba0ca8d2683ba2efdabd246dc9b18a1229c6 /chromium/net/disk_cache
parent79b4f909db1049fca459c07cca55af56a9b54fe3 (diff)
downloadqtwebengine-chromium-7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3.tar.gz
BASELINE: Update Chromium to 84.0.4147.141
Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/net/disk_cache')
-rw-r--r--chromium/net/disk_cache/blockfile/addr.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/backend_impl.cc22
-rw-r--r--chromium/net/disk_cache/blockfile/backend_impl.h1
-rw-r--r--chromium/net/disk_cache/blockfile/bitmap.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/eviction.cc3
-rw-r--r--chromium/net/disk_cache/blockfile/file_ios.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/file_posix.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/file_win.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/in_flight_backend_io.cc3
-rw-r--r--chromium/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/mapped_file_win.cc2
-rw-r--r--chromium/net/disk_cache/blockfile/stats.cc3
-rw-r--r--chromium/net/disk_cache/disk_cache_fuzzer.cc5
-rw-r--r--chromium/net/disk_cache/disk_cache_test_util.cc2
-rw-r--r--chromium/net/disk_cache/memory/mem_entry_impl.cc2
-rw-r--r--chromium/net/disk_cache/net_log_parameters.cc2
-rw-r--r--chromium/net/disk_cache/simple/post_doom_waiter.cc1
-rw-r--r--chromium/net/disk_cache/simple/simple_entry_impl.cc9
-rw-r--r--chromium/net/disk_cache/simple/simple_entry_operation.cc1
-rw-r--r--chromium/net/disk_cache/simple/simple_file_tracker.cc1
-rw-r--r--chromium/net/disk_cache/simple/simple_file_tracker_unittest.cc1
-rw-r--r--chromium/net/disk_cache/simple/simple_histogram_macros.h43
-rw-r--r--chromium/net/disk_cache/simple/simple_index.cc16
-rw-r--r--chromium/net/disk_cache/simple/simple_index.h6
-rw-r--r--chromium/net/disk_cache/simple/simple_index_file_unittest.cc2
-rw-r--r--chromium/net/disk_cache/simple/simple_index_unittest.cc77
-rw-r--r--chromium/net/disk_cache/simple/simple_net_log_parameters.cc2
-rw-r--r--chromium/net/disk_cache/simple/simple_util.cc2
-rw-r--r--chromium/net/disk_cache/simple/simple_util_unittest.cc1
29 files changed, 161 insertions, 58 deletions
diff --git a/chromium/net/disk_cache/blockfile/addr.cc b/chromium/net/disk_cache/blockfile/addr.cc
index cbe42f7f5fa..bf44bd78688 100644
--- a/chromium/net/disk_cache/blockfile/addr.cc
+++ b/chromium/net/disk_cache/blockfile/addr.cc
@@ -4,7 +4,7 @@
#include "net/disk_cache/blockfile/addr.h"
-#include "base/logging.h"
+#include "base/check.h"
namespace disk_cache {
diff --git a/chromium/net/disk_cache/blockfile/backend_impl.cc b/chromium/net/disk_cache/blockfile/backend_impl.cc
index ef6535bfdec..951607c725c 100644
--- a/chromium/net/disk_cache/blockfile/backend_impl.cc
+++ b/chromium/net/disk_cache/blockfile/backend_impl.cc
@@ -110,8 +110,10 @@ bool InitExperiment(disk_cache::IndexHeader* header, bool cache_created) {
}
// A callback to perform final cleanup on the background thread.
-void FinalCleanupCallback(disk_cache::BackendImpl* backend) {
+void FinalCleanupCallback(disk_cache::BackendImpl* backend,
+ base::WaitableEvent* done) {
backend->CleanupCache();
+ done->Signal();
}
class CacheThread : public base::Thread {
@@ -159,9 +161,7 @@ BackendImpl::BackendImpl(
block_files_(path),
mask_(0),
user_flags_(0),
- net_log_(net_log),
- done_(base::WaitableEvent::ResetPolicy::MANUAL,
- base::WaitableEvent::InitialState::NOT_SIGNALED) {
+ net_log_(net_log) {
TRACE_EVENT0("disk_cache", "BackendImpl::BackendImpl");
}
@@ -177,9 +177,7 @@ BackendImpl::BackendImpl(
block_files_(path),
mask_(mask),
user_flags_(kMask),
- net_log_(net_log),
- done_(base::WaitableEvent::ResetPolicy::MANUAL,
- base::WaitableEvent::InitialState::NOT_SIGNALED) {
+ net_log_(net_log) {
TRACE_EVENT0("disk_cache", "BackendImpl::BackendImpl");
}
@@ -199,12 +197,15 @@ BackendImpl::~BackendImpl() {
// Unit tests may use the same sequence for everything.
CleanupCache();
} else {
+ // Signals the end of background work.
+ base::WaitableEvent done;
+
background_queue_.background_thread()->PostTask(
- FROM_HERE,
- base::BindOnce(&FinalCleanupCallback, base::Unretained(this)));
+ FROM_HERE, base::BindOnce(&FinalCleanupCallback, base::Unretained(this),
+ base::Unretained(&done)));
// http://crbug.com/74623
base::ScopedAllowBaseSyncPrimitivesOutsideBlockingScope allow_wait;
- done_.Wait();
+ done.Wait();
}
}
@@ -348,7 +349,6 @@ void BackendImpl::CleanupCache() {
FlushIndex();
index_ = nullptr;
ptr_factory_.InvalidateWeakPtrs();
- done_.Signal();
}
// ------------------------------------------------------------------------
diff --git a/chromium/net/disk_cache/blockfile/backend_impl.h b/chromium/net/disk_cache/blockfile/backend_impl.h
index cefe8bb7c89..db2a43fed28 100644
--- a/chromium/net/disk_cache/blockfile/backend_impl.h
+++ b/chromium/net/disk_cache/blockfile/backend_impl.h
@@ -426,7 +426,6 @@ class NET_EXPORT_PRIVATE BackendImpl : public Backend {
Stats stats_; // Usage statistics.
std::unique_ptr<base::RepeatingTimer> timer_; // Usage timer.
- base::WaitableEvent done_; // Signals the end of background work.
base::WeakPtrFactory<BackendImpl> ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(BackendImpl);
diff --git a/chromium/net/disk_cache/blockfile/bitmap.cc b/chromium/net/disk_cache/blockfile/bitmap.cc
index 016eaed43b5..a78dedac206 100644
--- a/chromium/net/disk_cache/blockfile/bitmap.cc
+++ b/chromium/net/disk_cache/blockfile/bitmap.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include "base/bits.h"
-#include "base/logging.h"
+#include "base/check_op.h"
namespace {
// Returns the index of the first bit set to |value| from |word|. This code
diff --git a/chromium/net/disk_cache/blockfile/eviction.cc b/chromium/net/disk_cache/blockfile/eviction.cc
index 1ff15ab5c05..58975d0ed3f 100644
--- a/chromium/net/disk_cache/blockfile/eviction.cc
+++ b/chromium/net/disk_cache/blockfile/eviction.cc
@@ -33,10 +33,11 @@
#include <limits>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/chromium/net/disk_cache/blockfile/file_ios.cc b/chromium/net/disk_cache/blockfile/file_ios.cc
index 984a34b18fc..89091faae7e 100644
--- a/chromium/net/disk_cache/blockfile/file_ios.cc
+++ b/chromium/net/disk_cache/blockfile/file_ios.cc
@@ -11,8 +11,8 @@
#include <utility>
#include "base/bind.h"
+#include "base/check.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
diff --git a/chromium/net/disk_cache/blockfile/file_posix.cc b/chromium/net/disk_cache/blockfile/file_posix.cc
index b5921108c28..210d717012d 100644
--- a/chromium/net/disk_cache/blockfile/file_posix.cc
+++ b/chromium/net/disk_cache/blockfile/file_posix.cc
@@ -9,8 +9,8 @@
#include <utility>
#include "base/bind.h"
+#include "base/check.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/run_loop.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
diff --git a/chromium/net/disk_cache/blockfile/file_win.cc b/chromium/net/disk_cache/blockfile/file_win.cc
index 2225c16de47..250aece780a 100644
--- a/chromium/net/disk_cache/blockfile/file_win.cc
+++ b/chromium/net/disk_cache/blockfile/file_win.cc
@@ -40,7 +40,7 @@ static_assert(offsetof(MyOverlapped, context_) == 0,
class CompletionHandler : public base::MessagePumpForIO::IOHandler,
public base::RefCounted<CompletionHandler> {
public:
- CompletionHandler() = default;
+ CompletionHandler() : base::MessagePumpForIO::IOHandler(FROM_HERE) {}
static CompletionHandler* Get();
private:
diff --git a/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc b/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
index 3d2250a9246..aa2bae8ba04 100644
--- a/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
+++ b/chromium/net/disk_cache/blockfile/in_flight_backend_io.cc
@@ -8,9 +8,10 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/check_op.h"
#include "base/compiler_specific.h"
#include "base/location.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/single_thread_task_runner.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/blockfile/backend_impl.h"
diff --git a/chromium/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc b/chromium/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
index 3936358236d..633aaa056fb 100644
--- a/chromium/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
+++ b/chromium/net/disk_cache/blockfile/mapped_file_avoid_mmap_posix.cc
@@ -6,8 +6,8 @@
#include <stdlib.h>
+#include "base/check.h"
#include "base/files/file_path.h"
-#include "base/logging.h"
namespace disk_cache {
diff --git a/chromium/net/disk_cache/blockfile/mapped_file_win.cc b/chromium/net/disk_cache/blockfile/mapped_file_win.cc
index 1490212c143..5829dcc4a28 100644
--- a/chromium/net/disk_cache/blockfile/mapped_file_win.cc
+++ b/chromium/net/disk_cache/blockfile/mapped_file_win.cc
@@ -6,8 +6,8 @@
#include <memory>
+#include "base/check.h"
#include "base/files/file_path.h"
-#include "base/logging.h"
#include "net/disk_cache/disk_cache.h"
#include <windows.h>
diff --git a/chromium/net/disk_cache/blockfile/stats.cc b/chromium/net/disk_cache/blockfile/stats.cc
index 43c6758ccfe..224e1c9d06a 100644
--- a/chromium/net/disk_cache/blockfile/stats.cc
+++ b/chromium/net/disk_cache/blockfile/stats.cc
@@ -4,13 +4,14 @@
#include "net/disk_cache/blockfile/stats.h"
+#include "base/check.h"
#include "base/format_macros.h"
-#include "base/logging.h"
#include "base/metrics/bucket_ranges.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_samples.h"
#include "base/metrics/sample_vector.h"
#include "base/metrics/statistics_recorder.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/net/disk_cache/disk_cache_fuzzer.cc b/chromium/net/disk_cache/disk_cache_fuzzer.cc
index f88effda31f..ee4c1036e08 100644
--- a/chromium/net/disk_cache/disk_cache_fuzzer.cc
+++ b/chromium/net/disk_cache/disk_cache_fuzzer.cc
@@ -22,6 +22,7 @@
#include "base/numerics/checked_math.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/task_environment.h"
+#include "base/test/test_timeouts.h"
#include "base/time/time.h"
#include "net/base/cache_type.h"
#include "net/base/interval.h"
@@ -91,6 +92,10 @@ struct InitGlobals {
print_comms_ = ::getenv("LPM_DUMP_NATIVE_INPUT");
+ // TaskEnvironment requires TestTimeouts initialization to watch for
+ // problematic long-running tasks.
+ TestTimeouts::Initialize();
+
// Mark this thread as an IO_THREAD with MOCK_TIME, and ensure that Now()
// is driven from the same mock clock.
task_environment_ = std::make_unique<base::test::TaskEnvironment>(
diff --git a/chromium/net/disk_cache/disk_cache_test_util.cc b/chromium/net/disk_cache/disk_cache_test_util.cc
index 651533b1fe6..959fa88b54e 100644
--- a/chromium/net/disk_cache/disk_cache_test_util.cc
+++ b/chromium/net/disk_cache/disk_cache_test_util.cc
@@ -4,9 +4,9 @@
#include "net/disk_cache/disk_cache_test_util.h"
+#include "base/check_op.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
-#include "base/logging.h"
#include "base/run_loop.h"
#include "base/threading/thread_task_runner_handle.h"
#include "net/base/net_errors.h"
diff --git a/chromium/net/disk_cache/memory/mem_entry_impl.cc b/chromium/net/disk_cache/memory/mem_entry_impl.cc
index 93680d2aec2..b46a807c0c5 100644
--- a/chromium/net/disk_cache/memory/mem_entry_impl.cc
+++ b/chromium/net/disk_cache/memory/mem_entry_impl.cc
@@ -8,8 +8,8 @@
#include <utility>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/format_macros.h"
-#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_math.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/net/disk_cache/net_log_parameters.cc b/chromium/net/disk_cache/net_log_parameters.cc
index 96e99bb0b0e..67afd8b1c26 100644
--- a/chromium/net/disk_cache/net_log_parameters.cc
+++ b/chromium/net/disk_cache/net_log_parameters.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/values.h"
#include "net/base/net_errors.h"
#include "net/disk_cache/disk_cache.h"
diff --git a/chromium/net/disk_cache/simple/post_doom_waiter.cc b/chromium/net/disk_cache/simple/post_doom_waiter.cc
index 2f6464fd08a..0f355c33462 100644
--- a/chromium/net/disk_cache/simple/post_doom_waiter.cc
+++ b/chromium/net/disk_cache/simple/post_doom_waiter.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/check_op.h"
#include "net/disk_cache/simple/simple_histogram_macros.h"
namespace disk_cache {
diff --git a/chromium/net/disk_cache/simple/simple_entry_impl.cc b/chromium/net/disk_cache/simple/simple_entry_impl.cc
index e59b6073527..2e3eadcb2d5 100644
--- a/chromium/net/disk_cache/simple/simple_entry_impl.cc
+++ b/chromium/net/disk_cache/simple/simple_entry_impl.cc
@@ -13,8 +13,9 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/callback.h"
+#include "base/check_op.h"
#include "base/location.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/task_runner.h"
#include "base/task_runner_util.h"
@@ -1743,8 +1744,10 @@ void SimpleEntryImpl::UpdateDataFromEntryStat(
data_size_[i] = entry_stat.data_size(i);
}
sparse_data_size_ = entry_stat.sparse_data_size();
- if (doom_state_ == DOOM_NONE && backend_.get()) {
- backend_->index()->UpdateEntrySize(
+
+ SimpleBackendImpl* backend_ptr = backend_.get();
+ if (doom_state_ == DOOM_NONE && backend_ptr) {
+ backend_ptr->index()->UpdateEntrySize(
entry_hash_, base::checked_cast<uint32_t>(GetDiskUsage()));
}
}
diff --git a/chromium/net/disk_cache/simple/simple_entry_operation.cc b/chromium/net/disk_cache/simple/simple_entry_operation.cc
index 70a65564654..ebe9cada319 100644
--- a/chromium/net/disk_cache/simple/simple_entry_operation.cc
+++ b/chromium/net/disk_cache/simple/simple_entry_operation.cc
@@ -6,7 +6,6 @@
#include <limits.h>
-#include "base/logging.h"
#include "net/base/io_buffer.h"
#include "net/disk_cache/disk_cache.h"
#include "net/disk_cache/simple/simple_entry_impl.h"
diff --git a/chromium/net/disk_cache/simple/simple_file_tracker.cc b/chromium/net/disk_cache/simple/simple_file_tracker.cc
index 4d12cebfecd..5bea31b767f 100644
--- a/chromium/net/disk_cache/simple/simple_file_tracker.cc
+++ b/chromium/net/disk_cache/simple/simple_file_tracker.cc
@@ -10,6 +10,7 @@
#include <utility>
#include "base/files/file.h"
+#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/synchronization/lock.h"
#include "net/disk_cache/simple/simple_histogram_enums.h"
diff --git a/chromium/net/disk_cache/simple/simple_file_tracker_unittest.cc b/chromium/net/disk_cache/simple/simple_file_tracker_unittest.cc
index d46362fa9a5..0c34224a5a4 100644
--- a/chromium/net/disk_cache/simple/simple_file_tracker_unittest.cc
+++ b/chromium/net/disk_cache/simple/simple_file_tracker_unittest.cc
@@ -8,7 +8,6 @@
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
diff --git a/chromium/net/disk_cache/simple/simple_histogram_macros.h b/chromium/net/disk_cache/simple/simple_histogram_macros.h
index 84d0a57e490..d7d36f38d2d 100644
--- a/chromium/net/disk_cache/simple/simple_histogram_macros.h
+++ b/chromium/net/disk_cache/simple/simple_histogram_macros.h
@@ -18,27 +18,28 @@
// TODO(pasko): add histograms for shader cache as soon as it becomes possible
// for a user to get shader cache with the |SimpleBackendImpl| without altering
// any flags.
-// TODO(mythria): add histograms for generated_code_cache when we actually start
-// using the generated_code_cache.
-#define SIMPLE_CACHE_UMA(uma_type, uma_name, cache_type, ...) \
- do { \
- switch (cache_type) { \
- case net::DISK_CACHE: \
- SIMPLE_CACHE_THUNK(uma_type, \
- ("SimpleCache.Http." uma_name, ##__VA_ARGS__)); \
- break; \
- case net::APP_CACHE: \
- SIMPLE_CACHE_THUNK(uma_type, \
- ("SimpleCache.App." uma_name, ##__VA_ARGS__)); \
- break; \
- case net::GENERATED_BYTE_CODE_CACHE: \
- case net::GENERATED_NATIVE_CODE_CACHE: \
- case net::SHADER_CACHE: \
- break; \
- default: \
- NOTREACHED(); \
- break; \
- } \
+#define SIMPLE_CACHE_UMA(uma_type, uma_name, cache_type, ...) \
+ do { \
+ switch (cache_type) { \
+ case net::DISK_CACHE: \
+ SIMPLE_CACHE_THUNK(uma_type, \
+ ("SimpleCache.Http." uma_name, ##__VA_ARGS__)); \
+ break; \
+ case net::APP_CACHE: \
+ SIMPLE_CACHE_THUNK(uma_type, \
+ ("SimpleCache.App." uma_name, ##__VA_ARGS__)); \
+ break; \
+ case net::GENERATED_BYTE_CODE_CACHE: \
+ SIMPLE_CACHE_THUNK(uma_type, \
+ ("SimpleCache.Code." uma_name, ##__VA_ARGS__)); \
+ break; \
+ case net::GENERATED_NATIVE_CODE_CACHE: \
+ case net::SHADER_CACHE: \
+ break; \
+ default: \
+ NOTREACHED(); \
+ break; \
+ } \
} while (0)
#endif // NET_DISK_CACHE_SIMPLE_SIMPLE_HISTOGRAM_MACROS_H_
diff --git a/chromium/net/disk_cache/simple/simple_index.cc b/chromium/net/disk_cache/simple/simple_index.cc
index 38ee9dca625..0775f57ff5a 100644
--- a/chromium/net/disk_cache/simple/simple_index.cc
+++ b/chromium/net/disk_cache/simple/simple_index.cc
@@ -11,8 +11,8 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/check_op.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/pickle.h"
#include "base/strings/string_number_conversions.h"
@@ -58,6 +58,11 @@ static const int kEstimatedEntryOverhead = 512;
namespace disk_cache {
+const base::Feature
+ SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache{
+ "SimpleCacheDisableEvictionSizeHeuristicForCodeCache",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
EntryMetadata::EntryMetadata()
: last_used_time_seconds_since_epoch_(0),
entry_size_256b_chunks_(0),
@@ -417,6 +422,12 @@ void SimpleIndex::StartEvictionIfNeeded() {
MEMORY_KB, "Eviction.MaxCacheSizeOnStart2", cache_type_,
static_cast<base::HistogramBase::Sample>(max_size_ / kBytesInKb));
+ bool use_size_heuristic = true;
+ if (cache_type_ == net::GENERATED_BYTE_CODE_CACHE) {
+ use_size_heuristic = !base::FeatureList::IsEnabled(
+ kSimpleCacheDisableEvictionSizeHeuristicForCodeCache);
+ }
+
// Flatten for sorting.
std::vector<std::pair<uint64_t, const EntrySet::value_type*>> entries;
entries.reserve(entries_set_.size());
@@ -428,7 +439,8 @@ void SimpleIndex::StartEvictionIfNeeded() {
//
// 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;
+ if (use_size_heuristic)
+ 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);
diff --git a/chromium/net/disk_cache/simple/simple_index.h b/chromium/net/disk_cache/simple/simple_index.h
index 17ca017582f..f8cdd3c102d 100644
--- a/chromium/net/disk_cache/simple/simple_index.h
+++ b/chromium/net/disk_cache/simple/simple_index.h
@@ -14,6 +14,7 @@
#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"
@@ -242,6 +243,8 @@ class NET_EXPORT_PRIVATE SimpleIndex
FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWriteExecuted);
FRIEND_TEST_ALL_PREFIXES(SimpleIndexTest, DiskWritePostponed);
FRIEND_TEST_ALL_PREFIXES(SimpleIndexAppCacheTest, DiskWriteQueued);
+ FRIEND_TEST_ALL_PREFIXES(SimpleIndexCodeCacheTest, DisableEvictBySize);
+ FRIEND_TEST_ALL_PREFIXES(SimpleIndexCodeCacheTest, EnableEvictBySize);
void StartEvictionIfNeeded();
void EvictionDone(int result);
@@ -309,6 +312,9 @@ class NET_EXPORT_PRIVATE SimpleIndex
// background we can write the index much more frequently, to insure fresh
// index on next startup.
bool app_on_background_ = false;
+
+ static const base::Feature
+ kSimpleCacheDisableEvictionSizeHeuristicForCodeCache;
};
} // namespace disk_cache
diff --git a/chromium/net/disk_cache/simple/simple_index_file_unittest.cc b/chromium/net/disk_cache/simple/simple_index_file_unittest.cc
index 0b59cb088dc..c193f72fd47 100644
--- a/chromium/net/disk_cache/simple/simple_index_file_unittest.cc
+++ b/chromium/net/disk_cache/simple/simple_index_file_unittest.cc
@@ -6,12 +6,12 @@
#include <memory>
+#include "base/check.h"
#include "base/files/file.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/hash/hash.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/pickle.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
diff --git a/chromium/net/disk_cache/simple/simple_index_unittest.cc b/chromium/net/disk_cache/simple/simple_index_unittest.cc
index d1b8fe15487..e6e8e932d64 100644
--- a/chromium/net/disk_cache/simple/simple_index_unittest.cc
+++ b/chromium/net/disk_cache/simple/simple_index_unittest.cc
@@ -12,11 +12,11 @@
#include "base/bind.h"
#include "base/files/scoped_temp_dir.h"
#include "base/hash/hash.h"
-#include "base/logging.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"
@@ -186,6 +186,13 @@ class SimpleIndexAppCacheTest : public SimpleIndexTest {
net::CacheType CacheType() const override { return net::APP_CACHE; }
};
+class SimpleIndexCodeCacheTest : public SimpleIndexTest {
+ protected:
+ net::CacheType CacheType() const override {
+ return net::GENERATED_BYTE_CODE_CACHE;
+ }
+};
+
TEST_F(EntryMetadataTest, Basics) {
EntryMetadata entry_metadata;
EXPECT_EQ(base::Time(), entry_metadata.GetLastUsedTime());
@@ -634,6 +641,74 @@ TEST_F(SimpleIndexTest, EvictBySize) {
ASSERT_EQ(1u, last_doom_entry_hashes().size());
}
+TEST_F(SimpleIndexCodeCacheTest, DisableEvictBySize) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatures(
+ {SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache}, {});
+
+ 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.
+ // Since evict by size is supposed to be disabled, it evicts in LRU order,
+ // so entries 1 and 2 are both kicked out.
+ 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(SimpleIndexCodeCacheTest, EnableEvictBySize) {
+ base::test::ScopedFeatureList scoped_feature_list;
+ scoped_feature_list.InitWithFeatures(
+ {}, {SimpleIndex::kSimpleCacheDisableEvictionSizeHeuristicForCodeCache});
+
+ 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.
+ // This has size-weighting enabled, so it end sup kickicking out entry
+ // 2, which is biggest, and is enough, even though <1> is older.
+ index()->UpdateEntrySize(hashes_.at<3>(), 40000u);
+ EXPECT_EQ(1, doom_entries_calls());
+ EXPECT_EQ(2, index()->GetEntryCount());
+ EXPECT_TRUE(index()->Has(hashes_.at<1>()));
+ EXPECT_FALSE(index()->Has(hashes_.at<2>()));
+ EXPECT_TRUE(index()->Has(hashes_.at<3>()));
+ ASSERT_EQ(1u, last_doom_entry_hashes().size());
+}
+
// Same as test above, but using much older entries to make sure that small
// things eventually get evictied.
TEST_F(SimpleIndexTest, EvictBySize2) {
diff --git a/chromium/net/disk_cache/simple/simple_net_log_parameters.cc b/chromium/net/disk_cache/simple/simple_net_log_parameters.cc
index ce4889b81a0..ee3241ba989 100644
--- a/chromium/net/disk_cache/simple/simple_net_log_parameters.cc
+++ b/chromium/net/disk_cache/simple/simple_net_log_parameters.cc
@@ -7,9 +7,9 @@
#include <utility>
#include "base/bind.h"
+#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/format_macros.h"
-#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "net/base/net_errors.h"
diff --git a/chromium/net/disk_cache/simple/simple_util.cc b/chromium/net/disk_cache/simple/simple_util.cc
index 41fc7e5954f..59d3b919418 100644
--- a/chromium/net/disk_cache/simple/simple_util.cc
+++ b/chromium/net/disk_cache/simple/simple_util.cc
@@ -6,10 +6,10 @@
#include <limits>
+#include "base/check_op.h"
#include "base/files/file_util.h"
#include "base/format_macros.h"
#include "base/hash/sha1.h"
-#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/net/disk_cache/simple/simple_util_unittest.cc b/chromium/net/disk_cache/simple/simple_util_unittest.cc
index 442dc425f8c..675f310539e 100644
--- a/chromium/net/disk_cache/simple/simple_util_unittest.cc
+++ b/chromium/net/disk_cache/simple/simple_util_unittest.cc
@@ -5,7 +5,6 @@
#include <stdint.h>
#include <string>
-#include "base/logging.h"
#include "net/disk_cache/simple/simple_util.h"
#include "testing/gtest/include/gtest/gtest.h"