Chromium Code Reviews| Index: public/platform/WebPrivateOwnPtr.h |
| diff --git a/public/platform/WebPrivateOwnPtr.h b/public/platform/WebPrivateOwnPtr.h |
| index 8b911264417d86b5adb91e9572b670006470facb..72252576bb99ecc9dd6b859f26896e3e84b794e8 100644 |
| --- a/public/platform/WebPrivateOwnPtr.h |
| +++ b/public/platform/WebPrivateOwnPtr.h |
| @@ -36,6 +36,35 @@ |
| namespace blink { |
| +template <typename T> |
| +class WebPrivatePassOwnPtr { |
| +public: |
| + WebPrivatePassOwnPtr() : m_ptr(nullptr) {} |
| + WebPrivatePassOwnPtr(decltype(nullptr)) : m_ptr(nullptr) {} |
| + template <typename U> |
| + WebPrivatePassOwnPtr(const WebPrivatePassOwnPtr<U>& o) |
|
kinuko
2015/07/16 05:58:57
Do we need this?
yhirano
2015/07/16 06:37:48
Yes, if we pass a WebPrivatePassOwnPtr<Derived> to
|
| + { |
| + m_ptr = o.m_ptr; |
| + o.m_ptr = nullptr; |
| + } |
| + ~WebPrivatePassOwnPtr() { BLINK_ASSERT(!m_ptr); } |
| + WebPrivatePassOwnPtr& operator =(const WebPrivatePassOwnPtr&) = delete; |
| + |
| + T* get() const { return m_ptr; } |
|
kinuko
2015/07/16 05:58:57
Do we need this? I feel release() (in the other pa
yhirano
2015/07/16 06:37:48
Done.
|
| + |
| + template <typename U> friend class WebPrivateOwnPtr; |
| + template <typename U> friend class WebPrivatePassOwnPtr; |
| + template <typename U> friend WebPrivatePassOwnPtr<U> adoptWebPtr(U*); |
| + |
| +private: |
| + explicit WebPrivatePassOwnPtr(T* ptr) : m_ptr(ptr) {} |
| + |
| + mutable T* m_ptr; |
| +}; |
| + |
| +template <typename T> |
| +WebPrivatePassOwnPtr<T> adoptWebPtr(T* p) { return WebPrivatePassOwnPtr<T>(p); } |
| + |
| // This class is an implementation detail of the WebKit API. It exists |
| // to help simplify the implementation of WebKit interfaces that merely |
| // wrap a pointer to a WebCore class. It's similar to WebPrivatePtr, but it |
| @@ -47,12 +76,15 @@ class WebPrivateOwnPtr : public WebNonCopyable { |
| public: |
| WebPrivateOwnPtr() : m_ptr(nullptr) {} |
| WebPrivateOwnPtr(decltype(nullptr)) : m_ptr(nullptr) {} |
| - ~WebPrivateOwnPtr() { BLINK_ASSERT(!m_ptr); } |
| - |
| - explicit WebPrivateOwnPtr(T* ptr) |
| - : m_ptr(ptr) |
| + template <typename U> |
| + WebPrivateOwnPtr(const WebPrivatePassOwnPtr<U>& o) |
|
kinuko
2015/07/16 05:58:57
Do we actually use this?
yhirano
2015/07/16 06:37:48
Deleted.
|
| { |
| + m_ptr = o.m_ptr; |
| + o.m_ptr = nullptr; |
| } |
| + ~WebPrivateOwnPtr() { BLINK_ASSERT(!m_ptr); } |
| + |
| + explicit WebPrivateOwnPtr(T* ptr) : m_ptr(ptr) {} |
| T* get() const { return m_ptr; } |