Backed out changeset 379bb5e39311 (bug 1850606) to unblock deployment of new bugbug...
[gecko.git] / dom / reporting / ReportingObserver.h
blobb89ee33adf9c46b3cc966d733b7faabac3294054
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_ReportingObserver_h
8 #define mozilla_dom_ReportingObserver_h
10 #include "js/TypeDecls.h"
11 #include "mozilla/AlreadyAddRefed.h"
12 #include "mozilla/Assertions.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/RefPtr.h"
15 #include "nsCOMPtr.h"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsISupports.h"
18 #include "nsStringFwd.h"
19 #include "nsTArray.h"
20 #include "nsWrapperCache.h"
22 class nsIGlobalObject;
24 namespace mozilla {
25 class ErrorResult;
27 namespace dom {
28 class GlobalObject;
29 class Report;
30 class ReportingObserverCallback;
31 struct ReportingObserverOptions;
33 class ReportingObserver final : public nsWrapperCache {
34 public:
35 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ReportingObserver)
36 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(ReportingObserver)
38 static already_AddRefed<ReportingObserver> Constructor(
39 const GlobalObject& aGlobal, ReportingObserverCallback& aCallback,
40 const ReportingObserverOptions& aOptions, ErrorResult& aRv);
42 ReportingObserver(nsIGlobalObject* aGlobal,
43 ReportingObserverCallback& aCallback,
44 const nsTArray<nsString>& aTypes, bool aBuffered);
46 JSObject* WrapObject(JSContext* aCx,
47 JS::Handle<JSObject*> aGivenProto) override;
49 nsIGlobalObject* GetParentObject() const { return mGlobal; }
51 void Observe();
53 void Disconnect();
55 void TakeRecords(nsTArray<RefPtr<Report>>& aRecords);
57 void MaybeReport(Report* aReport);
59 MOZ_CAN_RUN_SCRIPT void MaybeNotify();
61 void ForgetReports();
63 private:
64 ~ReportingObserver();
66 nsTArray<RefPtr<Report>> mReports;
68 nsCOMPtr<nsIGlobalObject> mGlobal;
69 RefPtr<ReportingObserverCallback> mCallback;
70 nsTArray<nsString> mTypes;
71 bool mBuffered;
74 } // namespace dom
75 } // namespace mozilla
77 #endif // mozilla_dom_ReportingObserver_h