Backed out changeset 2450366cf7ca (bug 1891629) for causing win msix mochitest failures
[gecko.git] / dom / console / ConsoleUtils.h
blob6e3d71ea04812d9fd165d3b66d10bd6e007484eb
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/. */
7 #ifndef mozilla_dom_ConsoleUtils_h
8 #define mozilla_dom_ConsoleUtils_h
10 #include "mozilla/JSObjectHolder.h"
11 #include "nsISupportsImpl.h"
12 #include "nsString.h"
14 namespace mozilla::dom {
16 class ConsoleUtils final {
17 public:
18 NS_INLINE_DECL_REFCOUNTING(ConsoleUtils)
20 enum Level {
21 eLog,
22 eWarning,
23 eError,
26 // Main-thread only, reports a console message from a ServiceWorker.
27 static void ReportForServiceWorkerScope(const nsAString& aScope,
28 const nsAString& aMessage,
29 const nsAString& aFilename,
30 uint32_t aLineNumber,
31 uint32_t aColumnNumber, Level aLevel);
33 private:
34 ConsoleUtils();
35 ~ConsoleUtils();
37 static ConsoleUtils* GetOrCreate();
39 JSObject* GetOrCreateSandbox(JSContext* aCx);
41 void ReportForServiceWorkerScopeInternal(const nsAString& aScope,
42 const nsAString& aMessage,
43 const nsAString& aFilename,
44 uint32_t aLineNumber,
45 uint32_t aColumnNumber,
46 Level aLevel);
48 RefPtr<JSObjectHolder> mSandbox;
51 } // namespace mozilla::dom
53 #endif /* mozilla_dom_ConsoleUtils_h */