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

Unified Diff: content/common/sandbox_linux/sandbox_linux.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 | « content/child/npapi/np_channel_base.cc ('k') | content/common/sandbox_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/sandbox_linux/sandbox_linux.cc
diff --git a/content/common/sandbox_linux/sandbox_linux.cc b/content/common/sandbox_linux/sandbox_linux.cc
index 6f605849cbc1e90686172bbc66964baab6109463..5fd89f725c3ec9d1fba28e5e34c4775fcd1cdb25 100644
--- a/content/common/sandbox_linux/sandbox_linux.cc
+++ b/content/common/sandbox_linux/sandbox_linux.cc
@@ -15,7 +15,6 @@
#include "base/bind.h"
#include "base/callback_helpers.h"
#include "base/command_line.h"
-#include "base/files/scoped_file.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
@@ -44,6 +43,10 @@
}
};
+// Don't use base::ScopedFD since it doesn't CHECK that the file descriptor was
+// closed.
+typedef scoped_ptr<int, FDCloser> SafeScopedFD;
+
void LogSandboxStarted(const std::string& sandbox_name) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
const std::string process_type =
@@ -200,25 +203,25 @@
// of using the pid.
bool LinuxSandbox::IsSingleThreaded() const {
bool is_single_threaded = false;
- base::ScopedFD proc_self_task(OpenProcTaskFd(proc_fd_));
+ int proc_self_task = OpenProcTaskFd(proc_fd_);
// In Debug mode, it's mandatory to be able to count threads to catch bugs.
#if !defined(NDEBUG)
// Using CHECK here since we want to check all the cases where
// !defined(NDEBUG)
// gets built.
- CHECK(proc_self_task.is_valid())
- << "Could not count threads, the sandbox was not "
- << "pre-initialized properly.";
+ CHECK_LE(0, proc_self_task) << "Could not count threads, the sandbox was not "
+ << "pre-initialized properly.";
#endif // !defined(NDEBUG)
- if (!proc_self_task.is_valid()) {
+ if (proc_self_task < 0) {
// Pretend to be monothreaded if it can't be determined (for instance the
// setuid sandbox is already engaged but no proc_fd_ is available).
is_single_threaded = true;
} else {
+ SafeScopedFD task_closer(&proc_self_task);
is_single_threaded =
- sandbox::ThreadHelpers::IsSingleThreaded(proc_self_task.get());
+ sandbox::ThreadHelpers::IsSingleThreaded(proc_self_task);
}
return is_single_threaded;
@@ -388,10 +391,11 @@
void LinuxSandbox::StopThreadAndEnsureNotCounted(base::Thread* thread) const {
DCHECK(thread);
- base::ScopedFD proc_self_task(OpenProcTaskFd(proc_fd_));
- PCHECK(proc_self_task.is_valid());
- CHECK(sandbox::ThreadHelpers::StopThreadAndWatchProcFS(proc_self_task.get(),
- thread));
+ int proc_self_task = OpenProcTaskFd(proc_fd_);
+ PCHECK(proc_self_task >= 0);
+ SafeScopedFD task_closer(&proc_self_task);
+ CHECK(
+ sandbox::ThreadHelpers::StopThreadAndWatchProcFS(proc_self_task, thread));
}
} // namespace content
« no previous file with comments | « content/child/npapi/np_channel_base.cc ('k') | content/common/sandbox_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698