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