Changeset 218705 in webkit


Ignore:
Timestamp:
Jun 22, 2017 10:34:35 AM (7 years ago)
Author:
beidson@apple.com
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):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r218704 r218705  
     12017-06-22  Brady Eidson  <beidson@apple.com>
     2
     3        Add some thread safety guards to GenericCallback.
     4        https://bugs.webkit.org/show_bug.cgi?id=173693
     5
     6        Reviewed by Sam Weinig.
     7
     8        A callback should be created, performed, invalidated, and/or destroyed all on the same thread.
     9        Let's write code to notify us if that doesn't happen.
     10
     11        * UIProcess/GenericCallback.h:
     12        (WebKit::GenericCallback::~GenericCallback):
     13        (WebKit::GenericCallback::performCallbackWithReturnValue):
     14        (WebKit::GenericCallback::invalidate):
     15
    1162017-06-22  David Kilzer  <ddkilzer@apple.com>
    217
  • trunk/Source/WebKit2/UIProcess/GenericCallback.h

    r218676 r218705  
    3636#include <wtf/RefCounted.h>
    3737#include <wtf/RunLoop.h>
     38#include <wtf/Threading.h>
    3839
    3940namespace WebKit {
     
    101102    virtual ~GenericCallback()
    102103    {
     104        ASSERT(currentThread() == m_originThreadID);
    103105        ASSERT(!m_callback);
    104106    }
     
    106108    void performCallbackWithReturnValue(T... returnValue)
    107109    {
     110        ASSERT(currentThread() == m_originThreadID);
     111
    108112        if (!m_callback)
    109113            return;
     
    121125    void invalidate(Error error = Error::Unknown) final
    122126    {
     127        ASSERT(currentThread() == m_originThreadID);
     128
    123129        if (!m_callback)
    124130            return;
     
    144150
    145151    std::optional<CallbackFunction> m_callback;
     152
     153#ifndef NDEBUG
     154    ThreadIdentifier m_originThreadID { currentThread() };
     155#endif
    146156};
    147157
Note: See TracChangeset for help on using the changeset viewer.