Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 WebPassOwnPtr_h | 5 #ifndef WebPassOwnPtr_h |
| 6 #define WebPassOwnPtr_h | 6 #define WebPassOwnPtr_h |
| 7 | 7 |
| 8 #include "public/platform/WebCommon.h" | 8 #include "public/platform/WebCommon.h" |
| 9 #include <cstddef> | 9 #include <cstddef> |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 } | 43 } |
| 44 WebPassOwnPtr& operator =(const WebPassOwnPtr&) = delete; | 44 WebPassOwnPtr& operator =(const WebPassOwnPtr&) = delete; |
| 45 | 45 |
| 46 #if INSIDE_BLINK | 46 #if INSIDE_BLINK |
| 47 PassOwnPtr<T> release() | 47 PassOwnPtr<T> release() |
| 48 { | 48 { |
| 49 T* ptr = m_ptr; | 49 T* ptr = m_ptr; |
| 50 m_ptr = nullptr; | 50 m_ptr = nullptr; |
| 51 return adoptPtr(ptr); | 51 return adoptPtr(ptr); |
| 52 } | 52 } |
| 53 #else | |
| 54 T* release() | |
|
esprehn
2016/01/06 19:48:37
leakPtr()
Ian Vollick
2016/01/08 03:01:53
This has been replaced with the scoped_ptr convers
| |
| 55 { | |
| 56 T* ptr = m_ptr; | |
| 57 m_ptr = nullptr; | |
| 58 return ptr; | |
| 59 } | |
| 53 #endif // INSIDE_BLINK | 60 #endif // INSIDE_BLINK |
| 54 | 61 |
| 55 template <typename U> friend class WebPassOwnPtr; | 62 template <typename U> friend class WebPassOwnPtr; |
| 56 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*); | 63 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*); |
| 57 | 64 |
| 58 private: | 65 private: |
| 59 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {} | 66 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {} |
| 60 | 67 |
| 61 // See the constructor comment to see why |mutable| is needed. | 68 // See the constructor comment to see why |mutable| is needed. |
| 62 mutable T* m_ptr; | 69 mutable T* m_ptr; |
| 63 }; | 70 }; |
| 64 | 71 |
| 65 template <typename T> | 72 template <typename T> |
| 66 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); } | 73 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); } |
| 67 | 74 |
| 68 } // namespace blink | 75 } // namespace blink |
| 69 | 76 |
| 70 #endif | 77 #endif |
| OLD | NEW |