Home | History | Annotate | Download | only in trace_event
      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 
      5 #ifndef BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_
      6 #define BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_
      7 
      8 #include <memory>
      9 #include <string>
     10 #include <unordered_set>
     11 
     12 #include "base/base_export.h"
     13 #include "base/macros.h"
     14 #include "base/trace_event/trace_event_filter.h"
     15 
     16 namespace base {
     17 namespace trace_event {
     18 
     19 class TraceEvent;
     20 
     21 // Filters trace events by checking the full name against a whitelist.
     22 // The current implementation is quite simple and dumb and just uses a
     23 // hashtable which requires char* to std::string conversion. It could be smarter
     24 // and use a bloom filter trie. However, today this is used too rarely to
     25 // justify that cost.
     26 class BASE_EXPORT EventNameFilter : public TraceEventFilter {
     27  public:
     28   using EventNamesWhitelist = std::unordered_set<std::string>;
     29   static const char kName[];
     30 
     31   EventNameFilter(std::unique_ptr<EventNamesWhitelist>);
     32   ~EventNameFilter() override;
     33 
     34   // TraceEventFilter implementation.
     35   bool FilterTraceEvent(const TraceEvent&) const override;
     36 
     37  private:
     38   std::unique_ptr<const EventNamesWhitelist> event_names_whitelist_;
     39 
     40   DISALLOW_COPY_AND_ASSIGN(EventNameFilter);
     41 };
     42 
     43 }  // namespace trace_event
     44 }  // namespace base
     45 
     46 #endif  // BASE_TRACE_EVENT_EVENT_NAME_FILTER_H_
     47