Bug 1639230: Remove vendor prefix for printing with webdriver r=jgraham,webdriver...
[gecko.git] / dom / promise / PromiseDebugging.h
blob6397d2aeb9981dc5f676a458141b93de8e0dde1d
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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_PromiseDebugging_h
8 #define mozilla_dom_PromiseDebugging_h
10 #include "js/TypeDecls.h"
11 #include "nsTArray.h"
12 #include "mozilla/RefPtr.h"
14 namespace mozilla {
16 class ErrorResult;
18 namespace dom {
19 class Promise;
20 struct PromiseDebuggingStateHolder;
21 class GlobalObject;
22 class UncaughtRejectionObserver;
23 class FlushRejections;
24 class WorkerPrivate;
26 void TriggerFlushRejections();
28 class PromiseDebugging {
29 public:
30 static void Init();
31 static void Shutdown();
33 static void GetState(GlobalObject&, JS::Handle<JSObject*> aPromise,
34 PromiseDebuggingStateHolder& aState, ErrorResult& aRv);
36 static void GetPromiseID(GlobalObject&, JS::Handle<JSObject*>, nsString&,
37 ErrorResult&);
39 static void GetAllocationStack(GlobalObject&, JS::Handle<JSObject*> aPromise,
40 JS::MutableHandle<JSObject*> aStack,
41 ErrorResult& aRv);
42 static void GetRejectionStack(GlobalObject&, JS::Handle<JSObject*> aPromise,
43 JS::MutableHandle<JSObject*> aStack,
44 ErrorResult& aRv);
45 static void GetFullfillmentStack(GlobalObject&,
46 JS::Handle<JSObject*> aPromise,
47 JS::MutableHandle<JSObject*> aStack,
48 ErrorResult& aRv);
50 // Mechanism for watching uncaught instances of Promise.
51 static void AddUncaughtRejectionObserver(
52 GlobalObject&, UncaughtRejectionObserver& aObserver);
53 static bool RemoveUncaughtRejectionObserver(
54 GlobalObject&, UncaughtRejectionObserver& aObserver);
56 // Mark a Promise as having been left uncaught at script completion.
57 static void AddUncaughtRejection(JS::HandleObject);
58 // Mark a Promise previously added with `AddUncaughtRejection` as
59 // eventually consumed.
60 static void AddConsumedRejection(JS::HandleObject);
61 // Propagate the informations from AddUncaughtRejection
62 // and AddConsumedRejection to observers.
63 static void FlushUncaughtRejections();
65 protected:
66 static void FlushUncaughtRejectionsInternal();
67 friend class FlushRejections;
68 friend class mozilla::dom::WorkerPrivate;
70 private:
71 // Identity of the process.
72 // This property is:
73 // - set during initialization of the layout module,
74 // prior to any Worker using it;
75 // - read by both the main thread and the Workers;
76 // - unset during shutdown of the layout module,
77 // after any Worker has been shutdown.
78 static nsString sIDPrefix;
81 } // namespace dom
82 } // namespace mozilla
84 #endif // mozilla_dom_PromiseDebugging_h