2015-08-18 01:13:20 +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: */
|
|
|
|
/* 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_PerformanceObserver_h__
|
|
|
|
#define mozilla_dom_PerformanceObserver_h__
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsISupports.h"
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h"
|
2015-08-18 01:13:20 +03:00
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsTArray.h"
|
|
|
|
#include "nsWrapperCache.h"
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
class nsPIDOMWindowInner;
|
2015-08-18 01:13:20 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
class ErrorResult;
|
|
|
|
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class GlobalObject;
|
2016-06-09 20:04:42 +03:00
|
|
|
class Performance;
|
2015-08-18 01:13:20 +03:00
|
|
|
class PerformanceEntry;
|
|
|
|
class PerformanceObserverCallback;
|
|
|
|
struct PerformanceObserverInit;
|
|
|
|
class WorkerPrivate;
|
|
|
|
|
|
|
|
class PerformanceObserver final : public nsISupports, public nsWrapperCache {
|
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(PerformanceObserver)
|
|
|
|
|
|
|
|
static already_AddRefed<PerformanceObserver> Constructor(
|
|
|
|
const GlobalObject& aGlobal, PerformanceObserverCallback& aCb,
|
|
|
|
ErrorResult& aRv);
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
PerformanceObserver(nsPIDOMWindowInner* aOwner,
|
2015-08-18 01:13:20 +03:00
|
|
|
PerformanceObserverCallback& aCb);
|
|
|
|
|
2018-01-31 10:24:08 +03:00
|
|
|
PerformanceObserver(WorkerPrivate* aWorkerPrivate,
|
2015-08-18 01:13:20 +03:00
|
|
|
PerformanceObserverCallback& aCb);
|
|
|
|
|
|
|
|
virtual JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
nsISupports* GetParentObject() const { return mOwner; }
|
|
|
|
|
2019-04-12 19:29:48 +03:00
|
|
|
void Observe(const PerformanceObserverInit& aOptions, ErrorResult& aRv);
|
|
|
|
static void GetSupportedEntryTypes(const GlobalObject& aGlobal,
|
|
|
|
JS::MutableHandle<JSObject*> aObject);
|
2015-08-18 01:13:20 +03:00
|
|
|
|
|
|
|
void Disconnect();
|
|
|
|
|
2018-02-08 19:43:25 +03:00
|
|
|
void TakeRecords(nsTArray<RefPtr<PerformanceEntry>>& aRetval);
|
|
|
|
|
2019-03-19 08:24:39 +03:00
|
|
|
MOZ_CAN_RUN_SCRIPT void Notify();
|
2015-09-03 00:41:00 +03:00
|
|
|
void QueueEntry(PerformanceEntry* aEntry);
|
2015-08-18 01:13:20 +03:00
|
|
|
|
2019-04-12 19:29:48 +03:00
|
|
|
bool ObservesTypeOfEntry(PerformanceEntry* aEntry);
|
|
|
|
|
2015-08-18 01:13:20 +03:00
|
|
|
private:
|
2019-04-12 19:29:48 +03:00
|
|
|
void ReportUnsupportedTypesErrorToConsole(bool aIsMainThread,
|
|
|
|
const char* msgId,
|
|
|
|
const nsString& aInvalidTypes);
|
2015-08-18 01:13:20 +03:00
|
|
|
~PerformanceObserver();
|
|
|
|
|
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<PerformanceObserverCallback> mCallback;
|
2016-06-09 20:04:42 +03:00
|
|
|
RefPtr<Performance> mPerformance;
|
2015-08-18 01:13:20 +03:00
|
|
|
nsTArray<nsString> mEntryTypes;
|
2019-04-12 19:29:48 +03:00
|
|
|
nsTArray<PerformanceObserverInit> mOptions;
|
|
|
|
enum {
|
|
|
|
ObserverTypeUndefined,
|
|
|
|
ObserverTypeSingle,
|
|
|
|
ObserverTypeMultiple,
|
|
|
|
} mObserverType;
|
|
|
|
/*
|
|
|
|
* This is also known as registered, in the spec.
|
|
|
|
*/
|
2015-08-21 00:33:54 +03:00
|
|
|
bool mConnected;
|
2015-10-18 08:24:48 +03:00
|
|
|
nsTArray<RefPtr<PerformanceEntry>> mQueuedEntries;
|
2015-08-18 01:13:20 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif
|