ReportDeliver.h (1568B)
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/. */ 6 7 #ifndef mozilla_dom_ReportDeliver_h 8 #define mozilla_dom_ReportDeliver_h 9 10 #include "nsIObserver.h" 11 #include "nsITimer.h" 12 #include "nsString.h" 13 #include "nsTArray.h" 14 15 // XXX Avoid including this here by moving function bodies to the cpp file 16 #include "nsIPrincipal.h" 17 18 class nsIPrincipal; 19 class nsPIDOMWindowInner; 20 21 namespace mozilla::dom { 22 23 class ReportBody; 24 25 class ReportDeliver final : public nsIObserver, public nsINamed { 26 public: 27 NS_DECL_ISUPPORTS 28 NS_DECL_NSIOBSERVER 29 NS_DECL_NSINAMED 30 31 struct ReportData { 32 nsString mType; 33 nsString mGroupName; 34 nsString mURL; 35 nsCString mEndpointURL; 36 nsString mUserAgent; 37 TimeStamp mCreationTime; 38 nsCString mReportBodyJSON; 39 nsCOMPtr<nsIPrincipal> mPrincipal; 40 uint32_t mFailures; 41 }; 42 43 static void Record(nsPIDOMWindowInner* aWindow, const nsAString& aType, 44 const nsAString& aGroupName, const nsAString& aURL, 45 ReportBody* aBody); 46 47 static void Fetch(const ReportData& aReportData); 48 49 void AppendReportData(const ReportData& aReportData); 50 51 void Notify(); 52 53 private: 54 ReportDeliver(); 55 ~ReportDeliver(); 56 57 nsTArray<ReportData> mReportQueue; 58 }; 59 60 } // namespace mozilla::dom 61 62 #endif // mozilla_dom_ReportDeliver_h