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..848988672644b9760e30891fa9030e2ac82b886a 100644 |
--- a/net/disk_cache/simple/simple_index_file.h |
+++ b/net/disk_cache/simple/simple_index_file.h |
@@ -15,6 +15,7 @@ |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
#include "base/pickle.h" |
+#include "base/platform_file.h" |
gavinp
2013/08/21 11:49:47
Pourquoi? Just forward declare base::PlatformFileI
Philippe
2013/08/21 12:41:38
Yeah my bad. I used to have GetPlatformFileInfo()
|
#include "base/port.h" |
#include "net/base/net_export.h" |
#include "net/disk_cache/simple/simple_index.h" |
@@ -97,6 +98,9 @@ class NET_EXPORT_PRIVATE SimpleIndexFile { |
private: |
friend class WrappedSimpleIndexFile; |
+ // Used for cache directory traversal. |
+ typedef base::Callback<void (const char* 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; |
@@ -120,9 +124,32 @@ 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, |
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); |
+ |
+ // Returns whether file info was successfully retrieved. |
+ static bool GetPlatformFileInfo(const char* path, |
+ base::PlatformFileInfo* info); |
+ |
+ // 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/21 11:49:47
Can this method be moved into an anonymous namespa
Philippe
2013/08/21 12:41:38
Yeah good point.
|
+ std::vector<char>* buffer, |
gavinp
2013/08/21 11:49:47
char*! Let your inner C programmer out.
Philippe
2013/08/21 12:41:38
Ahaha :) I got rid of the buffer.
|
+ SimpleIndex::EntrySet* entries, |
+ const char* file_name); |
+ |
// Scan the index directory for entries, returning an EntrySet of all entries |
// found. |
static void SyncRestoreFromDisk(const base::FilePath& cache_directory, |