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

Unified Diff: third_party/WebKit/Source/platform/heap/Persistent.h

Issue 2207333002: Support CrossThreadWeakPersistent PostTask on per thread heap enabled thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 4 years, 4 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: third_party/WebKit/Source/platform/heap/Persistent.h
diff --git a/third_party/WebKit/Source/platform/heap/Persistent.h b/third_party/WebKit/Source/platform/heap/Persistent.h
index 2de4595a16d95d54ae979b0ca82aabbdaf169416..6ce492063d4bbe728f9120a81e83bd788adc3ac4 100644
--- a/third_party/WebKit/Source/platform/heap/Persistent.h
+++ b/third_party/WebKit/Source/platform/heap/Persistent.h
@@ -71,10 +71,17 @@ public:
}
template<typename U>
- PersistentBase(const PersistentBase<U, weaknessConfiguration, crossThreadnessConfiguration>& other) : m_raw(other)
+ PersistentBase(const PersistentBase<U, weaknessConfiguration, crossThreadnessConfiguration>& other)
{
saveCreationThreadHeap();
- initialize();
+ if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration && weaknessConfiguration == WeakPersistentConfiguration) {
+ CrossThreadPersistentRegion::LockScope persistentLock(ProcessHeap::crossThreadPersistentRegion());
haraken 2016/08/18 13:15:31 I wonder why you need to add the LockScope here. I
keishi 2016/08/22 09:48:55 The original code sets m_raw then calls allocatePe
haraken 2016/08/22 13:59:59 I'd say that if that happens, it's a bug of the ca
+ m_raw = other;
+ initialize();
+ } else {
+ m_raw = other;
+ initialize();
+ }
checkPointer();
}
@@ -137,7 +144,12 @@ public:
template<typename U>
PersistentBase& operator=(const PersistentBase<U, weaknessConfiguration, crossThreadnessConfiguration>& other)
{
- assign(other);
+ if (crossThreadnessConfiguration == CrossThreadPersistentConfiguration && weaknessConfiguration == WeakPersistentConfiguration) {
+ CrossThreadPersistentRegion::LockScope persistentLock(ProcessHeap::crossThreadPersistentRegion());
+ assign(other);
+ } else {
+ assign(other);
+ }
return *this;
}
@@ -416,102 +428,105 @@ public:
}
};
-// Unlike Persistent, we can destruct a CrossThreadPersistent in a thread
-// different from the construction thread.
+// Combines the behavior of CrossThreadPersistent and WeakPersistent.
template<typename T>
-class CrossThreadPersistent : public PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersistentConfiguration> {
- typedef PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersistentConfiguration> Parent;
+class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistentConfiguration> {
+ typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistentConfiguration> Parent;
public:
- CrossThreadPersistent() : Parent() { }
- CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
- CrossThreadPersistent(T* raw) : Parent(raw) { }
- CrossThreadPersistent(T& raw) : Parent(raw) { }
- CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
+ CrossThreadWeakPersistent() : Parent() { }
+ CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { }
+ CrossThreadWeakPersistent(T* raw) : Parent(raw) { }
+ CrossThreadWeakPersistent(T& raw) : Parent(raw) { }
+ CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(other) { }
template<typename U>
- CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
+ CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Parent(other) { }
template<typename U>
- CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
- CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
-
- T* atomicGet() { return Parent::atomicGet(); }
+ CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { }
+ CrossThreadWeakPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
template<typename U>
- CrossThreadPersistent& operator=(U* other)
+ CrossThreadWeakPersistent& operator=(U* other)
{
Parent::operator=(other);
return *this;
}
- CrossThreadPersistent& operator=(std::nullptr_t)
+ CrossThreadWeakPersistent& operator=(std::nullptr_t)
{
Parent::operator=(nullptr);
return *this;
}
- CrossThreadPersistent& operator=(const CrossThreadPersistent& other)
+ CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent& other)
{
Parent::operator=(other);
return *this;
}
template<typename U>
- CrossThreadPersistent& operator=(const CrossThreadPersistent<U>& other)
+ CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent<U>& other)
{
Parent::operator=(other);
return *this;
}
template<typename U>
- CrossThreadPersistent& operator=(const Member<U>& other)
+ CrossThreadWeakPersistent& operator=(const Member<U>& other)
{
Parent::operator=(other);
return *this;
}
};
-// Combines the behavior of CrossThreadPersistent and WeakPersistent.
+// Unlike Persistent, we can destruct a CrossThreadPersistent in a thread
+// different from the construction thread.
template<typename T>
-class CrossThreadWeakPersistent : public PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistentConfiguration> {
- typedef PersistentBase<T, WeakPersistentConfiguration, CrossThreadPersistentConfiguration> Parent;
+class CrossThreadPersistent : public PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersistentConfiguration> {
+ typedef PersistentBase<T, NonWeakPersistentConfiguration, CrossThreadPersistentConfiguration> Parent;
public:
- CrossThreadWeakPersistent() : Parent() { }
- CrossThreadWeakPersistent(std::nullptr_t) : Parent(nullptr) { }
- CrossThreadWeakPersistent(T* raw) : Parent(raw) { }
- CrossThreadWeakPersistent(T& raw) : Parent(raw) { }
- CrossThreadWeakPersistent(const CrossThreadWeakPersistent& other) : Parent(other) { }
+ CrossThreadPersistent() : Parent() { }
+ CrossThreadPersistent(std::nullptr_t) : Parent(nullptr) { }
+ CrossThreadPersistent(T* raw) : Parent(raw) { }
+ CrossThreadPersistent(T& raw) : Parent(raw) { }
+ CrossThreadPersistent(const CrossThreadPersistent& other) : Parent(other) { }
template<typename U>
- CrossThreadWeakPersistent(const CrossThreadWeakPersistent<U>& other) : Parent(other) { }
+ CrossThreadPersistent(const CrossThreadPersistent<U>& other) : Parent(other) { }
template<typename U>
- CrossThreadWeakPersistent(const Member<U>& other) : Parent(other) { }
+ CrossThreadPersistent(const CrossThreadWeakPersistent<U>& other) : Parent(other) { }
+ template<typename U>
+ CrossThreadPersistent(const Member<U>& other) : Parent(other) { }
+ CrossThreadPersistent(WTF::HashTableDeletedValueType x) : Parent(x) { }
+
+ T* atomicGet() { return Parent::atomicGet(); }
template<typename U>
- CrossThreadWeakPersistent& operator=(U* other)
+ CrossThreadPersistent& operator=(U* other)
{
Parent::operator=(other);
return *this;
}
- CrossThreadWeakPersistent& operator=(std::nullptr_t)
+ CrossThreadPersistent& operator=(std::nullptr_t)
{
Parent::operator=(nullptr);
return *this;
}
- CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent& other)
+ CrossThreadPersistent& operator=(const CrossThreadPersistent& other)
{
Parent::operator=(other);
return *this;
}
template<typename U>
- CrossThreadWeakPersistent& operator=(const CrossThreadWeakPersistent<U>& other)
+ CrossThreadPersistent& operator=(const CrossThreadPersistent<U>& other)
{
Parent::operator=(other);
return *this;
}
template<typename U>
- CrossThreadWeakPersistent& operator=(const Member<U>& other)
+ CrossThreadPersistent& operator=(const Member<U>& other)
{
Parent::operator=(other);
return *this;
@@ -762,6 +777,12 @@ struct IsWeakReceiver<blink::WeakPersistent<T>> : std::true_type {};
template <typename T>
struct IsWeakReceiver<blink::CrossThreadWeakPersistent<T>> : std::true_type {};
+template <typename T>
+blink::CrossThreadPersistent<T> Unwrap(const blink::CrossThreadWeakPersistent<T>& wrapped)
+{
+ return blink::CrossThreadPersistent<T>(wrapped);
+}
+
}
#endif // Persistent_h
« 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