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

Unified Diff: base/file_util.cc

Issue 14073: Implement the memory mapped file class for posix. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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: base/file_util.cc
===================================================================
--- base/file_util.cc (revision 6919)
+++ base/file_util.cc (working copy)
@@ -275,6 +275,29 @@
return fclose(file) == 0;
}
+///////////////////////////////////////////////
+// MemoryMappedFile
+
+MemoryMappedFile::~MemoryMappedFile() {
+ CloseHandles();
+}
+
+bool MemoryMappedFile::Initialize(const FilePath& file_name) {
+ if (IsValid())
+ return false;
+
+ if (!MapFileToMemory(file_name)) {
+ CloseHandles();
+ return false;
+ }
+
+ return true;
+}
+
+bool MemoryMappedFile::IsValid() {
+ return data_ != NULL;
+}
+
// Deprecated functions ----------------------------------------------------
bool AbsolutePath(std::wstring* path_str) {
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | base/file_util_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698