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

Side by Side Diff: base/scoped_handle_win.h

Issue 340077: Gets find bar animation/clipping to work on views/gtk. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 1 month 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
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_WIN_H_ 5 #ifndef BASE_SCOPED_HANDLE_WIN_H_
6 #define BASE_SCOPED_HANDLE_WIN_H_ 6 #define BASE_SCOPED_HANDLE_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 if (object_ && object != object_) 161 if (object_ && object != object_)
162 Close(); 162 Close();
163 object_ = object; 163 object_ = object;
164 } 164 }
165 165
166 ScopedGDIObject& operator=(T object) { 166 ScopedGDIObject& operator=(T object) {
167 Set(object); 167 Set(object);
168 return *this; 168 return *this;
169 } 169 }
170 170
171 T release() {
172 T object = object_;
173 object_ = NULL;
174 return object;
175 }
176
171 operator T() { return object_; } 177 operator T() { return object_; }
172 178
173 private: 179 private:
174 void Close() { 180 void Close() {
175 if (object_) 181 if (object_)
176 DeleteObject(object_); 182 DeleteObject(object_);
177 } 183 }
178 184
179 T object_; 185 T object_;
180 DISALLOW_COPY_AND_ASSIGN(ScopedGDIObject); 186 DISALLOW_COPY_AND_ASSIGN(ScopedGDIObject);
181 }; 187 };
182 188
183 // Typedefs for some common use cases. 189 // Typedefs for some common use cases.
184 typedef ScopedGDIObject<HBITMAP> ScopedBitmap; 190 typedef ScopedGDIObject<HBITMAP> ScopedBitmap;
185 typedef ScopedGDIObject<HRGN> ScopedHRGN; 191 typedef ScopedGDIObject<HRGN> ScopedRegion;
186 typedef ScopedGDIObject<HFONT> ScopedHFONT; 192 typedef ScopedGDIObject<HFONT> ScopedHFONT;
187 193
188 194
189 // Like ScopedHandle except for HGLOBAL. 195 // Like ScopedHandle except for HGLOBAL.
190 template<class T> 196 template<class T>
191 class ScopedHGlobal { 197 class ScopedHGlobal {
192 public: 198 public:
193 explicit ScopedHGlobal(HGLOBAL glob) : glob_(glob) { 199 explicit ScopedHGlobal(HGLOBAL glob) : glob_(glob) {
194 data_ = static_cast<T*>(GlobalLock(glob_)); 200 data_ = static_cast<T*>(GlobalLock(glob_));
195 } 201 }
(...skipping 12 matching lines...) Expand all
208 214
209 private: 215 private:
210 HGLOBAL glob_; 216 HGLOBAL glob_;
211 217
212 T* data_; 218 T* data_;
213 219
214 DISALLOW_EVIL_CONSTRUCTORS(ScopedHGlobal); 220 DISALLOW_EVIL_CONSTRUCTORS(ScopedHGlobal);
215 }; 221 };
216 222
217 #endif // BASE_SCOPED_HANDLE_WIN_H_ 223 #endif // BASE_SCOPED_HANDLE_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698