IdleRequest.h (1517B)
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 "mozilla/RefPtr.h" 13 #include "nsCOMPtr.h" 14 #include "nsCycleCollectionParticipant.h" 15 #include "nsDOMNavigationTiming.h" 16 #include "nsICancelableRunnable.h" 17 #include "nsString.h" 18 19 class nsPIDOMWindowInner; 20 21 namespace mozilla::dom { 22 23 class IdleRequestCallback; 24 25 class IdleRequest final : public LinkedListElement<RefPtr<IdleRequest>> { 26 public: 27 IdleRequest(IdleRequestCallback* aCallback, uint32_t aHandle); 28 29 MOZ_CAN_RUN_SCRIPT 30 void IdleRun(nsPIDOMWindowInner* aWindow, DOMHighResTimeStamp aDeadline, 31 bool aDidTimeout); 32 33 void SetTimeoutHandle(int32_t aHandle); 34 bool HasTimeout() const { return mTimeoutHandle.isSome(); } 35 int32_t GetTimeoutHandle() const; 36 37 uint32_t Handle() const { return mHandle; } 38 39 NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(IdleRequest) 40 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(IdleRequest) 41 private: 42 ~IdleRequest(); 43 44 RefPtr<IdleRequestCallback> mCallback; 45 const uint32_t mHandle; 46 mozilla::Maybe<int32_t> mTimeoutHandle; 47 }; 48 49 } // namespace mozilla::dom 50 51 #endif // mozilla_dom_idlerequest_h