Upload upstream chromium 114.0.5735.31
[platform/framework/web/chromium-efl.git] / components / ukm / ukm_entry_filter.h
1 // Copyright 2020 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 COMPONENTS_UKM_UKM_ENTRY_FILTER_H_
6 #define COMPONENTS_UKM_UKM_ENTRY_FILTER_H_
7
8 #include <cstdint>
9
10 #include "base/containers/flat_set.h"
11 #include "services/metrics/public/mojom/ukm_interface.mojom-forward.h"
12
13 namespace ukm {
14
15 // Used in conjunction with UkmService. See UkmService::RegisterEntryFilter().
16 class UkmEntryFilter {
17  public:
18   virtual ~UkmEntryFilter() = default;
19
20   // UkmService invokes this method on every reported entry. |entry| is mutable.
21   //
22   // An implementation:
23   //
24   //   * MAY modify the content of |entry->metrics| to remove unnecessary or
25   //     prohibited metrics.
26   //
27   //     Hashes of metrics that should be recorded as having been removed by the
28   //     filter should be added to |removed_metric_hashes|.
29   //
30   //     A filter may exclude a removed metric from |removed_metric_hashes| to
31   //     prevent a removed metric from being counted in the aggregate tables.
32   //     This is intentional and intends to allow removal of privacy sensitive
33   //     metrics without the those metrics being partially exposed via aggregate
34   //     tables.
35   //
36   //   * MUST NOT modify the |source_id| nor |event_hash|.
37   //
38   // There could be more than one UkmEntryFilter. The probihition on
39   // modifications to |source| and |event_hash|, and adding new metrics is due
40   // to the possibility that the new values not being seen by previously invoked
41   // UkmEntryFilters.
42   //
43   // Returning false drops the entire entry.
44   virtual bool FilterEntry(mojom::UkmEntry* entry,
45                            base::flat_set<uint64_t>* removed_metric_hashes) = 0;
46
47   // Invoked each time UkmService constructs a client report and stores all
48   // accumulated recordings in it. Effectively signals the start of a new
49   // report.
50   virtual void OnStoreRecordingsInReport() {}
51 };
52
53 }  // namespace ukm
54
55 #endif  // COMPONENTS_UKM_UKM_ENTRY_FILTER_H_