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

Unified Diff: base/scoped_handle.h

Issue 3197: My base changes to the plugin code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 3 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/scoped_handle.h
===================================================================
--- base/scoped_handle.h (revision 2456)
+++ base/scoped_handle.h (working copy)
@@ -105,16 +105,26 @@
// CreateCompatibleDC. For an HDC returned by GetDC, use ReleaseDC instead.
class ScopedHDC {
public:
+ ScopedHDC() : hdc_(NULL) { }
explicit ScopedHDC(HDC h) : hdc_(h) { }
~ScopedHDC() {
- if (hdc_)
- DeleteDC(hdc_);
+ Close();
}
+ void Set(HDC h) {
+ Close();
+ hdc_ = h;
+ }
+
operator HDC() { return hdc_; }
private:
+ void Close() {
+ if (hdc_)
+ DeleteDC(hdc_);
+ }
+
HDC hdc_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedHDC);
};
@@ -122,16 +132,26 @@
// Like ScopedHandle but for HBITMAP.
class ScopedBitmap {
public:
+ ScopedBitmap() : hbitmap_(NULL) { }
explicit ScopedBitmap(HBITMAP h) : hbitmap_(h) { }
~ScopedBitmap() {
- if (hbitmap_)
- DeleteObject(hbitmap_);
+ Close();
}
+ void Set(HBITMAP h) {
+ Close();
+ hbitmap_ = h;
+ }
+
operator HBITMAP() { return hbitmap_; }
private:
+ void Close() {
+ if (hbitmap_)
+ DeleteObject(hbitmap_);
+ }
+
HBITMAP hbitmap_;
DISALLOW_EVIL_CONSTRUCTORS(ScopedBitmap);
};
« 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