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

Unified Diff: base/files/memory_mapped_file.h

Issue 430583005: Make VEA test support videos with different coded size and visible size (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review comments of patch set 11 Created 6 years, 4 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
« no previous file with comments | « no previous file | base/files/memory_mapped_file.cc » ('j') | base/files/memory_mapped_file_unittest.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..17ffb80a25302a5d850fd84fca714966c49511a5 100644
--- a/base/files/memory_mapped_file.h
+++ b/base/files/memory_mapped_file.h
@@ -48,7 +48,6 @@ 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
@@ -58,18 +57,29 @@ class BASE_EXPORT MemoryMappedFile {
// As above, but works with a region of an already-opened file.
bool Initialize(File file, const Region& region);
+ // As above, works with an already-opened file and 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 and enables
+ // write permission when |write| is true.
+ 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
// the Initialize function above for additional information.
bool InitializeAsImageSection(const FilePath& file_name);
#endif // OS_WIN
- const uint8* data() const { return data_; }
+ uint8* data() const { return data_; }
size_t length() const { return length_; }
// Is file_ a valid file handle that points to an open, memory mapped file?
bool IsValid() const;
+ // Closes all open handles.
+ void CloseHandles();
wuchengli 2014/09/01 06:57:15 We shouldn't expose an API for the testing purpose
henryhsu 2014/09/01 07:49:49 Done.
+
private:
// Given the arbitrarily aligned memory region [start, size], returns the
// boundaries of the region aligned to the granularity specified by the OS,
@@ -85,10 +95,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);
-
- // Closes all open handles.
- void CloseHandles();
+ // - |write| is used to enable write permission of mmap.
+ bool MapFileRegionToMemory(const Region& region, bool write);
File file_;
uint8* data_;
« no previous file with comments | « no previous file | base/files/memory_mapped_file.cc » ('j') | base/files/memory_mapped_file_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698