summaryrefslogtreecommitdiffstats
path: root/base/shared_memory_win.cc
diff options
context:
space:
mode:
authorsehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 15:40:24 +0000
committersehr@google.com <sehr@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-25 15:40:24 +0000
commit9768435ce177fd81018fcd4654fe95add34c1cbf (patch)
tree101db6aa82f355b29fb76502c09a56f1fa85190e /base/shared_memory_win.cc
parentcebd413af76d96d534a5f70a2eeb356dde3fa392 (diff)
downloadchromium_src-9768435ce177fd81018fcd4654fe95add34c1cbf.zip
chromium_src-9768435ce177fd81018fcd4654fe95add34c1cbf.tar.gz
chromium_src-9768435ce177fd81018fcd4654fe95add34c1cbf.tar.bz2
Round the size of shared memory regions up to 64K. This allows
native client modules to map these regions. With this fix, Pepper audio works on all three platforms. Review URL: http://codereview.chromium.org/1242006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42621 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/shared_memory_win.cc')
-rw-r--r--base/shared_memory_win.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/base/shared_memory_win.cc b/base/shared_memory_win.cc
index 4afad3a..7d3e4cd 100644
--- a/base/shared_memory_win.cc
+++ b/base/shared_memory_win.cc
@@ -65,10 +65,17 @@ bool SharedMemory::Create(const std::wstring &name, bool read_only,
bool open_existing, uint32 size) {
DCHECK(mapped_file_ == NULL);
+ // NaCl's memory allocator requires 0mod64K alignment and size for
+ // shared memory objects. To allow passing shared memory to NaCl,
+ // therefore we round the size actually created to the nearest 64K unit.
+ // To avoid client impact, we continue to retain the size as the
+ // actual requested size.
+ uint32 rounded_size = (size + 0xffff) & ~0xffff;
name_ = name;
read_only_ = read_only;
mapped_file_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
- read_only_ ? PAGE_READONLY : PAGE_READWRITE, 0, static_cast<DWORD>(size),
+ read_only_ ? PAGE_READONLY : PAGE_READWRITE, 0,
+ static_cast<DWORD>(rounded_size),
name.empty() ? NULL : name.c_str());
if (!mapped_file_)
return false;