diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-22 22:40:21 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-22 22:40:21 +0000 |
commit | edf2446e7fc35186b96fa79ef23100d488beff3d (patch) | |
tree | ed9af6f053840bdc66c3715d17e9e194406a5c88 /base | |
parent | 22c54fdc29f5c5952175ec4a5d0f954139f2fb75 (diff) | |
download | chromium_src-edf2446e7fc35186b96fa79ef23100d488beff3d.zip chromium_src-edf2446e7fc35186b96fa79ef23100d488beff3d.tar.gz chromium_src-edf2446e7fc35186b96fa79ef23100d488beff3d.tar.bz2 |
My base changes to the plugin code.
Review URL: http://codereview.chromium.org/3197
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2460 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/scoped_handle.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/base/scoped_handle.h b/base/scoped_handle.h index 49c9833..5f12af1 100644 --- a/base/scoped_handle.h +++ b/base/scoped_handle.h @@ -105,16 +105,26 @@ class ScopedFindFileHandle { // 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 @@ class ScopedHDC { // 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); }; |