Bug 1755481: correct documentation of `nsIClipboard::getData`. r=mccr8
[gecko.git] / xpcom / threads / DelayedRunnable.h
blob0bca644e42ff7f781b83db54b99b816b8a31d3b0
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"
11 #include "nsCOMPtr.h"
12 #include "nsIDelayedRunnableObserver.h"
13 #include "nsIRunnable.h"
14 #include "nsITimer.h"
15 #include "nsThreadUtils.h"
17 namespace mozilla {
19 class DelayedRunnable : public Runnable, public nsITimerCallback {
20 public:
21 DelayedRunnable(already_AddRefed<nsIEventTarget> aTarget,
22 already_AddRefed<nsIRunnable> aRunnable, uint32_t aDelay);
24 NS_DECL_ISUPPORTS_INHERITED
25 NS_DECL_NSIRUNNABLE
26 NS_DECL_NSITIMERCALLBACK
28 nsresult Init();
30 /**
31 * Cancels the underlying timer. Called when the target is going away, so the
32 * runnable can be released safely on the target thread.
34 void CancelTimer();
36 private:
37 ~DelayedRunnable() = default;
38 nsresult DoRun();
40 const nsCOMPtr<nsIEventTarget> mTarget;
41 const nsCOMPtr<nsIDelayedRunnableObserver> mObserver;
42 nsCOMPtr<nsIRunnable> mWrappedRunnable;
43 nsCOMPtr<nsITimer> mTimer;
44 const TimeStamp mDelayedFrom;
45 uint32_t mDelay;
48 } // namespace mozilla
50 #endif