Title: [218705] trunk/Source/WebKit2
- Revision
- 218705
- Author
- [email protected]
- Date
- 2017-06-22 10:34:35 -0700 (Thu, 22 Jun 2017)
Log Message
Add some thread safety guards to GenericCallback.
https://bugs.webkit.org/show_bug.cgi?id=173693
Reviewed by Sam Weinig.
A callback should be created, performed, invalidated, and/or destroyed all on the same thread.
Let's write code to notify us if that doesn't happen.
* UIProcess/GenericCallback.h:
(WebKit::GenericCallback::~GenericCallback):
(WebKit::GenericCallback::performCallbackWithReturnValue):
(WebKit::GenericCallback::invalidate):
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (218704 => 218705)
--- trunk/Source/WebKit2/ChangeLog 2017-06-22 17:07:52 UTC (rev 218704)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-22 17:34:35 UTC (rev 218705)
@@ -1,3 +1,18 @@
+2017-06-22 Brady Eidson <[email protected]>
+
+ Add some thread safety guards to GenericCallback.
+ https://bugs.webkit.org/show_bug.cgi?id=173693
+
+ Reviewed by Sam Weinig.
+
+ A callback should be created, performed, invalidated, and/or destroyed all on the same thread.
+ Let's write code to notify us if that doesn't happen.
+
+ * UIProcess/GenericCallback.h:
+ (WebKit::GenericCallback::~GenericCallback):
+ (WebKit::GenericCallback::performCallbackWithReturnValue):
+ (WebKit::GenericCallback::invalidate):
+
2017-06-22 David Kilzer <[email protected]>
v2: REGRESSION (r218419): 3 NSMutableDictionary leaks calling -[WKProcessPool _pluginLoadClientPolicies]
Modified: trunk/Source/WebKit2/UIProcess/GenericCallback.h (218704 => 218705)
--- trunk/Source/WebKit2/UIProcess/GenericCallback.h 2017-06-22 17:07:52 UTC (rev 218704)
+++ trunk/Source/WebKit2/UIProcess/GenericCallback.h 2017-06-22 17:34:35 UTC (rev 218705)
@@ -35,6 +35,7 @@
#include <wtf/MainThread.h>
#include <wtf/RefCounted.h>
#include <wtf/RunLoop.h>
+#include <wtf/Threading.h>
namespace WebKit {
@@ -100,11 +101,14 @@
virtual ~GenericCallback()
{
+ ASSERT(currentThread() == m_originThreadID);
ASSERT(!m_callback);
}
void performCallbackWithReturnValue(T... returnValue)
{
+ ASSERT(currentThread() == m_originThreadID);
+
if (!m_callback)
return;
@@ -120,6 +124,8 @@
void invalidate(Error error = Error::Unknown) final
{
+ ASSERT(currentThread() == m_originThreadID);
+
if (!m_callback)
return;
@@ -143,6 +149,10 @@
}
std::optional<CallbackFunction> m_callback;
+
+#ifndef NDEBUG
+ ThreadIdentifier m_originThreadID { currentThread() };
+#endif
};
template<typename APIReturnValueType, typename InternalReturnValueType = typename APITypeInfo<APIReturnValueType>::ImplType*>
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes