mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1791761 - Add support for nsISerialEventTarget and nsIDirectTaskDispatcher to RemoteLazyInputStreamThread; r=dom-storage-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D157818
This commit is contained in:
parent
173881e7e3
commit
09461e0f96
@ -47,7 +47,8 @@ class ThreadInitializeRunnable final : public Runnable {
|
||||
|
||||
} // namespace
|
||||
|
||||
NS_IMPL_ISUPPORTS(RemoteLazyInputStreamThread, nsIObserver, nsIEventTarget)
|
||||
NS_IMPL_ISUPPORTS(RemoteLazyInputStreamThread, nsIObserver, nsIEventTarget,
|
||||
nsISerialEventTarget, nsIDirectTaskDispatcher)
|
||||
|
||||
bool RLISThreadIsInOrBeyondShutdown() {
|
||||
// ShutdownPhase::XPCOMShutdownThreads matches
|
||||
@ -182,6 +183,46 @@ RemoteLazyInputStreamThread::UnregisterShutdownTask(nsITargetShutdownTask*) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
RemoteLazyInputStreamThread::DispatchDirectTask(
|
||||
already_AddRefed<nsIRunnable> aRunnable) {
|
||||
nsCOMPtr<nsIRunnable> runnable(aRunnable);
|
||||
|
||||
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
|
||||
|
||||
nsCOMPtr<nsIDirectTaskDispatcher> dispatcher = do_QueryInterface(mThread);
|
||||
|
||||
if (dispatcher) {
|
||||
return dispatcher->DispatchDirectTask(runnable.forget());
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RemoteLazyInputStreamThread::DrainDirectTasks() {
|
||||
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
|
||||
|
||||
nsCOMPtr<nsIDirectTaskDispatcher> dispatcher = do_QueryInterface(mThread);
|
||||
|
||||
if (dispatcher) {
|
||||
return dispatcher->DrainDirectTasks();
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP RemoteLazyInputStreamThread::HaveDirectTasks(bool* aValue) {
|
||||
StaticMutexAutoLock lock(gRemoteLazyThreadMutex);
|
||||
|
||||
nsCOMPtr<nsIDirectTaskDispatcher> dispatcher = do_QueryInterface(mThread);
|
||||
|
||||
if (dispatcher) {
|
||||
return dispatcher->HaveDirectTasks(aValue);
|
||||
}
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
bool IsOnDOMFileThread() {
|
||||
MOZ_ASSERT(!RLISThreadIsInOrBeyondShutdown());
|
||||
|
||||
|
@ -18,12 +18,16 @@ namespace mozilla {
|
||||
|
||||
class RemoteLazyInputStreamChild;
|
||||
|
||||
// XXX Rename this class since it's used by LSNG too.
|
||||
class RemoteLazyInputStreamThread final : public nsIObserver,
|
||||
public nsIEventTarget {
|
||||
public nsISerialEventTarget,
|
||||
public nsIDirectTaskDispatcher {
|
||||
public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIEVENTTARGET
|
||||
NS_DECL_NSISERIALEVENTTARGET
|
||||
NS_DECL_NSIDIRECTTASKDISPATCHER
|
||||
|
||||
static RemoteLazyInputStreamThread* Get();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user