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> |