зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1811901 - part1 : implement conditional forward method on MediaEventForwarder. r=jolin
Differential Revision: https://phabricator.services.mozilla.com/D168013
This commit is contained in:
Родитель
7d268f85ca
Коммит
2fc0f48bca
|
@ -564,6 +564,19 @@ class MediaEventForwarder : public MediaEventSource<Es...> {
|
|||
}));
|
||||
}
|
||||
|
||||
template <typename Function>
|
||||
void ForwardIf(MediaEventSource<Es...>& aSource, Function&& aFunction) {
|
||||
// Forwarding a rawptr `this` here is fine, since DisconnectAll disconnect
|
||||
// all mListeners synchronously and prevents this handler from running.
|
||||
mListeners.AppendElement(aSource.Connect(
|
||||
mEventTarget, [this, func = aFunction](ArgType<Es>&&... aEvents) {
|
||||
if (!func()) {
|
||||
return;
|
||||
}
|
||||
this->NotifyInternal(std::forward<ArgType<Es>...>(aEvents)...);
|
||||
}));
|
||||
}
|
||||
|
||||
void DisconnectAll() {
|
||||
for (auto& l : mListeners) {
|
||||
l.Disconnect();
|
||||
|
|
Загрузка…
Ссылка в новой задаче