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

Unified Diff: base/scoped_handle_win.h

Issue 13780: Exposing the Close() method publicly in the ScopedHandle class.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/scoped_handle_win.h
===================================================================
--- base/scoped_handle_win.h (revision 6840)
+++ base/scoped_handle_win.h (working copy)
@@ -10,7 +10,12 @@
#include "base/basictypes.h"
#include "base/logging.h"
-// Used so we always remember to close the handle. Example:
+// Used so we always remember to close the handle.
+// The class interface matches that of ScopedStdioHandle in addition to an
+// IsValid() method since invalid handles on windows can be either NULL or
+// INVALID_HANDLE_VALUE (-1).
+//
+// Example:
// ScopedHandle hfile(CreateFile(...));
// if (!hfile.Get())
// ...process error
@@ -20,7 +25,7 @@
// secret_handle_ = hfile.Take();
//
// To explicitly close the handle:
-// CloseHandle(hfile.Take());
+// hfile.Close();
class ScopedHandle {
public:
ScopedHandle() : handle_(NULL) {
@@ -61,7 +66,6 @@
return h;
}
- private:
void Close() {
if (handle_) {
if (!::CloseHandle(handle_)) {
@@ -71,6 +75,7 @@
}
}
+ private:
HANDLE handle_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedHandle);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698