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

Unified Diff: base/win/scoped_hdc.h

Issue 10696185: Use GenericScopedHandle to implement ScopedCreateDC. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/scoped_hdc.h
diff --git a/base/win/scoped_hdc.h b/base/win/scoped_hdc.h
index 070c656b5494d14b506e609812c984524c49bcf3..6118fd4716465648860dd86e4428f491adce6a53 100644
--- a/base/win/scoped_hdc.h
+++ b/base/win/scoped_hdc.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/logging.h"
+#include "base/win/scoped_handle.h"
namespace base {
namespace win {
@@ -48,41 +49,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
alexeypa (please no reviews) 2012/07/12 18:18:00 This code was wrong BTW. When NOGDI is defined Del
- 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
« 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