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

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

Issue 2792383003: Rename ScopedComPtr::Release() to ScopedComPtr::Reset() (Closed)
Patch Set: Fix New Callers Created 3 years, 8 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
« no previous file with comments | « no previous file | base/win/scoped_comptr_unittest.cc » ('j') | 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 <objbase.h> 8 #include <objbase.h>
9 #include <unknwn.h> 9 #include <unknwn.h>
10 10
(...skipping 28 matching lines...) Expand all
39 if (ptr_) 39 if (ptr_)
40 ptr_->AddRef(); 40 ptr_->AddRef();
41 } 41 }
42 42
43 ~ScopedComPtr() { 43 ~ScopedComPtr() {
44 // We don't want the smart pointer class to be bigger than the pointer 44 // We don't want the smart pointer class to be bigger than the pointer
45 // it wraps. 45 // it wraps.
46 static_assert( 46 static_assert(
47 sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*), 47 sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*),
48 "ScopedComPtrSize"); 48 "ScopedComPtrSize");
49 Release(); 49 Reset();
50 } 50 }
51 51
52 Interface* get() const { return ptr_; } 52 Interface* get() const { return ptr_; }
53 53
54 explicit operator bool() const { return ptr_ != nullptr; } 54 explicit operator bool() const { return ptr_ != nullptr; }
55 55
56 // Explicit Release() of the held object. Useful for reuse of the 56 // Explicit Release() of the held object. Useful for reuse of the
57 // ScopedComPtr instance. 57 // ScopedComPtr instance.
58 // Note that this function equates to IUnknown::Release and should not 58 // Note that this function equates to IUnknown::Release and should not
59 // be confused with e.g. unique_ptr::release(). 59 // be confused with e.g. unique_ptr::release().
60 void Release() { 60 unsigned long Reset() {
61 unsigned long ref = 0;
61 Interface* temp = ptr_; 62 Interface* temp = ptr_;
62 if (temp) { 63 if (temp) {
63 ptr_ = nullptr; 64 ptr_ = nullptr;
64 temp->Release(); 65 ref = temp->Release();
65 } 66 }
67 return ref;
66 } 68 }
67 69
68 // Sets the internal pointer to NULL and returns the held object without 70 // Sets the internal pointer to NULL and returns the held object without
69 // releasing the reference. 71 // releasing the reference.
70 Interface* Detach() { 72 Interface* Detach() {
71 Interface* p = ptr_; 73 Interface* p = ptr_;
72 ptr_ = nullptr; 74 ptr_ = nullptr;
73 return p; 75 return p;
74 } 76 }
75 77
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // Helper to make IID_PPV_ARGS work with ScopedComPtr. 258 // Helper to make IID_PPV_ARGS work with ScopedComPtr.
257 template <typename T> 259 template <typename T>
258 void** IID_PPV_ARGS_Helper(base::win::ScopedComPtr<T>* pp) throw() { 260 void** IID_PPV_ARGS_Helper(base::win::ScopedComPtr<T>* pp) throw() {
259 return pp->ReceiveVoid(); 261 return pp->ReceiveVoid();
260 } 262 }
261 263
262 } // namespace win 264 } // namespace win
263 } // namespace base 265 } // namespace base
264 266
265 #endif // BASE_WIN_SCOPED_COMPTR_H_ 267 #endif // BASE_WIN_SCOPED_COMPTR_H_
OLDNEW
« no previous file with comments | « no previous file | base/win/scoped_comptr_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698