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 mozilla_dom_idlerequest_h
8 #define mozilla_dom_idlerequest_h
10 #include "mozilla/LinkedList.h"
11 #include "mozilla/Maybe.h"
12 #include "mozilla/RefPtr.h"
14 #include "nsCycleCollectionParticipant.h"
15 #include "nsDOMNavigationTiming.h"
16 #include "nsICancelableRunnable.h"
19 class nsPIDOMWindowInner
;
21 namespace mozilla::dom
{
23 class IdleRequestCallback
;
25 class IdleRequest final
: public LinkedListElement
<RefPtr
<IdleRequest
>> {
27 IdleRequest(IdleRequestCallback
* aCallback
, uint32_t aHandle
);
30 void IdleRun(nsPIDOMWindowInner
* aWindow
, DOMHighResTimeStamp aDeadline
,
33 void SetTimeoutHandle(int32_t aHandle
);
34 bool HasTimeout() const { return mTimeoutHandle
.isSome(); }
35 uint32_t GetTimeoutHandle() const;
37 uint32_t Handle() const { return mHandle
; }
39 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(IdleRequest
)
40 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(IdleRequest
)
44 RefPtr
<IdleRequestCallback
> mCallback
;
45 const uint32_t mHandle
;
46 mozilla::Maybe
<int32_t> mTimeoutHandle
;
49 } // namespace mozilla::dom
51 #endif // mozilla_dom_idlerequest_h