| OLD | NEW |
| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } | 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. unique_ptr::release(). |
| 55 void Release() { | 55 void Release() { |
| 56 if (this->ptr_ != NULL) { | 56 if (this->ptr_ != NULL) { |
| 57 this->ptr_->Release(); | 57 this->ptr_->Release(); |
| 58 this->ptr_ = NULL; | 58 this->ptr_ = NULL; |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Sets the internal pointer to NULL and returns the held object without | 62 // Sets the internal pointer to NULL and returns the held object without |
| 63 // releasing the reference. | 63 // releasing the reference. |
| 64 Interface* Detach() { | 64 Interface* Detach() { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 | 159 |
| 160 static const IID& iid() { | 160 static const IID& iid() { |
| 161 return *interface_id; | 161 return *interface_id; |
| 162 } | 162 } |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 } // namespace win | 165 } // namespace win |
| 166 } // namespace base | 166 } // namespace base |
| 167 | 167 |
| 168 #endif // BASE_WIN_SCOPED_COMPTR_H_ | 168 #endif // BASE_WIN_SCOPED_COMPTR_H_ |
| OLD | NEW |