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

Unified Diff: base/memory/shared_memory_android.cc

Issue 2843113002: make base::SharedMemoryHandle a class on POSIX. (Closed)
Patch Set: Fix test error. Created 3 years, 8 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/memory/shared_memory_android.cc
diff --git a/base/memory/shared_memory_android.cc b/base/memory/shared_memory_android.cc
index 6f1d9cb874c664891a1cfaa71920b803ef4c8eaa..49289f704b392d2e15ef594bdd11e83f140ead9f 100644
--- a/base/memory/shared_memory_android.cc
+++ b/base/memory/shared_memory_android.cc
@@ -18,21 +18,22 @@ namespace base {
// are closed, the memory buffer will go away.
bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
- DCHECK_EQ(-1, mapped_file_ );
+ DCHECK(!shm_.IsValid());
if (options.size > static_cast<size_t>(std::numeric_limits<int>::max()))
return false;
// "name" is just a label in ashmem. It is visible in /proc/pid/maps.
- mapped_file_ = ashmem_create_region(
+ int fd = ashmem_create_region(
options.name_deprecated == NULL ? "" : options.name_deprecated->c_str(),
options.size);
- if (-1 == mapped_file_) {
+ shm_ = SharedMemoryHandle::ImportHandle(fd);
+ if (!shm_.IsValid()) {
DLOG(ERROR) << "Shared memory creation failed";
return false;
}
- int err = ashmem_set_prot_region(mapped_file_,
+ int err = ashmem_set_prot_region(shm_.GetHandle(),
PROT_READ | PROT_WRITE | PROT_EXEC);
if (err < 0) {
DLOG(ERROR) << "Error " << err << " when setting protection of ashmem";
@@ -41,7 +42,7 @@ bool SharedMemory::Create(const SharedMemoryCreateOptions& options) {
// Android doesn't appear to have a way to drop write access on an ashmem
// segment for a single descriptor. http://crbug.com/320865
- readonly_mapped_file_ = dup(mapped_file_);
+ readonly_mapped_file_ = dup(shm_.GetHandle());
if (-1 == readonly_mapped_file_) {
DPLOG(ERROR) << "dup() failed";
return false;

Powered by Google App Engine
This is Rietveld 408576698