1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef XPCOM_THREADS_DELAYEDRUNNABLE_H_
8 #define XPCOM_THREADS_DELAYEDRUNNABLE_H_
10 #include "mozilla/TimeStamp.h"
12 #include "nsIDelayedRunnableObserver.h"
13 #include "nsIRunnable.h"
15 #include "nsThreadUtils.h"
19 class DelayedRunnable
: public Runnable
, public nsITimerCallback
{
21 DelayedRunnable(already_AddRefed
<nsIEventTarget
> aTarget
,
22 already_AddRefed
<nsIRunnable
> aRunnable
, uint32_t aDelay
);
24 NS_DECL_ISUPPORTS_INHERITED
26 NS_DECL_NSITIMERCALLBACK
31 * Cancels the underlying timer. Called when the target is going away, so the
32 * runnable can be released safely on the target thread.
37 ~DelayedRunnable() = default;
40 const nsCOMPtr
<nsIEventTarget
> mTarget
;
41 const nsCOMPtr
<nsIDelayedRunnableObserver
> mObserver
;
42 nsCOMPtr
<nsIRunnable
> mWrappedRunnable
;
43 nsCOMPtr
<nsITimer
> mTimer
;
44 const TimeStamp mDelayedFrom
;
48 } // namespace mozilla