Bug 1943650 - Command-line --help output misformatted after --dbus-service. r=emilio
[gecko.git] / toolkit / components / antitracking / bouncetrackingprotection / ClearDataCallback.h
blobd0a2c1cb44deab97f4d31cb3c5f7d4fb470e1c54
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef mozilla_ClearDataCallback_h__
5 #define mozilla_ClearDataCallback_h__
7 #include "BounceTrackingMapEntry.h"
8 #include "mozilla/MozPromise.h"
9 #include "mozilla/glean/bindings/GleanMetric.h"
10 #include "nsIClearDataService.h"
11 #include "nsIURIClassifier.h"
13 namespace mozilla {
15 // Pending clear operations are stored as ClearDataMozPromise, one per host.
16 using ClearDataMozPromise =
17 MozPromise<RefPtr<BounceTrackingPurgeEntry>, uint32_t, true>;
19 extern LazyLogModule gBounceTrackingProtectionLog;
21 // Helper for clear data callbacks used for purge bounce trackers.
22 // Wraps nsIClearDataCallback in MozPromise.
23 class ClearDataCallback final : public nsIClearDataCallback,
24 public nsIUrlClassifierFeatureCallback {
25 public:
26 NS_DECL_ISUPPORTS
27 NS_DECL_NSICLEARDATACALLBACK
28 NS_DECL_NSIURLCLASSIFIERFEATURECALLBACK
30 explicit ClearDataCallback(ClearDataMozPromise::Private* aPromise,
31 const OriginAttributes& aOriginAttributes,
32 const nsACString& aHost, PRTime aBounceTime);
34 private:
35 virtual ~ClearDataCallback();
37 // Entry containing the site host which was cleared and the timestamp of when
38 // the bounce occurred that led to the tracker being purged.
39 RefPtr<BounceTrackingPurgeEntry> mEntry;
41 // Promise which is resolved or rejected when the clear operation completes.
42 RefPtr<ClearDataMozPromise::Private> mPromise;
44 // Clear duration telemetry
45 void RecordClearDurationTelemetry();
46 glean::TimerId mClearDurationTimer;
48 // Purge count telemetry
49 void RecordPurgeCountTelemetry(bool aFailed);
51 // URL Classifier telemetry
52 void RecordURLClassifierTelemetry();
54 // Event telemetry for purges.
55 void RecordPurgeEventTelemetry(bool aSuccess);
58 } // namespace mozilla
60 #endif