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

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

Issue 3781009: Move the windows-specific scoped_* stuff from base to base/win and in the bas... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
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_COMPTR_WIN_H_ 5 #ifndef BASE_WIN_SCOPED_COMPTR_H_
6 #define BASE_SCOPED_COMPTR_WIN_H_ 6 #define BASE_WIN_SCOPED_COMPTR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <unknwn.h> 9 #include <unknwn.h>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/ref_counted.h" 12 #include "base/ref_counted.h"
13 13
14 // Utility template to prevent users of ScopedComPtr from calling AddRef and/or 14 namespace base {
15 // Release() without going through the ScopedComPtr class. 15 namespace win {
16 template <class Interface>
17 class BlockIUnknownMethods : public Interface {
18 private:
19 STDMETHOD(QueryInterface)(REFIID iid, void** object) = 0;
20 STDMETHOD_(ULONG, AddRef)() = 0;
21 STDMETHOD_(ULONG, Release)() = 0;
22 };
23 16
24 // A fairly minimalistic smart class for COM interface pointers. 17 // A fairly minimalistic smart class for COM interface pointers.
25 // Uses scoped_refptr for the basic smart pointer functionality 18 // Uses scoped_refptr for the basic smart pointer functionality
26 // and adds a few IUnknown specific services. 19 // and adds a few IUnknown specific services.
27 template <class Interface, const IID* interface_id = &__uuidof(Interface)> 20 template <class Interface, const IID* interface_id = &__uuidof(Interface)>
28 class ScopedComPtr : public scoped_refptr<Interface> { 21 class ScopedComPtr : public scoped_refptr<Interface> {
29 public: 22 public:
23 // Utility template to prevent users of ScopedComPtr from calling AddRef
24 // and/or Release() without going through the ScopedComPtr class.
25 template <class Interface>
darin (slow to review) 2010/10/15 05:58:11 this does not need the template prefix since it is
26 class BlockIUnknownMethods : public Interface {
27 private:
28 STDMETHOD(QueryInterface)(REFIID iid, void** object) = 0;
29 STDMETHOD_(ULONG, AddRef)() = 0;
30 STDMETHOD_(ULONG, Release)() = 0;
31 };
32
30 typedef scoped_refptr<Interface> ParentClass; 33 typedef scoped_refptr<Interface> ParentClass;
31 34
32 ScopedComPtr() { 35 ScopedComPtr() {
33 } 36 }
34 37
35 explicit ScopedComPtr(Interface* p) : ParentClass(p) { 38 explicit ScopedComPtr(Interface* p) : ParentClass(p) {
36 } 39 }
37 40
38 ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p) 41 ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p)
39 : ParentClass(p) { 42 : ParentClass(p) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // Pull in operator=() from the parent class. 152 // Pull in operator=() from the parent class.
150 using scoped_refptr<Interface>::operator=; 153 using scoped_refptr<Interface>::operator=;
151 154
152 // static methods 155 // static methods
153 156
154 static const IID& iid() { 157 static const IID& iid() {
155 return *interface_id; 158 return *interface_id;
156 } 159 }
157 }; 160 };
158 161
159 #endif // BASE_SCOPED_COMPTR_WIN_H_ 162 } // namespace win
163 } // namespace base
164
165 #endif // BASE_WIN_SCOPED_COMPTR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698