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 nsIIdleRunnable_h__ 8 #define nsIIdleRunnable_h__ 9 10 #include "nsISupports.h" 11 #include "mozilla/TimeStamp.h" 12 13 #define NS_IIDLERUNNABLE_IID \ 14 { \ 15 0x688be92e, 0x7ade, 0x4fdc, { \ 16 0x9d, 0x83, 0x74, 0xcb, 0xef, 0xf4, 0xa5, 0x2c \ 17 } \ 18 } 19 20 class nsIEventTarget; 21 22 /** 23 * A task interface for tasks that can schedule their work to happen 24 * in increments bounded by a deadline. 25 */ 26 class nsIIdleRunnable : public nsISupports { 27 public: NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIDLERUNNABLE_IID)28 NS_DECLARE_STATIC_IID_ACCESSOR(NS_IIDLERUNNABLE_IID) 29 30 /** 31 * Notify the task of a point in time in the future when the task 32 * should stop executing. 33 */ 34 virtual void SetDeadline(mozilla::TimeStamp aDeadline){}; SetTimer(uint32_t aDelay,nsIEventTarget * aTarget)35 virtual void SetTimer(uint32_t aDelay, nsIEventTarget* aTarget) { 36 MOZ_ASSERT_UNREACHABLE( 37 "The nsIIdleRunnable instance does not support " 38 "idle dispatch with timeout!"); 39 }; 40 41 protected: 42 nsIIdleRunnable() = default; 43 virtual ~nsIIdleRunnable() = default; 44 }; 45 46 NS_DEFINE_STATIC_IID_ACCESSOR(nsIIdleRunnable, NS_IIDLERUNNABLE_IID) 47 48 #endif // nsIIdleRunnable_h__ 49