Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: public/platform/WebPrivateOwnPtr.h

Issue 1232033004: Introduce WebPassOwnPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; }
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698