Bug 1787199 [wpt PR 35620] - Add tests for `VisibilityStateEntry`, a=testonly
[gecko.git] / dom / workers / WorkerDebugger.h
blob73efe402c8bb4496671401c9a9723a989742f990
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_workers_WorkerDebugger_h
8 #define mozilla_dom_workers_WorkerDebugger_h
10 #include "mozilla/PerformanceTypes.h"
11 #include "mozilla/dom/WorkerScope.h"
12 #include "nsCOMPtr.h"
13 #include "nsIWorkerDebugger.h"
15 class mozIDOMWindow;
16 class nsIPrincipal;
17 class nsPIDOMWindowInner;
19 namespace mozilla::dom {
21 class WorkerPrivate;
23 class WorkerDebugger : public nsIWorkerDebugger {
24 class ReportDebuggerErrorRunnable;
25 class PostDebuggerMessageRunnable;
27 CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate;
28 bool mIsInitialized;
29 nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners;
31 public:
32 explicit WorkerDebugger(WorkerPrivate* aWorkerPrivate);
34 NS_DECL_ISUPPORTS
35 NS_DECL_NSIWORKERDEBUGGER
37 void AssertIsOnParentThread();
39 void Close();
41 void PostMessageToDebugger(const nsAString& aMessage);
43 void ReportErrorToDebugger(const nsAString& aFilename, uint32_t aLineno,
44 const nsAString& aMessage);
47 * Sends back a PerformanceInfo struct from the counters
48 * in mWorkerPrivate. Counters are reset to zero after this call.
50 RefPtr<PerformanceInfoPromise> ReportPerformanceInfo();
52 private:
53 virtual ~WorkerDebugger();
55 void PostMessageToDebuggerOnMainThread(const nsAString& aMessage);
57 void ReportErrorToDebuggerOnMainThread(const nsAString& aFilename,
58 uint32_t aLineno,
59 const nsAString& aMessage);
61 nsCOMPtr<nsPIDOMWindowInner> DedicatedWorkerWindow();
64 } // namespace mozilla::dom
66 #endif // mozilla_dom_workers_WorkerDebugger_h