Chromium Code Reviews| Index: base/files/memory_mapped_file_win.cc |
| diff --git a/base/files/memory_mapped_file_win.cc b/base/files/memory_mapped_file_win.cc |
| index 4e7e934e1c858823f13a2c7842a1daa0e390591b..b6756fc535f17a38dca2f51286d99cf8e07739cb 100644 |
| --- a/base/files/memory_mapped_file_win.cc |
| +++ b/base/files/memory_mapped_file_win.cc |
| @@ -19,13 +19,17 @@ bool MemoryMappedFile::InitializeAsImageSection(const FilePath& file_name) { |
| } |
| bool MemoryMappedFile::MapFileRegionToMemory( |
| - const MemoryMappedFile::Region& region) { |
| + const MemoryMappedFile::Region& region, bool write) { |
| ThreadRestrictions::AssertIOAllowed(); |
| if (!file_.IsValid()) |
| return false; |
| - int flags = image_ ? SEC_IMAGE | PAGE_READONLY : PAGE_READONLY; |
| + int flags = 0; |
| + if (image_) |
| + flags = SEC_IMAGE | PAGE_READONLY; |
| + else |
| + flags = write ? PAGE_READWRITE : PAGE_READONLY; |
|
wuchengli
2014/09/01 09:19:25
You forgot to address this comment?
From MSDN, it
|
| file_mapping_.Set(::CreateFileMapping(file_.GetPlatformFile(), NULL, |
| flags, 0, 0, NULL)); |
| @@ -66,8 +70,9 @@ bool MemoryMappedFile::MapFileRegionToMemory( |
| length_ = static_cast<size_t>(region.size); |
| } |
| + int map_access = write ? FILE_MAP_WRITE : FILE_MAP_READ; |
| data_ = static_cast<uint8*>(::MapViewOfFile(file_mapping_.Get(), |
| - FILE_MAP_READ, |
| + map_access, |
| map_start.HighPart, |
| map_start.LowPart, |
| map_size)); |