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

Unified Diff: tools/android/memdump/memdump.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 | « sandbox/linux/services/yama.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/android/memdump/memdump.cc
diff --git a/tools/android/memdump/memdump.cc b/tools/android/memdump/memdump.cc
index 4f4dd14fd548ebc6b5dc672067c890b9ce42b62c..20684f69f820e6357661d5832da3b78a64b0300d 100644
--- a/tools/android/memdump/memdump.cc
+++ b/tools/android/memdump/memdump.cc
@@ -22,7 +22,6 @@
#include "base/callback_helpers.h"
#include "base/containers/hash_tables.h"
#include "base/file_util.h"
-#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@@ -437,12 +436,13 @@
int page_flags_fd,
ProcessMemory* process_memory) {
const pid_t pid = process_memory->pid;
- base::ScopedFD pagemap_fd(open(
- base::StringPrintf("/proc/%d/pagemap", pid).c_str(), O_RDONLY));
- if (!pagemap_fd.is_valid()) {
+ int pagemap_fd = open(
+ base::StringPrintf("/proc/%d/pagemap", pid).c_str(), O_RDONLY);
+ if (pagemap_fd < 0) {
PLOG(ERROR) << "open";
return false;
}
+ file_util::ScopedFD auto_closer(&pagemap_fd);
std::vector<MemoryMap>* const process_maps = &process_memory->memory_maps;
if (!GetProcessMaps(pid, process_maps))
return false;
@@ -450,7 +450,7 @@
it != process_maps->end(); ++it) {
std::vector<PageInfo>* const committed_pages = &it->committed_pages;
BitSet* const pages_bits = &it->committed_pages_bits;
- GetPagesForMemoryMap(pagemap_fd.get(), *it, committed_pages, pages_bits);
+ GetPagesForMemoryMap(pagemap_fd, *it, committed_pages, pages_bits);
SetPagesInfo(page_count_fd, page_flags_fd, committed_pages);
}
return true;
@@ -489,17 +489,20 @@
std::vector<ProcessMemory> processes_memory(pids.size());
{
- base::ScopedFD page_count_fd(open("/proc/kpagecount", O_RDONLY));
- if (!page_count_fd.is_valid()) {
+ int page_count_fd = open("/proc/kpagecount", O_RDONLY);
+ if (page_count_fd < 0) {
PLOG(ERROR) << "open /proc/kpagecount";
return EXIT_FAILURE;
}
- base::ScopedFD page_flags_fd(open("/proc/kpageflags", O_RDONLY));
- if (!page_flags_fd.is_valid()) {
+ int page_flags_fd = open("/proc/kpageflags", O_RDONLY);
+ if (page_flags_fd < 0) {
PLOG(ERROR) << "open /proc/kpageflags";
return EXIT_FAILURE;
}
+
+ file_util::ScopedFD page_count_fd_closer(&page_count_fd);
+ file_util::ScopedFD page_flags_fd_closer(&page_flags_fd);
base::ScopedClosureRunner auto_resume_processes(
base::Bind(&KillAll, pids, SIGCONT));
@@ -510,7 +513,7 @@
&processes_memory[it - pids.begin()];
process_memory->pid = *it;
if (!CollectProcessMemoryInformation(
- page_count_fd.get(), page_flags_fd.get(), process_memory)) {
+ page_count_fd, page_flags_fd, process_memory)) {
return EXIT_FAILURE;
}
}
« no previous file with comments | « sandbox/linux/services/yama.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698