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"
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
{
27 NS_DECL_NSICLEARDATACALLBACK
28 NS_DECL_NSIURLCLASSIFIERFEATURECALLBACK
30 explicit ClearDataCallback(ClearDataMozPromise::Private
* aPromise
,
31 const OriginAttributes
& aOriginAttributes
,
32 const nsACString
& aHost
, PRTime aBounceTime
);
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