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

Unified Diff: base/file_util_posix.cc

Issue 12321062: base: Move MemoryMappedFile out of file_util.h and into its own header file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chrome_frame Created 7 years, 10 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: base/file_util_posix.cc
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc
index 62bc9b3f9b061ced5e1201f1b2ddc405e29f321a..ea74ea6368af2eee09cb253720e7e71057cf0251 100644
--- a/base/file_util_posix.cc
+++ b/base/file_util_posix.cc
@@ -859,46 +859,6 @@ bool FileEnumerator::ReadDirectory(std::vector<DirectoryEntryInfo>* entries,
return true;
}
-///////////////////////////////////////////////
-// MemoryMappedFile
-
-MemoryMappedFile::MemoryMappedFile()
- : file_(base::kInvalidPlatformFileValue),
- data_(NULL),
- length_(0) {
-}
-
-bool MemoryMappedFile::MapFileToMemoryInternal() {
- base::ThreadRestrictions::AssertIOAllowed();
-
- struct stat file_stat;
- if (fstat(file_, &file_stat) == base::kInvalidPlatformFileValue) {
- DLOG(ERROR) << "Couldn't fstat " << file_ << ", errno " << errno;
- return false;
- }
- length_ = file_stat.st_size;
-
- data_ = static_cast<uint8*>(
- mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0));
- if (data_ == MAP_FAILED)
- DLOG(ERROR) << "Couldn't mmap " << file_ << ", errno " << errno;
-
- return data_ != MAP_FAILED;
-}
-
-void MemoryMappedFile::CloseHandles() {
- base::ThreadRestrictions::AssertIOAllowed();
-
- if (data_ != NULL)
- munmap(data_, length_);
- if (file_ != base::kInvalidPlatformFileValue)
- ignore_result(HANDLE_EINTR(close(file_)));
-
- data_ = NULL;
- length_ = 0;
- file_ = base::kInvalidPlatformFileValue;
-}
-
bool HasFileBeenModifiedSince(const FileEnumerator::FindInfo& find_info,
const base::Time& cutoff_time) {
return static_cast<time_t>(find_info.stat.st_mtime) >= cutoff_time.ToTimeT();

Powered by Google App Engine
This is Rietveld 408576698