2018-11-14 19:02:32 +00: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_ReportingObserver_h
|
|
|
|
#define mozilla_dom_ReportingObserver_h
|
|
|
|
|
2020-11-23 16:12:12 +00:00
|
|
|
#include "js/TypeDecls.h"
|
2020-07-22 15:12:10 +00:00
|
|
|
#include "mozilla/AlreadyAddRefed.h"
|
|
|
|
#include "mozilla/Assertions.h"
|
2018-11-14 19:02:32 +00:00
|
|
|
#include "mozilla/Attributes.h"
|
2020-07-22 15:12:10 +00:00
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2018-11-14 19:02:32 +00:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2020-07-22 15:12:10 +00:00
|
|
|
#include "nsISupports.h"
|
|
|
|
#include "nsStringFwd.h"
|
2018-11-14 19:02:33 +00:00
|
|
|
#include "nsTArray.h"
|
2020-07-22 15:12:10 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2018-11-14 19:02:32 +00:00
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
class nsIGlobalObject;
|
2018-11-14 19:02:32 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
2020-07-22 15:12:10 +00:00
|
|
|
class ErrorResult;
|
2018-11-14 19:02:32 +00:00
|
|
|
|
2020-07-22 15:12:10 +00:00
|
|
|
namespace dom {
|
|
|
|
class GlobalObject;
|
2018-11-14 19:02:33 +00:00
|
|
|
class Report;
|
|
|
|
class ReportingObserverCallback;
|
|
|
|
struct ReportingObserverOptions;
|
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
class ReportingObserver final : public nsWrapperCache {
|
2018-11-14 19:02:32 +00:00
|
|
|
public:
|
2020-04-18 12:25:57 +00:00
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ReportingObserver)
|
2022-09-07 11:22:51 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(ReportingObserver)
|
2018-11-14 19:02:32 +00:00
|
|
|
|
|
|
|
static already_AddRefed<ReportingObserver> Constructor(
|
|
|
|
const GlobalObject& aGlobal, ReportingObserverCallback& aCallback,
|
|
|
|
const ReportingObserverOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
ReportingObserver(nsIGlobalObject* aGlobal,
|
2018-11-14 19:02:32 +00:00
|
|
|
ReportingObserverCallback& aCallback,
|
|
|
|
const nsTArray<nsString>& aTypes, bool aBuffered);
|
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
nsIGlobalObject* GetParentObject() const { return mGlobal; }
|
2018-11-14 19:02:32 +00:00
|
|
|
|
|
|
|
void Observe();
|
|
|
|
|
|
|
|
void Disconnect();
|
|
|
|
|
|
|
|
void TakeRecords(nsTArray<RefPtr<Report>>& aRecords);
|
|
|
|
|
2018-11-14 19:02:33 +00:00
|
|
|
void MaybeReport(Report* aReport);
|
|
|
|
|
2019-03-19 04:33:54 +00:00
|
|
|
MOZ_CAN_RUN_SCRIPT void MaybeNotify();
|
2018-11-14 19:02:33 +00:00
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
void ForgetReports();
|
|
|
|
|
2018-11-14 19:02:32 +00:00
|
|
|
private:
|
|
|
|
~ReportingObserver();
|
|
|
|
|
2018-11-14 19:02:33 +00:00
|
|
|
nsTArray<RefPtr<Report>> mReports;
|
|
|
|
|
2020-04-18 12:25:57 +00:00
|
|
|
nsCOMPtr<nsIGlobalObject> mGlobal;
|
2018-11-14 19:02:32 +00:00
|
|
|
RefPtr<ReportingObserverCallback> mCallback;
|
|
|
|
nsTArray<nsString> mTypes;
|
|
|
|
bool mBuffered;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_ReportingObserver_h
|