diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 06:24:20 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-12-12 06:24:20 +0000 |
commit | 0c8a9b1ea09c88dd5860191c8430c81dfcb96199 (patch) | |
tree | 9194fe6bb146ee18cfcc433a50c4b640fd53d628 /base/scoped_handle_win.h | |
parent | 7bee1e113242a39b41579e07cd83e41591595eab (diff) | |
download | chromium_src-0c8a9b1ea09c88dd5860191c8430c81dfcb96199.zip chromium_src-0c8a9b1ea09c88dd5860191c8430c81dfcb96199.tar.gz chromium_src-0c8a9b1ea09c88dd5860191c8430c81dfcb96199.tar.bz2 |
Exposing the Close() method publicly in the ScopedHandle class.
This is to be more consistent with the interface defined in scoped_handle.h (ScopedStdioHandle)
and also to avoid making the user make an explicit, Windows
specific call to close the handle
The recommendation is currently to do
::CloseHandle(h.Take());
which is less portable.
Review URL: http://codereview.chromium.org/13780
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6883 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/scoped_handle_win.h')
-rw-r--r-- | base/scoped_handle_win.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/base/scoped_handle_win.h b/base/scoped_handle_win.h index f2eea7a..ead32ac 100644 --- a/base/scoped_handle_win.h +++ b/base/scoped_handle_win.h @@ -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 @@ class ScopedHandle { return h; } - private: void Close() { if (handle_) { if (!::CloseHandle(handle_)) { @@ -71,6 +75,7 @@ class ScopedHandle { } } + private: HANDLE handle_; DISALLOW_EVIL_CONSTRUCTORS(ScopedHandle); }; |