ukm_entry_filter.h 2.0 KB

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