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

Unified Diff: net/disk_cache/blockfile/mapped_file.cc

Issue 206453003: Move Preload() code to MappedFile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reworded comment Created 6 years, 9 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
« no previous file with comments | « net/disk_cache/blockfile/mapped_file.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/blockfile/mapped_file.cc
diff --git a/net/disk_cache/blockfile/mapped_file.cc b/net/disk_cache/blockfile/mapped_file.cc
index 4b0f27fc0972da59294c07d0bb6b45c7575a7e9d..d26cead89aab2064646b598e8b7b0ac5f0520c1e 100644
--- a/net/disk_cache/blockfile/mapped_file.cc
+++ b/net/disk_cache/blockfile/mapped_file.cc
@@ -4,6 +4,10 @@
#include "net/disk_cache/blockfile/mapped_file.h"
+#include <algorithm>
+
+#include "base/memory/scoped_ptr.h"
+
namespace disk_cache {
// Note: Most of this class is implemented in platform-specific files.
@@ -32,4 +36,11 @@ bool MappedFile::Store(const FileBlock* block,
return Write(block->buffer(), block->size(), offset, callback, completed);
}
+bool MappedFile::Preload() {
+ size_t file_len = GetLength();
+ scoped_ptr<char[]> buf(new char[file_len]);
+ if (!Read(buf.get(), file_len, 0))
+ return false;
+ return true;
+}
} // namespace disk_cache
« no previous file with comments | « net/disk_cache/blockfile/mapped_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698