IdleDeadline.h (1567B)
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_IdleDeadline_h 8 #define mozilla_dom_IdleDeadline_h 9 10 #include "js/TypeDecls.h" 11 #include "mozilla/dom/BindingDeclarations.h" 12 #include "nsCOMPtr.h" 13 #include "nsCycleCollectionParticipant.h" 14 #include "nsDOMNavigationTiming.h" 15 #include "nsWrapperCache.h" 16 17 class nsIGlobalObject; 18 class nsPIDOMWindowInner; 19 20 namespace mozilla::dom { 21 22 class IdleDeadline final : public nsISupports, public nsWrapperCache { 23 public: 24 IdleDeadline(nsPIDOMWindowInner* aWindow, bool aDidTimeout, 25 DOMHighResTimeStamp aDeadline); 26 27 IdleDeadline(nsIGlobalObject* aGlobal, bool aDidTimeout, 28 DOMHighResTimeStamp aDeadline); 29 30 nsIGlobalObject* GetParentObject() const { return mGlobal; } 31 32 virtual JSObject* WrapObject(JSContext* aCx, 33 JS::Handle<JSObject*> aGivenProto) override; 34 35 DOMHighResTimeStamp TimeRemaining(); 36 bool DidTimeout() const; 37 38 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 39 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(IdleDeadline) 40 41 private: 42 ~IdleDeadline(); 43 44 nsCOMPtr<nsPIDOMWindowInner> mWindow; 45 nsCOMPtr<nsIGlobalObject> mGlobal; 46 const bool mDidTimeout; 47 const DOMHighResTimeStamp mDeadline; 48 }; 49 50 } // namespace mozilla::dom 51 52 #endif // mozilla_dom_IdleDeadline_h