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

Unified Diff: base/memory/discardable_memory_allocator_android.cc

Issue 197873014: Revert of Implement ScopedFD in terms of ScopedGeneric. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « base/files/scoped_file.cc ('k') | base/memory/shared_memory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/memory/discardable_memory_allocator_android.cc
diff --git a/base/memory/discardable_memory_allocator_android.cc b/base/memory/discardable_memory_allocator_android.cc
index b1c936a7be54f9b3f48fa8fd9307b34d01c1005d..97e9abd7d6eec8baa54e2d58bed24fd6d1b2c3ba 100644
--- a/base/memory/discardable_memory_allocator_android.cc
+++ b/base/memory/discardable_memory_allocator_android.cc
@@ -16,7 +16,6 @@
#include "base/basictypes.h"
#include "base/containers/hash_tables.h"
#include "base/file_util.h"
-#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/discardable_memory.h"
#include "base/memory/scoped_vector.h"
@@ -66,13 +65,14 @@
size_t size,
int* out_fd,
void** out_address) {
- base::ScopedFD fd(ashmem_create_region(name, size));
- if (!fd.is_valid()) {
+ int fd = ashmem_create_region(name, size);
+ if (fd < 0) {
DLOG(ERROR) << "ashmem_create_region() failed";
return false;
}
-
- const int err = ashmem_set_prot_region(fd.get(), PROT_READ | PROT_WRITE);
+ file_util::ScopedFD fd_closer(&fd);
+
+ const int err = ashmem_set_prot_region(fd, PROT_READ | PROT_WRITE);
if (err < 0) {
DLOG(ERROR) << "Error " << err << " when setting protection of ashmem";
return false;
@@ -88,7 +88,8 @@
return false;
}
- *out_fd = fd.release();
+ ignore_result(fd_closer.release());
+ *out_fd = fd;
*out_address = address;
return true;
}
« no previous file with comments | « base/files/scoped_file.cc ('k') | base/memory/shared_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698