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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 #endif // INSIDE_BLINK | 53 #endif // INSIDE_BLINK |
54 | 54 |
55 T* get() const | |
jochen (gone - plz use gerrit)
2015/11/16 11:51:44
that breaks the ownership semantics of this class.
alex clarke (OOO till 29th)
2015/11/23 17:13:46
Done.
| |
56 { | |
57 return m_ptr; | |
58 } | |
59 | |
55 template <typename U> friend class WebPassOwnPtr; | 60 template <typename U> friend class WebPassOwnPtr; |
56 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*); | 61 template <typename U> friend WebPassOwnPtr<U> adoptWebPtr(U*); |
57 | 62 |
58 private: | 63 private: |
59 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {} | 64 explicit WebPassOwnPtr(T* ptr) : m_ptr(ptr) {} |
60 | 65 |
61 // See the constructor comment to see why |mutable| is needed. | 66 // See the constructor comment to see why |mutable| is needed. |
62 mutable T* m_ptr; | 67 mutable T* m_ptr; |
63 }; | 68 }; |
64 | 69 |
65 template <typename T> | 70 template <typename T> |
66 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); } | 71 WebPassOwnPtr<T> adoptWebPtr(T* p) { return WebPassOwnPtr<T>(p); } |
67 | 72 |
68 } // namespace blink | 73 } // namespace blink |
69 | 74 |
70 #endif | 75 #endif |
OLD | NEW |