event_name_filter.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // Copyright 2016 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 BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_
  5. #define BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_
  6. #include <memory>
  7. #include <string>
  8. #include <unordered_set>
  9. #include "base/base_export.h"
  10. #include "base/trace_event/trace_event_filter.h"
  11. namespace base {
  12. namespace trace_event {
  13. class TraceEvent;
  14. // Filters trace events by checking the full name against an allowlist.
  15. // The current implementation is quite simple and dumb and just uses a
  16. // hashtable which requires char* to std::string conversion. It could be smarter
  17. // and use a bloom filter trie. However, today this is used too rarely to
  18. // justify that cost.
  19. class BASE_EXPORT EventNameFilter : public TraceEventFilter {
  20. public:
  21. using EventNamesAllowlist = std::unordered_set<std::string>;
  22. static const char kName[];
  23. EventNameFilter(std::unique_ptr<EventNamesAllowlist>);
  24. EventNameFilter(const EventNameFilter&) = delete;
  25. EventNameFilter& operator=(const EventNameFilter&) = delete;
  26. ~EventNameFilter() override;
  27. // TraceEventFilter implementation.
  28. bool FilterTraceEvent(const TraceEvent&) const override;
  29. private:
  30. std::unique_ptr<const EventNamesAllowlist> event_names_allowlist_;
  31. };
  32. } // namespace trace_event
  33. } // namespace base
  34. #endif // BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_