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
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
2018-11-14 19:02:34 +00:00
|
|
|
#include "nsIObserver.h"
|
|
|
|
#include "nsWeakReference.h"
|
2018-11-14 19:02:32 +00:00
|
|
|
#include "nsWrapperCache.h"
|
2018-11-14 19:02:33 +00:00
|
|
|
#include "nsTArray.h"
|
2018-11-14 19:02:32 +00:00
|
|
|
|
|
|
|
class nsPIDOMWindowInner;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2018-11-14 19:02:33 +00:00
|
|
|
class Report;
|
|
|
|
class ReportingObserverCallback;
|
|
|
|
struct ReportingObserverOptions;
|
|
|
|
|
2018-11-14 19:02:34 +00:00
|
|
|
class ReportingObserver final : public nsIObserver,
|
2018-11-14 19:02:32 +00:00
|
|
|
public nsWrapperCache,
|
2018-11-14 19:02:34 +00:00
|
|
|
public nsSupportsWeakReference {
|
2018-11-14 19:02:32 +00:00
|
|
|
public:
|
|
|
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
2018-11-14 19:02:34 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(ReportingObserver,
|
|
|
|
nsIObserver)
|
|
|
|
NS_DECL_NSIOBSERVER
|
2018-11-14 19:02:32 +00:00
|
|
|
|
|
|
|
static already_AddRefed<ReportingObserver> Constructor(
|
|
|
|
const GlobalObject& aGlobal, ReportingObserverCallback& aCallback,
|
|
|
|
const ReportingObserverOptions& aOptions, ErrorResult& aRv);
|
|
|
|
|
|
|
|
ReportingObserver(nsPIDOMWindowInner* aWindow,
|
|
|
|
ReportingObserverCallback& aCallback,
|
|
|
|
const nsTArray<nsString>& aTypes, bool aBuffered);
|
|
|
|
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
|
|
|
nsPIDOMWindowInner* GetParentObject() const { return mWindow; }
|
|
|
|
|
|
|
|
void Observe();
|
|
|
|
|
|
|
|
void Disconnect();
|
|
|
|
|
|
|
|
void TakeRecords(nsTArray<RefPtr<Report>>& aRecords);
|
|
|
|
|
2018-11-14 19:02:33 +00:00
|
|
|
void MaybeReport(Report* aReport);
|
|
|
|
|
|
|
|
void MaybeNotify();
|
|
|
|
|
2018-11-14 19:02:32 +00:00
|
|
|
private:
|
|
|
|
~ReportingObserver();
|
|
|
|
|
2018-11-14 19:02:34 +00:00
|
|
|
void Shutdown();
|
|
|
|
|
2018-11-14 19:02:33 +00:00
|
|
|
nsTArray<RefPtr<Report>> mReports;
|
|
|
|
|
2018-11-14 19:02:32 +00:00
|
|
|
nsCOMPtr<nsPIDOMWindowInner> mWindow;
|
|
|
|
RefPtr<ReportingObserverCallback> mCallback;
|
|
|
|
nsTArray<nsString> mTypes;
|
|
|
|
bool mBuffered;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_dom_ReportingObserver_h
|