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

Side by Side Diff: base/scoped_handle.h

Issue 5040: Fix painting problem with transparent plugins because plugins were ignoring t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/common/plugin_messages_internal.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_SCOPED_HANDLE_H__ 5 #ifndef BASE_SCOPED_HANDLE_H__
6 #define BASE_SCOPED_HANDLE_H__ 6 #define BASE_SCOPED_HANDLE_H__
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 // CreateCompatibleDC. For an HDC returned by GetDC, use ReleaseDC instead. 105 // CreateCompatibleDC. For an HDC returned by GetDC, use ReleaseDC instead.
106 class ScopedHDC { 106 class ScopedHDC {
107 public: 107 public:
108 ScopedHDC() : hdc_(NULL) { } 108 ScopedHDC() : hdc_(NULL) { }
109 explicit ScopedHDC(HDC h) : hdc_(h) { } 109 explicit ScopedHDC(HDC h) : hdc_(h) { }
110 110
111 ~ScopedHDC() { 111 ~ScopedHDC() {
112 Close(); 112 Close();
113 } 113 }
114 114
115 HDC Get() {
116 return hdc_;
117 }
118
115 void Set(HDC h) { 119 void Set(HDC h) {
116 Close(); 120 Close();
117 hdc_ = h; 121 hdc_ = h;
118 } 122 }
119 123
120 operator HDC() { return hdc_; } 124 operator HDC() { return hdc_; }
121 125
122 private: 126 private:
123 void Close() { 127 void Close() {
124 if (hdc_) 128 if (hdc_)
125 DeleteDC(hdc_); 129 DeleteDC(hdc_);
126 } 130 }
127 131
128 HDC hdc_; 132 HDC hdc_;
129 DISALLOW_EVIL_CONSTRUCTORS(ScopedHDC); 133 DISALLOW_EVIL_CONSTRUCTORS(ScopedHDC);
130 }; 134 };
131 135
132 // Like ScopedHandle but for HBITMAP. 136 // Like ScopedHandle but for HBITMAP.
133 class ScopedBitmap { 137 class ScopedBitmap {
134 public: 138 public:
135 ScopedBitmap() : hbitmap_(NULL) { } 139 ScopedBitmap() : hbitmap_(NULL) { }
136 explicit ScopedBitmap(HBITMAP h) : hbitmap_(h) { } 140 explicit ScopedBitmap(HBITMAP h) : hbitmap_(h) { }
137 141
138 ~ScopedBitmap() { 142 ~ScopedBitmap() {
139 Close(); 143 Close();
140 } 144 }
141 145
146 HBITMAP Get() {
147 return hbitmap_;
148 }
149
142 void Set(HBITMAP h) { 150 void Set(HBITMAP h) {
143 Close(); 151 Close();
144 hbitmap_ = h; 152 hbitmap_ = h;
145 } 153 }
146 154
147 operator HBITMAP() { return hbitmap_; } 155 operator HBITMAP() { return hbitmap_; }
148 156
149 private: 157 private:
150 void Close() { 158 void Close() {
151 if (hbitmap_) 159 if (hbitmap_)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 private: 211 private:
204 HGLOBAL glob_; 212 HGLOBAL glob_;
205 213
206 T* data_; 214 T* data_;
207 215
208 DISALLOW_EVIL_CONSTRUCTORS(ScopedHGlobal); 216 DISALLOW_EVIL_CONSTRUCTORS(ScopedHGlobal);
209 }; 217 };
210 218
211 #endif // BASE_SCOPED_HANDLE_H__ 219 #endif // BASE_SCOPED_HANDLE_H__
212 220
OLDNEW
« no previous file with comments | « no previous file | chrome/common/plugin_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698