2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2014-02-28 03:39:00 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_Console_h
|
|
|
|
#define mozilla_dom_Console_h
|
|
|
|
|
2018-01-04 21:19:44 +03:00
|
|
|
#include "mozilla/dom/ConsoleBinding.h"
|
2015-07-21 21:31:44 +03:00
|
|
|
#include "mozilla/JSObjectHolder.h"
|
2017-12-20 16:35:34 +03:00
|
|
|
#include "mozilla/TimeStamp.h"
|
2014-02-28 03:39:00 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsDataHashtable.h"
|
|
|
|
#include "nsHashKeys.h"
|
2014-02-28 03:39:17 +04:00
|
|
|
#include "nsIObserver.h"
|
2016-01-21 16:17:33 +03:00
|
|
|
#include "nsWeakReference.h"
|
2014-10-01 22:43:26 +04:00
|
|
|
#include "nsDOMNavigationTiming.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
2014-02-28 03:39:00 +04:00
|
|
|
|
|
|
|
class nsIConsoleAPIStorage;
|
2015-07-01 16:56:00 +03:00
|
|
|
class nsIPrincipal;
|
2018-01-04 21:19:44 +03:00
|
|
|
class nsIStackFrame;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
class AnyCallback;
|
2014-02-28 03:39:00 +04:00
|
|
|
class ConsoleCallData;
|
2018-01-04 21:19:43 +03:00
|
|
|
class ConsoleInstance;
|
2018-01-04 21:19:44 +03:00
|
|
|
class ConsoleInstanceDumpCallback;
|
2016-02-07 13:29:12 +03:00
|
|
|
class ConsoleRunnable;
|
|
|
|
class ConsoleCallDataRunnable;
|
|
|
|
class ConsoleProfileRunnable;
|
2020-03-25 04:06:16 +03:00
|
|
|
class MainThreadConsoleData;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
class Console final : public nsIObserver, public nsSupportsWeakReference {
|
2014-02-28 03:39:00 +04:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2016-01-21 16:17:33 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(Console, nsIObserver)
|
2014-02-28 03:39:17 +04:00
|
|
|
NS_DECL_NSIOBSERVER
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
static already_AddRefed<Console> Create(JSContext* aCx,
|
2018-02-22 10:49:51 +03:00
|
|
|
nsPIDOMWindowInner* aWindow,
|
|
|
|
ErrorResult& aRv);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2018-04-12 07:21:20 +03:00
|
|
|
static already_AddRefed<Console> CreateForWorklet(JSContext* aCx,
|
2018-09-28 10:10:07 +03:00
|
|
|
nsIGlobalObject* aGlobal,
|
|
|
|
uint64_t aOuterWindowID,
|
|
|
|
uint64_t aInnerWindowID,
|
|
|
|
ErrorResult& aRv);
|
2018-09-25 16:26:04 +03:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Log(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Info(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Warn(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Error(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Exception(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Debug(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Table(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:52:24 +03:00
|
|
|
static void Trace(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-08-28 02:32:32 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Dir(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Dirxml(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Group(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2015-04-29 18:34:00 +03:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void GroupCollapsed(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-18 11:04:00 +03:00
|
|
|
static void GroupEnd(const GlobalObject& aGlobal);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:52:31 +03:00
|
|
|
static void Time(const GlobalObject& aGlobal, const nsAString& aLabel);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-05-15 14:00:49 +03:00
|
|
|
static void TimeLog(const GlobalObject& aGlobal, const nsAString& aLabel,
|
|
|
|
const Sequence<JS::Value>& aData);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:52:31 +03:00
|
|
|
static void TimeEnd(const GlobalObject& aGlobal, const nsAString& aLabel);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void TimeStamp(const GlobalObject& aGlobal,
|
|
|
|
const JS::Handle<JS::Value> aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Profile(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2015-04-29 22:48:57 +03:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void ProfileEnd(const GlobalObject& aGlobal,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Assert(const GlobalObject& aGlobal, bool aCondition,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:52:41 +03:00
|
|
|
static void Count(const GlobalObject& aGlobal, const nsAString& aLabel);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-05-22 12:34:41 +03:00
|
|
|
static void CountReset(const GlobalObject& aGlobal, const nsAString& aLabel);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:50:13 +03:00
|
|
|
static void Clear(const GlobalObject& aGlobal);
|
2014-02-28 03:39:24 +04:00
|
|
|
|
2018-01-04 21:19:43 +03:00
|
|
|
static already_AddRefed<ConsoleInstance> CreateInstance(
|
|
|
|
const GlobalObject& aGlobal, const ConsoleInstanceOptions& aOptions);
|
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
void ClearStorage();
|
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
void RetrieveConsoleEvents(JSContext* aCx, nsTArray<JS::Value>& aEvents,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2016-03-29 17:56:10 +03:00
|
|
|
void SetConsoleEventHandler(AnyCallback* aHandler);
|
2016-03-24 00:55:07 +03:00
|
|
|
|
2014-02-28 03:39:00 +04:00
|
|
|
private:
|
2018-09-28 10:10:07 +03:00
|
|
|
Console(JSContext* aCx, nsIGlobalObject* aGlobal, uint64_t aOuterWindowID,
|
2018-04-12 07:21:20 +03:00
|
|
|
uint64_t aInnerWIndowID);
|
2016-05-03 11:19:39 +03:00
|
|
|
~Console();
|
2016-03-24 00:55:07 +03:00
|
|
|
|
|
|
|
void Initialize(ErrorResult& aRv);
|
|
|
|
|
|
|
|
void Shutdown();
|
|
|
|
|
2014-02-28 03:39:00 +04:00
|
|
|
enum MethodName {
|
|
|
|
MethodLog,
|
|
|
|
MethodInfo,
|
|
|
|
MethodWarn,
|
|
|
|
MethodError,
|
|
|
|
MethodException,
|
|
|
|
MethodDebug,
|
2014-08-28 02:32:32 +04:00
|
|
|
MethodTable,
|
2014-02-28 03:39:00 +04:00
|
|
|
MethodTrace,
|
|
|
|
MethodDir,
|
2015-04-29 18:34:00 +03:00
|
|
|
MethodDirxml,
|
2014-02-28 03:39:00 +04:00
|
|
|
MethodGroup,
|
|
|
|
MethodGroupCollapsed,
|
|
|
|
MethodGroupEnd,
|
|
|
|
MethodTime,
|
2018-05-15 14:00:49 +03:00
|
|
|
MethodTimeLog,
|
2014-02-28 03:39:00 +04:00
|
|
|
MethodTimeEnd,
|
2015-04-29 22:48:57 +03:00
|
|
|
MethodTimeStamp,
|
2014-02-28 03:39:24 +04:00
|
|
|
MethodAssert,
|
2016-04-13 17:33:43 +03:00
|
|
|
MethodCount,
|
2018-05-22 12:34:41 +03:00
|
|
|
MethodCountReset,
|
2018-01-04 21:19:44 +03:00
|
|
|
MethodClear,
|
|
|
|
MethodProfile,
|
|
|
|
MethodProfileEnd,
|
2014-02-28 03:39:00 +04:00
|
|
|
};
|
|
|
|
|
2016-06-04 10:32:51 +03:00
|
|
|
static already_AddRefed<Console> GetConsole(const GlobalObject& aGlobal);
|
|
|
|
|
2017-12-20 16:35:34 +03:00
|
|
|
static already_AddRefed<Console> GetConsoleInternal(
|
2016-11-06 11:54:52 +03:00
|
|
|
const GlobalObject& aGlobal, ErrorResult& aRv);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-04 21:19:44 +03:00
|
|
|
static void ProfileMethod(const GlobalObject& aGlobal, MethodName aName,
|
|
|
|
const nsAString& aAction,
|
|
|
|
const Sequence<JS::Value>& aData);
|
2016-06-04 10:32:51 +03:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-04 21:19:44 +03:00
|
|
|
void ProfileMethodInternal(JSContext* aCx, MethodName aName,
|
|
|
|
const nsAString& aAction,
|
2016-06-04 10:32:51 +03:00
|
|
|
const Sequence<JS::Value>& aData);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
// Implementation of the mainthread-only parts of ProfileMethod.
|
|
|
|
// This is indepedent of console instance state.
|
|
|
|
static void ProfileMethodMainthread(JSContext* aCx, const nsAString& aAction,
|
|
|
|
const Sequence<JS::Value>& aData);
|
|
|
|
|
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
static void Method(const GlobalObject& aGlobal, MethodName aName,
|
|
|
|
const nsAString& aString,
|
|
|
|
const Sequence<JS::Value>& aData);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-06-04 10:32:51 +03:00
|
|
|
void MethodInternal(JSContext* aCx, MethodName aName,
|
2017-04-20 14:52:31 +03:00
|
|
|
const nsAString& aString,
|
|
|
|
const Sequence<JS::Value>& aData);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2017-04-20 14:52:41 +03:00
|
|
|
static void StringMethod(const GlobalObject& aGlobal, const nsAString& aLabel,
|
2018-05-15 14:00:49 +03:00
|
|
|
const Sequence<JS::Value>& aData,
|
|
|
|
MethodName aMethodName,
|
|
|
|
const nsAString& aMethodString);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-04 21:19:43 +03:00
|
|
|
void StringMethodInternal(JSContext* aCx, const nsAString& aLabel,
|
2018-05-15 14:00:49 +03:00
|
|
|
const Sequence<JS::Value>& aData,
|
2018-01-04 21:19:43 +03:00
|
|
|
MethodName aMethodName,
|
|
|
|
const nsAString& aMethodString);
|
|
|
|
|
2020-03-25 04:06:16 +03:00
|
|
|
MainThreadConsoleData* GetOrCreateMainThreadData();
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2020-03-25 03:47:15 +03:00
|
|
|
// Returns true on success; otherwise false.
|
|
|
|
bool StoreCallData(JSContext* aCx, ConsoleCallData* aCallData,
|
|
|
|
const Sequence<JS::Value>& aArguments);
|
2016-03-24 00:55:07 +03:00
|
|
|
|
|
|
|
void UnstoreCallData(ConsoleCallData* aData);
|
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
// aCx and aArguments must be in the same JS compartment.
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2016-03-24 00:55:07 +03:00
|
|
|
void NotifyHandler(JSContext* aCx, const Sequence<JS::Value>& aArguments,
|
2017-04-18 11:04:00 +03:00
|
|
|
ConsoleCallData* aData);
|
2016-03-24 00:55:07 +03:00
|
|
|
|
2016-03-24 11:29:08 +03:00
|
|
|
// PopulateConsoleNotificationInTheTargetScope receives aCx and aArguments in
|
2020-03-25 03:22:34 +03:00
|
|
|
// the same JS compartment and populates the ConsoleEvent object
|
|
|
|
// (aEventValue) in the aTargetScope.
|
2016-03-24 00:55:07 +03:00
|
|
|
// aTargetScope can be:
|
|
|
|
// - the system-principal scope when we want to dispatch the ConsoleEvent to
|
|
|
|
// nsIConsoleAPIStorage (See the comment in Console.cpp about the use of
|
|
|
|
// xpc::PrivilegedJunkScope()
|
2018-08-07 15:06:44 +03:00
|
|
|
// - the mConsoleEventNotifier->CallableGlobal() when we want to notify this
|
2016-03-24 00:55:07 +03:00
|
|
|
// handler about a new ConsoleEvent.
|
|
|
|
// - It can be the global from the JSContext when RetrieveConsoleEvents is
|
|
|
|
// called.
|
2020-03-25 03:22:34 +03:00
|
|
|
static bool PopulateConsoleNotificationInTheTargetScope(
|
2016-03-24 11:29:08 +03:00
|
|
|
JSContext* aCx, const Sequence<JS::Value>& aArguments,
|
2020-03-25 03:22:34 +03:00
|
|
|
JS::Handle<JSObject*> aTargetScope,
|
|
|
|
JS::MutableHandle<JS::Value> aEventValue, ConsoleCallData* aData,
|
|
|
|
nsTArray<nsString>* aGroupStack);
|
2016-03-24 00:55:07 +03:00
|
|
|
|
2017-05-12 00:36:12 +03:00
|
|
|
enum TimerStatus {
|
2017-05-12 00:36:09 +03:00
|
|
|
eTimerUnknown,
|
2017-05-12 00:36:12 +03:00
|
|
|
eTimerDone,
|
2017-05-12 00:36:09 +03:00
|
|
|
eTimerAlreadyExists,
|
2017-05-12 00:36:12 +03:00
|
|
|
eTimerDoesntExist,
|
2017-05-12 00:36:09 +03:00
|
|
|
eTimerJSException,
|
|
|
|
eTimerMaxReached,
|
|
|
|
};
|
|
|
|
|
2020-03-25 03:51:50 +03:00
|
|
|
static JS::Value CreateTimerError(JSContext* aCx, const nsAString& aLabel,
|
|
|
|
TimerStatus aStatus);
|
2017-05-12 00:36:12 +03:00
|
|
|
|
2016-02-11 20:09:22 +03:00
|
|
|
// StartTimer is called on the owning thread and populates aTimerLabel and
|
2017-05-12 00:36:09 +03:00
|
|
|
// aTimerValue.
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aCx - the JSContext rooting aName.
|
|
|
|
// * aName - this is (should be) the name of the timer as JS::Value.
|
2016-12-16 11:07:39 +03:00
|
|
|
// * aTimestamp - the monotonicTimer for this context taken from
|
|
|
|
// performance.now().
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aTimerLabel - This label will be populated with the aName converted to a
|
|
|
|
// string.
|
|
|
|
// * aTimerValue - the StartTimer value stored into (or taken from)
|
|
|
|
// mTimerRegistry.
|
2014-02-28 03:39:00 +04:00
|
|
|
TimerStatus StartTimer(JSContext* aCx, const JS::Value& aName,
|
2016-02-11 20:09:22 +03:00
|
|
|
DOMHighResTimeStamp aTimestamp, nsAString& aTimerLabel,
|
|
|
|
DOMHighResTimeStamp* aTimerValue);
|
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
// CreateStartTimerValue generates a ConsoleTimerStart dictionary exposed as
|
|
|
|
// JS::Value. If aTimerStatus is false, it generates a ConsoleTimerError
|
|
|
|
// instead. It's called only after the execution StartTimer on the owning
|
|
|
|
// thread.
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aCx - this is the context that will root the returned value.
|
|
|
|
// * aTimerLabel - this label must be what StartTimer received as aTimerLabel.
|
|
|
|
// * aTimerStatus - the return value of StartTimer.
|
2020-03-25 03:51:50 +03:00
|
|
|
static JS::Value CreateStartTimerValue(JSContext* aCx,
|
|
|
|
const nsAString& aTimerLabel,
|
|
|
|
TimerStatus aTimerStatus);
|
2016-02-11 20:09:22 +03:00
|
|
|
|
2018-05-15 14:00:49 +03:00
|
|
|
// LogTimer follows the same pattern as StartTimer: it runs on the
|
2016-02-11 20:09:22 +03:00
|
|
|
// owning thread and populates aTimerLabel and aTimerDuration, used by
|
2018-05-15 14:00:49 +03:00
|
|
|
// CreateLogOrEndTimerValue.
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aCx - the JSContext rooting aName.
|
|
|
|
// * aName - this is (should be) the name of the timer as JS::Value.
|
2016-12-16 11:07:39 +03:00
|
|
|
// * aTimestamp - the monotonicTimer for this context taken from
|
|
|
|
// performance.now().
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aTimerLabel - This label will be populated with the aName converted to a
|
|
|
|
// string.
|
|
|
|
// * aTimerDuration - the difference between aTimestamp and when the timer
|
|
|
|
// started (see StartTimer).
|
2018-05-15 14:00:49 +03:00
|
|
|
// * aCancelTimer - if true, the timer is removed from the table.
|
|
|
|
TimerStatus LogTimer(JSContext* aCx, const JS::Value& aName,
|
|
|
|
DOMHighResTimeStamp aTimestamp, nsAString& aTimerLabel,
|
|
|
|
double* aTimerDuration, bool aCancelTimer);
|
2016-02-11 20:09:22 +03:00
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
// This method generates a ConsoleTimerEnd dictionary exposed as JS::Value, or
|
2018-05-15 14:00:49 +03:00
|
|
|
// a ConsoleTimerError dictionary if aTimerStatus is false. See LogTimer.
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aCx - this is the context that will root the returned value.
|
2018-05-15 14:00:49 +03:00
|
|
|
// * aTimerLabel - this label must be what LogTimer received as aTimerLabel.
|
|
|
|
// * aTimerDuration - this is what LogTimer received as aTimerDuration
|
|
|
|
// * aTimerStatus - the return value of LogTimer.
|
2020-03-25 03:51:50 +03:00
|
|
|
static JS::Value CreateLogOrEndTimerValue(JSContext* aCx,
|
|
|
|
const nsAString& aLabel,
|
|
|
|
double aDuration,
|
|
|
|
TimerStatus aStatus);
|
2014-02-28 03:39:00 +04:00
|
|
|
|
|
|
|
// The method populates a Sequence from an array of JS::Value.
|
2016-02-07 13:29:12 +03:00
|
|
|
bool ArgumentsToValueList(const Sequence<JS::Value>& aData,
|
|
|
|
Sequence<JS::Value>& aSequence) const;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2016-02-11 20:09:22 +03:00
|
|
|
// This method follows the same pattern as StartTimer: its runs on the owning
|
2018-05-22 12:34:41 +03:00
|
|
|
// thread and populate aCountLabel, used by CreateCounterOrResetCounterValue.
|
|
|
|
// Returns 3 possible values:
|
2017-04-20 14:52:41 +03:00
|
|
|
// * MAX_PAGE_COUNTERS in case of error that has to be reported;
|
|
|
|
// * 0 in case of a CX exception. The operation cannot continue;
|
|
|
|
// * the incremented counter value.
|
|
|
|
// Params:
|
2016-02-11 20:09:22 +03:00
|
|
|
// * aCx - the JSContext rooting aData.
|
|
|
|
// * aData - the arguments received by the console.count() method.
|
|
|
|
// * aCountLabel - the label that will be populated by this method.
|
2017-04-07 19:04:10 +03:00
|
|
|
uint32_t IncreaseCounter(JSContext* aCx, const Sequence<JS::Value>& aData,
|
2016-02-11 20:09:22 +03:00
|
|
|
nsAString& aCountLabel);
|
|
|
|
|
2018-05-22 12:34:41 +03:00
|
|
|
// This method follows the same pattern as StartTimer: its runs on the owning
|
|
|
|
// thread and populate aCountLabel, used by CreateCounterResetValue. Returns
|
|
|
|
// 3 possible values:
|
|
|
|
// * MAX_PAGE_COUNTERS in case of error that has to be reported;
|
|
|
|
// * 0 elsewhere. In case of a CX exception, aCountLabel will be an empty
|
|
|
|
// string.
|
|
|
|
// Params:
|
|
|
|
// * aCx - the JSContext rooting aData.
|
|
|
|
// * aData - the arguments received by the console.count() method.
|
|
|
|
// * aCountLabel - the label that will be populated by this method.
|
|
|
|
uint32_t ResetCounter(JSContext* aCx, const Sequence<JS::Value>& aData,
|
|
|
|
nsAString& aCountLabel);
|
|
|
|
|
2020-03-24 12:01:04 +03:00
|
|
|
static bool ShouldIncludeStackTrace(MethodName aMethodName);
|
2014-04-11 00:02:37 +04:00
|
|
|
|
2016-02-11 20:11:02 +03:00
|
|
|
void AssertIsOnOwningThread() const;
|
|
|
|
|
2016-05-03 11:19:39 +03:00
|
|
|
bool IsShuttingDown() const;
|
|
|
|
|
2017-12-20 16:35:34 +03:00
|
|
|
bool MonotonicTimer(JSContext* aCx, MethodName aMethodName,
|
|
|
|
const Sequence<JS::Value>& aData,
|
|
|
|
DOMHighResTimeStamp* aTimeStamp);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-04 21:19:44 +03:00
|
|
|
void MaybeExecuteDumpFunction(JSContext* aCx, const nsAString& aMethodName,
|
2018-02-22 10:50:02 +03:00
|
|
|
const Sequence<JS::Value>& aData,
|
|
|
|
nsIStackFrame* aStack);
|
2018-01-04 21:19:44 +03:00
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-29 15:25:15 +03:00
|
|
|
void MaybeExecuteDumpFunctionForTime(JSContext* aCx, MethodName aMethodName,
|
|
|
|
const nsAString& aMethodString,
|
|
|
|
uint64_t aMonotonicTimer,
|
|
|
|
const JS::Value& aData);
|
|
|
|
|
2019-03-19 07:33:32 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT
|
2018-01-04 21:19:44 +03:00
|
|
|
void ExecuteDumpFunction(const nsAString& aMessage);
|
|
|
|
|
2018-01-04 21:19:44 +03:00
|
|
|
bool IsEnabled(JSContext* aCx) const;
|
|
|
|
|
2018-01-04 21:19:44 +03:00
|
|
|
bool ShouldProceed(MethodName aName) const;
|
|
|
|
|
|
|
|
uint32_t WebIDLLogLevelToInteger(ConsoleLogLevel aLevel) const;
|
|
|
|
|
|
|
|
uint32_t InternalLogLevelToInteger(MethodName aName) const;
|
|
|
|
|
2020-03-25 03:47:15 +03:00
|
|
|
class ArgumentData {
|
|
|
|
public:
|
|
|
|
bool Initialize(JSContext* aCx, const Sequence<JS::Value>& aArguments);
|
|
|
|
void Trace(const TraceCallbacks& aCallbacks, void* aClosure);
|
|
|
|
bool PopulateArgumentsSequence(Sequence<JS::Value>& aSequence) const;
|
|
|
|
JSObject* Global() const { return mGlobal; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
void AssertIsOnOwningThread() const {
|
|
|
|
NS_ASSERT_OWNINGTHREAD(ArgumentData);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_OWNINGTHREAD;
|
|
|
|
JS::Heap<JSObject*> mGlobal;
|
|
|
|
nsTArray<JS::Heap<JS::Value>> mArguments;
|
|
|
|
};
|
|
|
|
|
2018-09-28 10:10:07 +03:00
|
|
|
// Owning/CC thread only
|
|
|
|
nsCOMPtr<nsIGlobalObject> mGlobal;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2016-02-11 20:09:22 +03:00
|
|
|
// Touched on the owner thread.
|
2014-02-28 03:39:00 +04:00
|
|
|
nsDataHashtable<nsStringHashKey, DOMHighResTimeStamp> mTimerRegistry;
|
2014-02-28 03:39:24 +04:00
|
|
|
nsDataHashtable<nsStringHashKey, uint32_t> mCounterRegistry;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
nsTArray<RefPtr<ConsoleCallData>> mCallDataStorage;
|
2020-03-25 03:47:15 +03:00
|
|
|
// These are references to the arguments we received in each call
|
|
|
|
// from the DOM bindings.
|
|
|
|
// Vector<T> supports non-memmovable types such as ArgumentData
|
|
|
|
// (without any need to jump through hoops like
|
|
|
|
// MOZ_DECLARE_RELOCATE_USING_MOVE_CONSTRUCTOR_FOR_TEMPLATE for nsTArray).
|
|
|
|
Vector<ArgumentData> mArgumentStorage;
|
2016-02-07 13:29:12 +03:00
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
RefPtr<AnyCallback> mConsoleEventNotifier;
|
|
|
|
|
2020-03-25 04:06:16 +03:00
|
|
|
RefPtr<MainThreadConsoleData> mMainThreadData;
|
|
|
|
// This is the stack for grouping relating to Console-thread events, when
|
|
|
|
// the Console thread is not the main thread.
|
2017-04-18 11:04:00 +03:00
|
|
|
nsTArray<nsString> mGroupStack;
|
|
|
|
|
2014-02-28 03:39:00 +04:00
|
|
|
uint64_t mOuterID;
|
|
|
|
uint64_t mInnerID;
|
2018-01-04 21:19:43 +03:00
|
|
|
|
|
|
|
// Set only by ConsoleInstance:
|
2018-01-04 21:19:43 +03:00
|
|
|
nsString mConsoleID;
|
2018-01-04 21:19:43 +03:00
|
|
|
nsString mPassedInnerID;
|
2018-01-04 21:19:44 +03:00
|
|
|
RefPtr<ConsoleInstanceDumpCallback> mDumpFunction;
|
|
|
|
bool mDumpToStdout;
|
2018-01-17 20:19:36 +03:00
|
|
|
nsString mPrefix;
|
2018-01-04 21:19:44 +03:00
|
|
|
bool mChromeInstance;
|
2018-01-04 21:19:44 +03:00
|
|
|
ConsoleLogLevel mMaxLogLevel;
|
2014-02-28 03:39:00 +04:00
|
|
|
|
2016-03-24 00:55:07 +03:00
|
|
|
enum { eUnknown, eInitialized, eShuttingDown } mStatus;
|
|
|
|
|
2017-12-20 16:35:34 +03:00
|
|
|
// This is used when Console is created and it's used only for JSM custom
|
|
|
|
// console instance.
|
|
|
|
mozilla::TimeStamp mCreationTimeStamp;
|
|
|
|
|
2014-02-28 03:39:00 +04:00
|
|
|
friend class ConsoleCallData;
|
2018-04-12 07:21:20 +03:00
|
|
|
friend class ConsoleCallDataWorkletRunnable;
|
2018-01-04 21:19:43 +03:00
|
|
|
friend class ConsoleInstance;
|
2018-04-12 07:21:20 +03:00
|
|
|
friend class ConsoleProfileWorkerRunnable;
|
|
|
|
friend class ConsoleProfileWorkletRunnable;
|
2015-01-06 18:45:00 +03:00
|
|
|
friend class ConsoleRunnable;
|
2018-04-12 07:21:20 +03:00
|
|
|
friend class ConsoleWorkerRunnable;
|
2018-09-18 12:29:15 +03:00
|
|
|
friend class ConsoleWorkletRunnable;
|
2020-03-25 04:06:16 +03:00
|
|
|
friend class MainThreadConsoleData;
|
2014-02-28 03:39:00 +04:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
2014-02-28 03:39:00 +04:00
|
|
|
|
|
|
|
#endif /* mozilla_dom_Console_h */
|