summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 00:10:06 +0000
committeraelias@chromium.org <aelias@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-29 00:10:06 +0000
commit60e7d52240664fac7ebbbc571173e4c5d0d1fad4 (patch)
tree1de74de49f32bca74620abd1e48fd400e2d20a5b
parent89d7e9f519989ec34404d92421a7e87c4f242244 (diff)
downloadchromium_src-60e7d52240664fac7ebbbc571173e4c5d0d1fad4.zip
chromium_src-60e7d52240664fac7ebbbc571173e4c5d0d1fad4.tar.gz
chromium_src-60e7d52240664fac7ebbbc571173e4c5d0d1fad4.tar.bz2
Fix Android-specific shmem size code.
In the past, this OS_ANDROID block assigned a value to created_size_ (which appears not to have been used for anything), whereas mapped_size_ used the cross-platform codepath. In r191098 jschuh@ disabled the normal assignment of mapped_size_ on Android and made this old code set the value of mapped_size_. This Android code block was there to set "bytes" in when Map is called with a size argument of 0. So after r191098, mapped_size_ was never set when the argument was nonzero. Bring back the mapped_size_ setting and clean up the Android block. NOTRY=true BUG=224646 Review URL: https://chromiumcodereview.appspot.com/13133004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@191250 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--base/shared_memory_posix.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 607d665..820efa2 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -224,18 +224,14 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
return false;
#if defined(OS_ANDROID)
+ // On Android, Map can be called with a size and offset of zero to use the
+ // ashmem-determined size.
if (bytes == 0) {
+ DCHECK_EQ(0, offset);
int ashmem_bytes = ashmem_get_size_region(mapped_file_);
if (ashmem_bytes < 0)
return false;
-
- DCHECK_GE(static_cast<uint32>(ashmem_bytes), bytes);
- // The caller wants to determine the map region size from ashmem.
- bytes = ashmem_bytes - offset;
- // TODO(port): we set the created size here so that it is available in
- // transport_dib_android.cc. We should use ashmem_get_size_region()
- // in transport_dib_android.cc.
- mapped_size_ = ashmem_bytes;
+ bytes = ashmem_bytes;
}
#endif
@@ -244,9 +240,7 @@ bool SharedMemory::MapAt(off_t offset, size_t bytes) {
bool mmap_succeeded = memory_ != (void*)-1 && memory_ != NULL;
if (mmap_succeeded) {
-#if !defined(OS_ANDROID)
mapped_size_ = bytes;
-#endif
DCHECK_EQ(0U, reinterpret_cast<uintptr_t>(memory_) &
(SharedMemory::MAP_MINIMUM_ALIGNMENT - 1));
} else {