Skip to content

Commit cf04808

Browse files
committed
Bug 1792474 - Part 1: Add an IsOnCurrentThread() helper to EventTargetCapability, r=xpcom-reviewers,kmag
The type will be used to explicitly track which members of IPC::Channel::ChannelImpl can only be accessed on the I/O thread vs. using the mutex. Differential Revision: https://phabricator.services.mozilla.com/D158159
1 parent ce9040c commit cf04808

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

xpcom/threads/EventTargetCapability.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ class MOZ_CAPABILITY EventTargetCapability final {
6666
EventTargetCapability& operator=(EventTargetCapability&&) = default;
6767

6868
void AssertOnCurrentThread() const MOZ_ASSERT_CAPABILITY(this) {
69-
MOZ_ASSERT(mTarget->IsOnCurrentThread());
69+
MOZ_ASSERT(IsOnCurrentThread());
7070
}
7171

72+
// Allow users to check if we're on the same thread as the event target.
73+
bool IsOnCurrentThread() const { return mTarget->IsOnCurrentThread(); }
74+
7275
// Allow users to get the event target, so classes don't have to store the
7376
// target as a separate member to use it.
74-
T* GetEventTarget() { return mTarget; }
77+
T* GetEventTarget() const { return mTarget; }
7578

7679
// Helper to simplify dispatching to mTarget.
7780
nsresult Dispatch(already_AddRefed<nsIRunnable> aRunnable,

0 commit comments

Comments
 (0)