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"
16 #include "nsCycleCollectionParticipant.h"
17 #include "nsISupports.h"
18 #include "nsStringFwd.h"
20 #include "nsWrapperCache.h"
22 class nsIGlobalObject
;
30 class ReportingObserverCallback
;
31 struct ReportingObserverOptions
;
33 class ReportingObserver final
: public nsWrapperCache
{
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
; }
55 void TakeRecords(nsTArray
<RefPtr
<Report
>>& aRecords
);
57 void MaybeReport(Report
* aReport
);
59 MOZ_CAN_RUN_SCRIPT
void MaybeNotify();
66 nsTArray
<RefPtr
<Report
>> mReports
;
68 nsCOMPtr
<nsIGlobalObject
> mGlobal
;
69 RefPtr
<ReportingObserverCallback
> mCallback
;
70 nsTArray
<nsString
> mTypes
;
75 } // namespace mozilla
77 #endif // mozilla_dom_ReportingObserver_h