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

Unified Diff: base/file_util.cc

Issue 397017: reland 31875. Revert was:... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util.cc
===================================================================
--- base/file_util.cc (revision 32085)
+++ base/file_util.cc (working copy)
@@ -267,6 +267,20 @@
CloseHandles();
}
+bool MemoryMappedFile::Initialize(base::PlatformFile file) {
+ if (IsValid())
+ return false;
+
+ file_ = file;
+
+ if (!MapFileToMemoryInternal()) {
+ CloseHandles();
+ return false;
+ }
+
+ return true;
+}
+
bool MemoryMappedFile::Initialize(const FilePath& file_name) {
if (IsValid())
return false;
@@ -279,6 +293,19 @@
return true;
}
+bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) {
+ file_ = base::CreatePlatformFile(file_name,
+ base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ,
+ NULL);
+
+ if (file_ == base::kInvalidPlatformFileValue) {
+ LOG(ERROR) << "Couldn't open " << file_name.value();
+ return false;
+ }
+
+ return MapFileToMemoryInternal();
+}
+
bool MemoryMappedFile::IsValid() {
return data_ != NULL;
}
« no previous file with comments | « base/file_util.h ('k') | base/file_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698