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.
5 #ifndef COMPONENTS_UKM_UKM_ENTRY_FILTER_H_
6 #define COMPONENTS_UKM_UKM_ENTRY_FILTER_H_
10 #include "base/containers/flat_set.h"
11 #include "services/metrics/public/mojom/ukm_interface.mojom-forward.h"
15 // Used in conjunction with UkmService. See UkmService::RegisterEntryFilter().
16 class UkmEntryFilter {
18 virtual ~UkmEntryFilter() = default;
20 // UkmService invokes this method on every reported entry. |entry| is mutable.
24 // * MAY modify the content of |entry->metrics| to remove unnecessary or
25 // prohibited metrics.
27 // Hashes of metrics that should be recorded as having been removed by the
28 // filter should be added to |removed_metric_hashes|.
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
36 // * MUST NOT modify the |source_id| nor |event_hash|.
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
43 // Returning false drops the entire entry.
44 virtual bool FilterEntry(mojom::UkmEntry* entry,
45 base::flat_set<uint64_t>* removed_metric_hashes) = 0;
47 // Invoked each time UkmService constructs a client report and stores all
48 // accumulated recordings in it. Effectively signals the start of a new
50 virtual void OnStoreRecordingsInReport() {}
55 #endif // COMPONENTS_UKM_UKM_ENTRY_FILTER_H_