Line data Source code
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/. */
6 :
7 : #ifndef mozilla_dom_idlerequest_h
8 : #define mozilla_dom_idlerequest_h
9 :
10 : #include "mozilla/LinkedList.h"
11 : #include "mozilla/Maybe.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsCycleCollectionParticipant.h"
14 : #include "nsDOMNavigationTiming.h"
15 : #include "nsICancelableRunnable.h"
16 : #include "nsIRunnable.h"
17 : #include "nsString.h"
18 :
19 : class nsPIDOMWindowInner;
20 :
21 : namespace mozilla {
22 : namespace dom {
23 :
24 : class IdleRequestCallback;
25 :
26 : class IdleRequest final : public nsISupports,
27 : public LinkedListElement<IdleRequest>
28 : {
29 : public:
30 : IdleRequest(IdleRequestCallback* aCallback, uint32_t aHandle);
31 :
32 : nsresult IdleRun(nsPIDOMWindowInner* aWindow,
33 : DOMHighResTimeStamp aDeadline,
34 : bool aDidTimeout);
35 :
36 : void SetTimeoutHandle(int32_t aHandle);
37 1 : bool HasTimeout() const { return mTimeoutHandle.isSome(); }
38 : uint32_t GetTimeoutHandle() const;
39 :
40 0 : uint32_t Handle() const
41 : {
42 0 : return mHandle;
43 : }
44 :
45 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
46 19 : NS_DECL_CYCLE_COLLECTION_CLASS(IdleRequest)
47 :
48 : private:
49 : ~IdleRequest();
50 :
51 : RefPtr<IdleRequestCallback> mCallback;
52 : const uint32_t mHandle;
53 : mozilla::Maybe<int32_t> mTimeoutHandle;
54 : };
55 :
56 : } // namespace dom
57 : } // namespace mozilla
58 :
59 : #endif // mozilla_dom_idlerequest_h
|