Chromium Code Reviews| Index: base/files/memory_mapped_file.h |
| diff --git a/base/files/memory_mapped_file.h b/base/files/memory_mapped_file.h |
| index 8a7f045f351a0365d496f37f5824607cacfdc12e..1ab1b459442e3ae7eb0fdb1fed639cff8325a4e2 100644 |
| --- a/base/files/memory_mapped_file.h |
| +++ b/base/files/memory_mapped_file.h |
| @@ -48,15 +48,15 @@ class BASE_EXPORT MemoryMappedFile { |
| // read only. If this object already points to a valid memory mapped file |
| // then this method will fail and return false. If it cannot open the file, |
| // the file does not exist, or the memory mapping fails, it will return false. |
| - // Later we may want to allow the user to specify access. |
| bool Initialize(const FilePath& file_name); |
| - // As above, but works with an already-opened file. MemoryMappedFile takes |
| - // ownership of |file| and closes it when done. |
| - bool Initialize(File file); |
| + // As above, works with an already-opened file, closes it when done, and |
|
wuchengli
2014/09/01 09:19:25
s/works/but works/?
Tom Sepez
2014/09/02 16:57:15
I'd rather have a InitializeForTesting() method th
|
| + // enables write permission when |write| is true. |
| + bool Initialize(File file, bool write); |
| - // As above, but works with a region of an already-opened file. |
| - bool Initialize(File file, const Region& region); |
| + // As above, but works with a region of an already-opened file and enables |
| + // write permission when |write| is true. |
|
wuchengli
2014/09/01 09:19:25
Remove "and enables write permission when |write|
|
| + bool Initialize(File file, const Region& region, bool write); |
| #if defined(OS_WIN) |
| // Opens an existing file and maps it as an image section. Please refer to |
| @@ -64,7 +64,7 @@ class BASE_EXPORT MemoryMappedFile { |
| bool InitializeAsImageSection(const FilePath& file_name); |
| #endif // OS_WIN |
| - const uint8* data() const { return data_; } |
| + uint8* data() const { return data_; } |
|
Tom Sepez
2014/09/02 16:57:15
You might want, say, mutable_data_for_testing() to
|
| size_t length() const { return length_; } |
| // Is file_ a valid file handle that points to an open, memory mapped file? |
| @@ -85,7 +85,8 @@ class BASE_EXPORT MemoryMappedFile { |
| // Map the file to memory, set data_ to that memory address. Return true on |
| // success, false on any kind of failure. This is a helper for Initialize(). |
| - bool MapFileRegionToMemory(const Region& region); |
| + // - |write| is used to enable write permission of mmap. |
| + bool MapFileRegionToMemory(const Region& region, bool write); |
| // Closes all open handles. |
| void CloseHandles(); |