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 : #ifndef nsIScriptTimeoutHandler_h___
7 : #define nsIScriptTimeoutHandler_h___
8 :
9 : #include "nsITimeoutHandler.h"
10 : #include "nsTArray.h"
11 : #include "js/TypeDecls.h"
12 : #include "mozilla/Maybe.h"
13 :
14 : namespace mozilla {
15 : namespace dom {
16 : class Function;
17 : } // namespace dom
18 : } // namespace mozilla
19 :
20 : #define NS_ISCRIPTTIMEOUTHANDLER_IID \
21 : { 0x53c8e80e, 0xcc78, 0x48bc, \
22 : { 0xba, 0x63, 0x0c, 0xb9, 0xdb, 0xf7, 0x06, 0x34 } }
23 :
24 : /**
25 : * Abstraction of the script objects etc required to do timeouts in a
26 : * language agnostic way.
27 : */
28 :
29 11 : class nsIScriptTimeoutHandler : public nsITimeoutHandler
30 : {
31 : public:
32 : NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISCRIPTTIMEOUTHANDLER_IID)
33 :
34 : // Get the Function to call. If this returns nullptr, GetHandlerText() will
35 : // be called to get the string.
36 : virtual mozilla::dom::Function* GetCallback() = 0;
37 :
38 : // Get the handler text of not a compiled object.
39 : virtual const nsAString& GetHandlerText() = 0;
40 :
41 : // Get the location of the script.
42 : // Note: The memory pointed to by aFileName is owned by the
43 : // nsIScriptTimeoutHandler and should not be freed by the caller.
44 :
45 : // If we have a Function, get the arguments for passing to it.
46 : virtual const nsTArray<JS::Value>& GetArgs() = 0;
47 : };
48 :
49 : NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptTimeoutHandler,
50 : NS_ISCRIPTTIMEOUTHANDLER_IID)
51 :
52 : #endif // nsIScriptTimeoutHandler_h___
|