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

Side by Side Diff: app/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: brettw review 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
« no previous file with comments | « app/win/iat_patch_function.cc ('k') | app/win/scoped_com_initializer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef APP_WIN_SCOPED_CO_MEM_H_
6 #define APP_WIN_SCOPED_CO_MEM_H_
7 #pragma once
8
9 #include <objbase.h>
10
11 #include "base/basictypes.h"
12
13 namespace app {
14 namespace win {
15
16 // Simple scoped memory releaser class for COM allocated memory.
17 // Example:
18 // app::win::ScopedCoMem<ITEMIDLIST> file_item;
19 // SHGetSomeInfo(&file_item, ...);
20 // ...
21 // return; <-- memory released
22 template<typename T>
23 class ScopedCoMem {
24 public:
25 explicit ScopedCoMem() : mem_ptr_(NULL) {}
26
27 ~ScopedCoMem() {
28 if (mem_ptr_)
29 CoTaskMemFree(mem_ptr_);
30 }
31
32 T** operator&() { // NOLINT
33 return &mem_ptr_;
34 }
35
36 operator T*() {
37 return mem_ptr_;
38 }
39
40 private:
41 T* mem_ptr_;
42
43 DISALLOW_COPY_AND_ASSIGN(ScopedCoMem);
44 };
45
46 } // namespace win
47 } // namespace app
48
49 #endif // APP_WIN_SCOPED_CO_MEM_H_
OLDNEW
« no previous file with comments | « app/win/iat_patch_function.cc ('k') | app/win/scoped_com_initializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698