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_ConsoleInstance_h
8 #define mozilla_dom_ConsoleInstance_h
10 #include "mozilla/dom/Console.h"
12 namespace mozilla::dom
{
14 class ConsoleInstance final
: public nsISupports
, public nsWrapperCache
{
16 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
17 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(ConsoleInstance
)
20 explicit ConsoleInstance(JSContext
* aCx
,
21 const ConsoleInstanceOptions
& aOptions
);
24 JSObject
* WrapObject(JSContext
* aCx
,
25 JS::Handle
<JSObject
*> aGivenProto
) override
;
27 nsPIDOMWindowInner
* GetParentObject() const { return nullptr; }
30 void Log(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
33 void Info(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
36 void Warn(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
39 void Error(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
42 void Exception(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
45 void Debug(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
48 void Table(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
51 void Trace(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
54 void Dir(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
57 void Dirxml(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
60 void Group(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
63 void GroupCollapsed(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
66 void GroupEnd(JSContext
* aCx
);
69 void Time(JSContext
* aCx
, const nsAString
& aLabel
);
72 void TimeLog(JSContext
* aCx
, const nsAString
& aLabel
,
73 const Sequence
<JS::Value
>& aData
);
76 void TimeEnd(JSContext
* aCx
, const nsAString
& aLabel
);
79 void TimeStamp(JSContext
* aCx
, const JS::Handle
<JS::Value
> aData
);
82 void Profile(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
85 void ProfileEnd(JSContext
* aCx
, const Sequence
<JS::Value
>& aData
);
88 void Assert(JSContext
* aCx
, bool aCondition
,
89 const Sequence
<JS::Value
>& aData
);
92 void Count(JSContext
* aCx
, const nsAString
& aLabel
);
95 void CountReset(JSContext
* aCx
, const nsAString
& aLabel
);
98 void Clear(JSContext
* aCx
);
100 bool ShouldLog(ConsoleLogLevel aLevel
);
103 void ReportForServiceWorkerScope(const nsAString
& aScope
,
104 const nsAString
& aMessage
,
105 const nsACString
& aFilename
,
106 uint32_t aLineNumber
, uint32_t aColumnNumber
,
107 ConsoleLevel aLevel
);
113 static void MaxLogLevelPrefChangedCallback(const char* /* aPrefName */,
114 void* /* aClosure */);
116 ConsoleLogLevel mMaxLogLevel
;
117 nsCString mMaxLogLevelPref
;
118 RefPtr
<Console
> mConsole
;
121 } // namespace mozilla::dom
123 #endif // mozilla_dom_ConsoleInstance_h