xref: /aosp_15_r20/external/cronet/net/reporting/reporting_browsing_data_remover.h (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2017 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_REPORTING_REPORTING_BROWSING_DATA_REMOVER_H_
6 #define NET_REPORTING_REPORTING_BROWSING_DATA_REMOVER_H_
7 
8 #include "base/functional/callback.h"
9 #include "net/base/net_export.h"
10 #include "url/origin.h"
11 
12 namespace net {
13 
14 class ReportingCache;
15 
16 // Clears browsing data (reports and clients) from the Reporting system.
17 class NET_EXPORT ReportingBrowsingDataRemover {
18  public:
19   enum DataType {
20     DATA_TYPE_REPORTS = 0x1,
21     DATA_TYPE_CLIENTS = 0x2,
22   };
23 
24   ReportingBrowsingDataRemover() = delete;
25   ReportingBrowsingDataRemover(const ReportingBrowsingDataRemover&) = delete;
26   ReportingBrowsingDataRemover& operator=(const ReportingBrowsingDataRemover&) =
27       delete;
28 
29   // Removes browsing data from the Reporting system. |data_type_mask| specifies
30   // which types of data to remove: reports queued by browser features and/or
31   // clients (endpoints configured by origins). |origin_filter| specifies which
32   // origins' data to remove.
33   //
34   // Note: Currently this does not clear the endpoint backoff data in
35   // ReportingEndpointManager because that's not persisted to disk. If it's ever
36   // persisted, it will need to be cleared as well.
37   static void RemoveBrowsingData(
38       ReportingCache* cache,
39       uint64_t data_type_mask,
40       const base::RepeatingCallback<bool(const url::Origin&)>& origin_filter);
41 
42   // Like RemoveBrowsingData except removes data for all origins without a
43   // filter. Allows slight optimization over passing an always-true filter to
44   // RemoveBrowsingData.
45   static void RemoveAllBrowsingData(ReportingCache* cache,
46                                     uint64_t data_type_mask);
47 };
48 
49 }  // namespace net
50 
51 #endif  // NET_REPORTING_REPORTING_BROWSING_DATA_REMOVER_H_
52