diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 22:55:17 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-16 22:55:17 +0000 |
commit | cb6037d67847a6341eea166baf1d4051667a0b88 (patch) | |
tree | 2b766762057e96d758385b96e2a576d7b6690d54 /base/file_util.cc | |
parent | f9be34d622561d5599603b41d1c43d595e503426 (diff) | |
download | chromium_src-cb6037d67847a6341eea166baf1d4051667a0b88.zip chromium_src-cb6037d67847a6341eea166baf1d4051667a0b88.tar.gz chromium_src-cb6037d67847a6341eea166baf1d4051667a0b88.tar.bz2 |
reland 31875. Revert was:
------
Revert 31875 to see whether it fixes reliability bot.
BUG=25677
TEST=None
------
TBR=huanr
Review URL: http://codereview.chromium.org/397017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@32112 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util.cc')
-rw-r--r-- | base/file_util.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/base/file_util.cc b/base/file_util.cc index 4cde773..8d1b517 100644 --- a/base/file_util.cc +++ b/base/file_util.cc @@ -267,6 +267,20 @@ MemoryMappedFile::~MemoryMappedFile() { 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 @@ bool MemoryMappedFile::Initialize(const FilePath& file_name) { 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; } |