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

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

Issue 2451123004: WIP - allow scoped_refptr to be used without full defn of T (Closed)
Patch Set: Created 4 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
« no previous file with comments | « base/memory/ref_counted.h ('k') | no next file » | 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) 2011 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 BASE_WIN_SCOPED_COMPTR_H_ 5 #ifndef BASE_WIN_SCOPED_COMPTR_H_
6 #define BASE_WIN_SCOPED_COMPTR_H_ 6 #define BASE_WIN_SCOPED_COMPTR_H_
7 7
8 #include <unknwn.h> 8 #include <unknwn.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*), 47 sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*),
48 "ScopedComPtrSize"); 48 "ScopedComPtrSize");
49 } 49 }
50 50
51 // Explicit Release() of the held object. Useful for reuse of the 51 // Explicit Release() of the held object. Useful for reuse of the
52 // ScopedComPtr instance. 52 // ScopedComPtr instance.
53 // Note that this function equates to IUnknown::Release and should not 53 // Note that this function equates to IUnknown::Release and should not
54 // be confused with e.g. scoped_ptr::release(). 54 // be confused with e.g. scoped_ptr::release().
55 void Release() { 55 void Release() {
56 if (this->ptr_ != NULL) { 56 if (this->ptr_ != NULL) {
57 this->ptr_->Release(); 57 //FIXME: need to null |ref_| in this class as well.
58 this->ref_->Release();
58 this->ptr_ = NULL; 59 this->ptr_ = NULL;
59 } 60 }
60 } 61 }
61 62
62 // Sets the internal pointer to NULL and returns the held object without 63 // Sets the internal pointer to NULL and returns the held object without
63 // releasing the reference. 64 // releasing the reference.
64 Interface* Detach() { 65 Interface* Detach() {
65 Interface* p = this->ptr_; 66 Interface* p = this->ptr_;
66 this->ptr_ = NULL; 67 this->ptr_ = NULL;
67 return p; 68 return p;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 160
160 static const IID& iid() { 161 static const IID& iid() {
161 return *interface_id; 162 return *interface_id;
162 } 163 }
163 }; 164 };
164 165
165 } // namespace win 166 } // namespace win
166 } // namespace base 167 } // namespace base
167 168
168 #endif // BASE_WIN_SCOPED_COMPTR_H_ 169 #endif // BASE_WIN_SCOPED_COMPTR_H_
OLDNEW
« no previous file with comments | « base/memory/ref_counted.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698