| 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 25 matching lines...) Expand all Loading... |
| 36 explicit ScopedComPtr(Interface* p) : ParentClass(p) { | 36 explicit ScopedComPtr(Interface* p) : ParentClass(p) { |
| 37 } | 37 } |
| 38 | 38 |
| 39 ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p) | 39 ScopedComPtr(const ScopedComPtr<Interface, interface_id>& p) |
| 40 : ParentClass(p) { | 40 : ParentClass(p) { |
| 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 COMPILE_ASSERT(sizeof(ScopedComPtr<Interface, interface_id>) == | 46 static_assert( |
| 47 sizeof(Interface*), ScopedComPtrSize); | 47 sizeof(ScopedComPtr<Interface, interface_id>) == sizeof(Interface*), |
| 48 "ScopedComPtrSize"); |
| 48 } | 49 } |
| 49 | 50 |
| 50 // Explicit Release() of the held object. Useful for reuse of the | 51 // Explicit Release() of the held object. Useful for reuse of the |
| 51 // ScopedComPtr instance. | 52 // ScopedComPtr instance. |
| 52 // Note that this function equates to IUnknown::Release and should not | 53 // Note that this function equates to IUnknown::Release and should not |
| 53 // be confused with e.g. scoped_ptr::release(). | 54 // be confused with e.g. scoped_ptr::release(). |
| 54 void Release() { | 55 void Release() { |
| 55 if (this->ptr_ != NULL) { | 56 if (this->ptr_ != NULL) { |
| 56 this->ptr_->Release(); | 57 this->ptr_->Release(); |
| 57 this->ptr_ = NULL; | 58 this->ptr_ = NULL; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 159 |
| 159 static const IID& iid() { | 160 static const IID& iid() { |
| 160 return *interface_id; | 161 return *interface_id; |
| 161 } | 162 } |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 } // namespace win | 165 } // namespace win |
| 165 } // namespace base | 166 } // namespace base |
| 166 | 167 |
| 167 #endif // BASE_WIN_SCOPED_COMPTR_H_ | 168 #endif // BASE_WIN_SCOPED_COMPTR_H_ |
| OLD | NEW |