Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Unified Diff: net/disk_cache/simple/simple_index_file.h

Issue 22927018: Avoid fragmenting the heap too much while reconstructing the index. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/disk_cache/simple/simple_index_file.h
diff --git a/net/disk_cache/simple/simple_index_file.h b/net/disk_cache/simple/simple_index_file.h
index b536df9a1e72cbaaa8a32f01ef33e82fa6f915d3..9885c8f970d3629e06ea53a13786a7f1629eda4a 100644
--- a/net/disk_cache/simple/simple_index_file.h
+++ b/net/disk_cache/simple/simple_index_file.h
@@ -97,6 +97,9 @@ class NET_EXPORT_PRIVATE SimpleIndexFile {
private:
friend class WrappedSimpleIndexFile;
+ // Used for cache directory traversal.
+ typedef base::Callback<void (const std::string& file_name)> EntryFileCallback;
+
// When loading the entries from disk, add this many extra hash buckets to
// prevent reallocation on the IO thread when merging in new live entries.
static const int kExtraSizeForMerge = 512;
@@ -123,6 +126,24 @@ class NET_EXPORT_PRIVATE SimpleIndexFile {
static void Deserialize(const char* data, int data_len,
SimpleIndexLoadResult* out_result);
+ // Implemented either in simple_index_file_posix.cc or
+ // simple_index_file_win.cc. base::FileEnumerator turned out to be very
+ // expensive in terms of memory usage therefore it's used only on non-POSIX
+ // environments for convenience (for now). Note that this function is
+ // synchronous although its signature could suggest otherwise. Returns
+ // whether the traversal succeeded.
+ static bool TraverseCacheDirectory(
+ const std::string& cache_path,
+ const EntryFileCallback& entry_file_callback);
+
+ // Called for each cache directory traversal iteration. The provided
+ // non-cleared |buffer| can be used accross iterations to avoid doing too many
+ // heap allocations given that cache directories can be very large.
+ static void ProcessEntryFile(const std::string& cache_path,
gavinp 2013/08/20 20:13:45 I suggest you want: static void ProcessEntryFile(
Philippe 2013/08/21 09:37:33 I want to keep the hash extraction in this method
+ std::string* buffer,
gavinp 2013/08/20 18:53:23 I'm a bit confused at this buffer being a std::str
Philippe 2013/08/21 09:37:33 I replaced it with a vector that does now a single
+ SimpleIndex::EntrySet* entries,
+ const std::string& file_name);
+
// Scan the index directory for entries, returning an EntrySet of all entries
// found.
static void SyncRestoreFromDisk(const base::FilePath& cache_directory,
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index_file.cc » ('j') | net/disk_cache/simple/simple_index_file.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698