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

Unified Diff: base/files/memory_mapped_file.h

Issue 394313002: Add support for loading pak files from arbitrary file regions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address first willchan@ comments Created 6 years, 5 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
Index: base/files/memory_mapped_file.h
diff --git a/base/files/memory_mapped_file.h b/base/files/memory_mapped_file.h
index b02d8cfbdae09b89159675495313eae521a7576e..6e06f2033319d0fe916f210cb5450464fa1bb0a7 100644
--- a/base/files/memory_mapped_file.h
+++ b/base/files/memory_mapped_file.h
@@ -35,6 +35,9 @@ class BASE_EXPORT MemoryMappedFile {
// ownership of |file| and closes it when done.
bool Initialize(File file);
+ // As above, but works with a region of an already-opened file.
+ bool Initialize(File file, const base::File::Region& region);
willchan no longer on Chromium 2014/07/22 20:45:47 No need for base::
Primiano Tucci (use gerrit) 2014/07/23 23:17:38 Shame on me. sorry I should have rechecked all the
+
#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.
@@ -48,9 +51,21 @@ class BASE_EXPORT MemoryMappedFile {
bool IsValid() const;
private:
+ // Given the arbitrarily aligned memory region [start, size], returns the
+ // boundaries of the region aligned to the granularity specified by the OS,
+ // (a page on Linux, ~32k on Windows) as follows:
+ // - |aligned_start| is page aligned and <= |start|.
+ // - |aligned_size| is a multiple of the VM granularity and >= |size|.
+ // - |offset| is the displacement of |start| w.r.t |aligned_start|.
+ static void CalculateVMAlignedBoundaries(int64 start,
+ int64 size,
+ int64* aligned_start,
+ int64* aligned_size,
+ int32* offset);
+
// 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 MapFileToMemory();
+ bool MapFileRegionToMemory(const base::File::Region& region);
willchan no longer on Chromium 2014/07/22 20:45:47 No need for base::
Primiano Tucci (use gerrit) 2014/07/23 23:17:38 Done.
// Closes all open handles.
void CloseHandles();

Powered by Google App Engine
This is Rietveld 408576698