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

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: Address Egor's and Gavin's comments 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..3c33de3f5ad0509f20b93872494f4b2a00aa1e88 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 base::FilePath&)> 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;
@@ -120,9 +123,19 @@ class NET_EXPORT_PRIVATE SimpleIndexFile {
// Given the contents of an index file |data| of length |data_len|, returns
// the corresponding EntrySet. Returns NULL on error.
- static void Deserialize(const char* data, int data_len,
+ static void Deserialize(const char* data,
+ int data_len,
gavinp 2013/08/21 15:31:58 Nit: don't do this change. It's acceptable for clo
Philippe 2013/08/21 15:37:50 Done.
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). Returns whether the traversal
+ // succeeded.
+ static bool TraverseCacheDirectory(
+ const base::FilePath& cache_path,
+ const EntryFileCallback& entry_file_callback);
+
// Scan the index directory for entries, returning an EntrySet of all entries
// found.
static void SyncRestoreFromDisk(const base::FilePath& cache_directory,
@@ -144,9 +157,6 @@ class NET_EXPORT_PRIVATE SimpleIndexFile {
const base::FilePath index_file_;
const base::FilePath temp_index_file_;
- static const char kIndexFileName[];
- static const char kTempIndexFileName[];
-
DISALLOW_COPY_AND_ASSIGN(SimpleIndexFile);
};
« 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