diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 22:03:55 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-07-12 22:03:55 +0000 |
commit | 7a7c8f317f85764ae564a21a41b941ec3b5d538d (patch) | |
tree | 51c215bcbe8ea16ace55f8e64c6509393020a2f2 /base/win/scoped_hdc.h | |
parent | 95549331a831de5e4fea29691340af2025be552c (diff) | |
download | chromium_src-7a7c8f317f85764ae564a21a41b941ec3b5d538d.zip chromium_src-7a7c8f317f85764ae564a21a41b941ec3b5d538d.tar.gz chromium_src-7a7c8f317f85764ae564a21a41b941ec3b5d538d.tar.bz2 |
Use GenericScopedHandle to implement ScopedCreateDC.
TEST=Existing unit-tests, Chrome runs, everybody happy.
Review URL: https://chromiumcodereview.appspot.com/10696185
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@146457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/win/scoped_hdc.h')
-rw-r--r-- | base/win/scoped_hdc.h | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/base/win/scoped_hdc.h b/base/win/scoped_hdc.h index f3f6005..9aead96 100644 --- a/base/win/scoped_hdc.h +++ b/base/win/scoped_hdc.h @@ -9,6 +9,7 @@ #include "base/basictypes.h" #include "base/logging.h" +#include "base/win/scoped_handle.h" namespace base { namespace win { @@ -47,41 +48,28 @@ class ScopedGetDC { // Like ScopedHandle but for HDC. Only use this on HDCs returned from // CreateCompatibleDC, CreateDC and CreateIC. -class ScopedCreateDC { +class CreateDCTraits { public: - ScopedCreateDC() : hdc_(NULL) { } - explicit ScopedCreateDC(HDC h) : hdc_(h) { } + typedef HDC Handle; - ~ScopedCreateDC() { - Close(); + static bool CloseHandle(HDC handle) { + return ::DeleteDC(handle) != FALSE; } - HDC Get() { - return hdc_; + static bool IsHandleValid(HDC handle) { + return handle != NULL; } - void Set(HDC h) { - Close(); - hdc_ = h; + static HDC NullHandle() { + return NULL; } - operator HDC() { return hdc_; } - private: - void Close() { -#ifdef NOGDI - assert(false); -#else - if (hdc_) - DeleteDC(hdc_); -#endif // NOGDI - } - - HDC hdc_; - - DISALLOW_COPY_AND_ASSIGN(ScopedCreateDC); + DISALLOW_IMPLICIT_CONSTRUCTORS(CreateDCTraits); }; +typedef GenericScopedHandle<CreateDCTraits, VerifierTraits> ScopedCreateDC; + } // namespace win } // namespace base |