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

Unified Diff: base/file_util.h

Issue 191673003: 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
Index: base/file_util.h
diff --git a/base/file_util.h b/base/file_util.h
index 32dce3b1a5ee0d93a83a930b8891b0f3a6a613f0..d6d1aadaa0ac69d9afeb188ea802967956379f87 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -413,32 +413,6 @@ struct ScopedFILEClose {
// Automatically closes |FILE*|s.
typedef scoped_ptr<FILE, ScopedFILEClose> ScopedFILE;
-#if defined(OS_POSIX)
-// Functor for |ScopedFD| (below).
-struct ScopedFDClose {
- inline void operator()(int* x) const {
- if (x && *x >= 0) {
- // It's important to crash here.
- // There are security implications to not closing a file descriptor
- // properly. As file descriptors are "capabilities", keeping them open
- // would make the current process keep access to a resource. Much of
- // Chrome relies on being able to "drop" such access.
- // It's especially problematic on Linux with the setuid sandbox, where
- // a single open directory would bypass the entire security model.
- PCHECK(0 == IGNORE_EINTR(close(*x)));
- }
- }
-};
-
-// Automatically closes FDs (note: doesn't store the FD).
-// TODO(viettrungluu): This is a very odd API, since (unlike |FILE*|s, you'll
-// need to store the FD separately and keep its memory alive). This should
-// probably be called |ScopedFDCloser| or something like that.
-typedef scoped_ptr<int, ScopedFDClose> ScopedFD;
-// Let new users use ScopedFDCloser already, while ScopedFD is replaced.
-typedef ScopedFD ScopedFDCloser;
-#endif // OS_POSIX
-
#if defined(OS_LINUX)
// Broad categories of file systems as returned by statfs() on Linux.
enum FileSystemType {

Powered by Google App Engine
This is Rietveld 408576698