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

Side by Side Diff: base/win/scoped_co_mem.h

Issue 7231016: Move app/win/* files to base/win/, ui/base/win and chrome/common/ directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 6 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 APP_WIN_SCOPED_CO_MEM_H_ 5 #ifndef BASE_WIN_SCOPED_CO_MEM_H_
brettw 2011/06/23 16:13:04 It looks like this isn't used outside of chrome/,
tfarina 2011/06/23 16:50:12 Done.
6 #define APP_WIN_SCOPED_CO_MEM_H_ 6 #define BASE_WIN_SCOPED_CO_MEM_H_
7 #pragma once 7 #pragma once
8 8
9 #include <objbase.h> 9 #include <objbase.h>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 12
13 namespace app { 13 namespace base {
14 namespace win { 14 namespace win {
15 15
16 // Simple scoped memory releaser class for COM allocated memory. 16 // Simple scoped memory releaser class for COM allocated memory.
17 // Example: 17 // Example:
18 // app::win::ScopedCoMem<ITEMIDLIST> file_item; 18 // base::win::ScopedCoMem<ITEMIDLIST> file_item;
19 // SHGetSomeInfo(&file_item, ...); 19 // SHGetSomeInfo(&file_item, ...);
20 // ... 20 // ...
21 // return; <-- memory released 21 // return; <-- memory released
22 template<typename T> 22 template<typename T>
23 class ScopedCoMem { 23 class ScopedCoMem {
24 public: 24 public:
25 explicit ScopedCoMem() : mem_ptr_(NULL) {} 25 explicit ScopedCoMem() : mem_ptr_(NULL) {}
26 26
27 ~ScopedCoMem() { 27 ~ScopedCoMem() {
28 if (mem_ptr_) 28 if (mem_ptr_)
29 CoTaskMemFree(mem_ptr_); 29 CoTaskMemFree(mem_ptr_);
30 } 30 }
31 31
32 T** operator&() { // NOLINT 32 T** operator&() { // NOLINT
33 return &mem_ptr_; 33 return &mem_ptr_;
34 } 34 }
35 35
36 operator T*() { 36 operator T*() {
37 return mem_ptr_; 37 return mem_ptr_;
38 } 38 }
39 39
40 private: 40 private:
41 T* mem_ptr_; 41 T* mem_ptr_;
42 42
43 DISALLOW_COPY_AND_ASSIGN(ScopedCoMem); 43 DISALLOW_COPY_AND_ASSIGN(ScopedCoMem);
44 }; 44 };
45 45
46 } // namespace win 46 } // namespace win
47 } // namespace app 47 } // namespace base
48 48
49 #endif // APP_WIN_SCOPED_CO_MEM_H_ 49 #endif // BASE_WIN_SCOPED_CO_MEM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698