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