Index: base/files/memory_mapped_file.cc |
diff --git a/base/files/memory_mapped_file.cc b/base/files/memory_mapped_file.cc |
index 891fcffc4cb434b74729657b7981a400729f2e61..bad1792ec3de4ea32be250de2d0515d74e263731 100644 |
--- a/base/files/memory_mapped_file.cc |
+++ b/base/files/memory_mapped_file.cc |
@@ -16,10 +16,11 @@ const MemoryMappedFile::Region MemoryMappedFile::Region::kWholeFile( |
MemoryMappedFile::Region::Region(base::LinkerInitialized) : offset(0), size(0) { |
} |
+MemoryMappedFile::Region::Region() : offset(-1), size(-1) { |
+} |
+ |
MemoryMappedFile::Region::Region(int64 offset, int64 size) |
: offset(offset), size(size) { |
- DCHECK_GE(offset, 0); |
- DCHECK_GT(size, 0); |
} |
bool MemoryMappedFile::Region::operator==( |
@@ -27,6 +28,11 @@ bool MemoryMappedFile::Region::operator==( |
return other.offset == offset && other.size == size; |
} |
+bool MemoryMappedFile::Region::operator!=( |
+ const MemoryMappedFile::Region& other) const { |
+ return other.offset != offset || other.size != size; |
Lei Zhang
2015/06/02 20:25:43
Some people just do !(this == other) here, especia
|
+} |
+ |
MemoryMappedFile::~MemoryMappedFile() { |
CloseHandles(); |
} |
@@ -59,6 +65,11 @@ bool MemoryMappedFile::Initialize(File file, const Region& region) { |
if (IsValid()) |
return false; |
+ if (region != Region::kWholeFile) { |
+ DCHECK_GE(region.offset, 0); |
+ DCHECK_GT(region.size, 0); |
+ } |
+ |
file_ = file.Pass(); |
if (!MapFileRegionToMemory(region)) { |