Title: [140580] trunk/Source/WebCore
- Revision
- 140580
- Author
- [email protected]
- Date
- 2013-01-23 13:26:11 -0800 (Wed, 23 Jan 2013)
Log Message
Assert that Supplementable objects is only used in their creator thread.
https://bugs.webkit.org/show_bug.cgi?id=107717.
Reviewed by Adam Barth.
No new tests.
* platform/Supplementable.h:
(WebCore):
(WebCore::Supplementable::provideSupplement):
(WebCore::Supplementable::removeSupplement):
(WebCore::Supplementable::requireSupplement):
(Supplementable):
(WebCore::Supplementable::Supplementable):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (140579 => 140580)
--- trunk/Source/WebCore/ChangeLog 2013-01-23 21:23:28 UTC (rev 140579)
+++ trunk/Source/WebCore/ChangeLog 2013-01-23 21:26:11 UTC (rev 140580)
@@ -1,3 +1,20 @@
+2013-01-23 Mark Lam <[email protected]>
+
+ Assert that Supplementable objects is only used in their creator thread.
+ https://bugs.webkit.org/show_bug.cgi?id=107717.
+
+ Reviewed by Adam Barth.
+
+ No new tests.
+
+ * platform/Supplementable.h:
+ (WebCore):
+ (WebCore::Supplementable::provideSupplement):
+ (WebCore::Supplementable::removeSupplement):
+ (WebCore::Supplementable::requireSupplement):
+ (Supplementable):
+ (WebCore::Supplementable::Supplementable):
+
2013-01-23 Tony Chang <[email protected]>
Incorrect scrollable height during simplified layout
Modified: trunk/Source/WebCore/platform/Supplementable.h (140579 => 140580)
--- trunk/Source/WebCore/platform/Supplementable.h 2013-01-23 21:23:28 UTC (rev 140579)
+++ trunk/Source/WebCore/platform/Supplementable.h 2013-01-23 21:26:11 UTC (rev 140580)
@@ -26,12 +26,25 @@
#ifndef Supplementable_h
#define Supplementable_h
+#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#if !ASSERT_DISABLED
+#include <wtf/Threading.h>
+#endif
+
namespace WebCore {
+// What you should know about Supplementable and Supplement
+// ========================================================
+// Supplementable and Supplement instances are meant to be thread local. They
+// should only be accessed from within the thread that created them. The
+// 2 classes are not designed for safe access from another thread. Violating
+// this design assumption can result in memory corruption and unpredictable
+// behavior.
+//
// What you should know about the Supplement keys
// ==============================================
// The Supplement is expected to use the same const char* string instance
@@ -86,25 +99,37 @@
public:
void provideSupplement(const char* key, PassOwnPtr<Supplement<T> > supplement)
{
+ ASSERT(m_threadId == currentThread());
ASSERT(!m_supplements.get(key));
m_supplements.set(key, supplement);
}
void removeSupplement(const char* key)
{
+ ASSERT(m_threadId == currentThread());
m_supplements.remove(key);
}
Supplement<T>* requireSupplement(const char* key)
{
+ ASSERT(m_threadId == currentThread());
return m_supplements.get(key);
}
+#if !ASSERT_DISABLED
+protected:
+ Supplementable() : m_threadId(currentThread()) { }
+#endif
+
private:
typedef HashMap<const char*, OwnPtr<Supplement<T> >, PtrHash<const char*> > SupplementMap;
SupplementMap m_supplements;
+#if !ASSERT_DISABLED
+ ThreadIdentifier m_threadId;
+#endif
};
} // namespace WebCore
#endif // Supplementable_h
+
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes