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

Unified Diff: third_party/WebKit/public/platform/WebPrivatePtr.h

Issue 2019963002: Remove get from CrossThreadPersistent to avoid accidental use Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
Index: third_party/WebKit/public/platform/WebPrivatePtr.h
diff --git a/third_party/WebKit/public/platform/WebPrivatePtr.h b/third_party/WebKit/public/platform/WebPrivatePtr.h
index 4925f35aaa44160ecb2ccb42cf7f78907d435cc9..5873182484785e12d62d5a4a913d00123fc4797c 100644
--- a/third_party/WebKit/public/platform/WebPrivatePtr.h
+++ b/third_party/WebKit/public/platform/WebPrivatePtr.h
@@ -136,8 +136,40 @@ public:
using Type = CrossThreadWeakPersistent<T>;
};
-template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivatePtrStrength strongOrWeak>
-class PtrStorageImpl<T, crossThreadDestruction, strongOrWeak, GarbageCollectedLifetime> {
+template<typename T, WebPrivatePtrStrength strongOrWeak>
+class PtrStorageImpl<T, WebPrivatePtrDestructionCrossThread, strongOrWeak, GarbageCollectedLifetime> {
+public:
+ void assign(T* val)
+ {
+ if (!val) {
+ release();
+ return;
+ }
+
+ if (!m_handle)
+ m_handle = new (typename WebPrivatePtrPersistentStorageType<T, WebPrivatePtrDestructionCrossThread, strongOrWeak>::Type)();
+
+ (*m_handle) = val;
+ }
+
+ template<typename U> void assign(U* val) { assign(static_cast<T*>(val)); }
+
+ void assign(const PtrStorageImpl& other) { assign(other.get()); }
+
+ T* get() const { return m_handle ? m_handle->unsafeGet() : nullptr; }
sof 2016/06/02 07:00:12 You can use a trait (over WebPrivatePtrDestruction
+
+ void release()
+ {
+ delete m_handle;
+ m_handle = nullptr;
+ }
+
+private:
+ typename WebPrivatePtrPersistentStorageType<T, WebPrivatePtrDestructionCrossThread, strongOrWeak>::Type* m_handle;
+};
+
+template<typename T, WebPrivatePtrStrength strongOrWeak>
+class PtrStorageImpl<T, WebPrivatePtrDestructionSameThread, strongOrWeak, GarbageCollectedLifetime> {
public:
void assign(T* val)
{
@@ -147,7 +179,7 @@ public:
}
if (!m_handle)
- m_handle = new (typename WebPrivatePtrPersistentStorageType<T, crossThreadDestruction, strongOrWeak>::Type)();
+ m_handle = new (typename WebPrivatePtrPersistentStorageType<T, WebPrivatePtrDestructionSameThread, strongOrWeak>::Type)();
(*m_handle) = val;
}
@@ -165,7 +197,7 @@ public:
}
private:
- typename WebPrivatePtrPersistentStorageType<T, crossThreadDestruction, strongOrWeak>::Type* m_handle;
+ typename WebPrivatePtrPersistentStorageType<T, WebPrivatePtrDestructionSameThread, strongOrWeak>::Type* m_handle;
};
template<typename T, WebPrivatePtrDestruction crossThreadDestruction, WebPrivatePtrStrength strongOrWeak>

Powered by Google App Engine
This is Rietveld 408576698