| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FXCRT_CFX_WEAK_PTR_H_ | 7 #ifndef CORE_FXCRT_CFX_WEAK_PTR_H_ |
| 8 #define CORE_FXCRT_CFX_WEAK_PTR_H_ | 8 #define CORE_FXCRT_CFX_WEAK_PTR_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 CFX_WeakPtr& operator=(const CFX_WeakPtr& that) { | 28 CFX_WeakPtr& operator=(const CFX_WeakPtr& that) { |
| 29 m_pHandle = that.m_pHandle; | 29 m_pHandle = that.m_pHandle; |
| 30 return *this; | 30 return *this; |
| 31 } | 31 } |
| 32 bool operator==(const CFX_WeakPtr& that) const { | 32 bool operator==(const CFX_WeakPtr& that) const { |
| 33 return m_pHandle == that.m_pHandle; | 33 return m_pHandle == that.m_pHandle; |
| 34 } | 34 } |
| 35 bool operator!=(const CFX_WeakPtr& that) const { return !(*this == that); } | 35 bool operator!=(const CFX_WeakPtr& that) const { return !(*this == that); } |
| 36 | 36 |
| 37 T* Get() const { return m_pHandle ? m_pHandle->Get() : nullptr; } | 37 T* Get() const { return m_pHandle ? m_pHandle->Get() : nullptr; } |
| 38 void Clear() { | 38 void DeleteObject() { |
| 39 if (m_pHandle) { | 39 if (m_pHandle) { |
| 40 m_pHandle->Clear(); | 40 m_pHandle->Clear(); |
| 41 m_pHandle.Reset(); | 41 m_pHandle.Reset(); |
| 42 } | 42 } |
| 43 } | 43 } |
| 44 void Reset() { m_pHandle.Reset(); } | 44 void Reset() { m_pHandle.Reset(); } |
| 45 void Reset(std::unique_ptr<T, D> pObj) { | 45 void Reset(std::unique_ptr<T, D> pObj) { |
| 46 m_pHandle.Reset(new Handle(std::move(pObj))); | 46 m_pHandle.Reset(new Handle(std::move(pObj))); |
| 47 } | 47 } |
| 48 void Swap(CFX_WeakPtr& that) { m_pHandle.Swap(that.m_pHandle); } | 48 void Swap(CFX_WeakPtr& that) { m_pHandle.Swap(that.m_pHandle); } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 71 ~Handle() {} | 71 ~Handle() {} |
| 72 | 72 |
| 73 intptr_t m_nCount; | 73 intptr_t m_nCount; |
| 74 std::unique_ptr<T, D> m_pObj; | 74 std::unique_ptr<T, D> m_pObj; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 CFX_RetainPtr<Handle> m_pHandle; | 77 CFX_RetainPtr<Handle> m_pHandle; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 #endif // CORE_FXCRT_CFX_WEAK_PTR_H_ | 80 #endif // CORE_FXCRT_CFX_WEAK_PTR_H_ |
| OLD | NEW |