WorkerDebugger.h (1691B)
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/. */ 6 7 #ifndef mozilla_dom_workers_WorkerDebugger_h 8 #define mozilla_dom_workers_WorkerDebugger_h 9 10 #include "mozilla/dom/WorkerScope.h" 11 #include "nsCOMPtr.h" 12 #include "nsIWorkerDebugger.h" 13 14 class mozIDOMWindow; 15 class nsIPrincipal; 16 class nsPIDOMWindowInner; 17 18 namespace mozilla::dom { 19 20 class WorkerPrivate; 21 22 class WorkerDebugger : public nsIWorkerDebugger { 23 class ReportDebuggerErrorRunnable; 24 class PostDebuggerMessageRunnable; 25 26 CheckedUnsafePtr<WorkerPrivate> mWorkerPrivate; 27 bool mIsInitialized; 28 nsTArray<nsCOMPtr<nsIWorkerDebuggerListener>> mListeners; 29 30 public: 31 explicit WorkerDebugger(WorkerPrivate* aWorkerPrivate); 32 33 NS_DECL_ISUPPORTS 34 NS_DECL_NSIWORKERDEBUGGER 35 36 void AssertIsOnParentThread(); 37 38 void Close(); 39 40 void PostMessageToDebugger(const nsAString& aMessage); 41 42 void ReportErrorToDebugger(const nsACString& aFilename, uint32_t aLineno, 43 const nsAString& aMessage); 44 45 private: 46 virtual ~WorkerDebugger(); 47 48 void PostMessageToDebuggerOnMainThread(const nsAString& aMessage); 49 50 void ReportErrorToDebuggerOnMainThread(const nsACString& aFilename, 51 uint32_t aLineno, 52 const nsAString& aMessage); 53 54 nsCOMPtr<nsPIDOMWindowInner> DedicatedWorkerWindow(); 55 }; 56 57 } // namespace mozilla::dom 58 59 #endif // mozilla_dom_workers_WorkerDebugger_h