blob: df8c3a5b2a70d3e7a5d4762fa79fa20035905f18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef BASE_TRACE_EVENT_TRACE_CONFIG_CATEGORY_FILTER_H_
#define BASE_TRACE_EVENT_TRACE_CONFIG_CATEGORY_FILTER_H_
#include <string>
#include <vector>
#include "base/base_export.h"
#include "base/strings/string_piece.h"
#include "base/values.h"
namespace base {
namespace trace_event {
// Configuration of categories enabled and disabled in TraceConfig.
class BASE_EXPORT TraceConfigCategoryFilter {
public:
using StringList = std::vector<std::string>;
TraceConfigCategoryFilter();
TraceConfigCategoryFilter(const TraceConfigCategoryFilter& other);
~TraceConfigCategoryFilter();
TraceConfigCategoryFilter& operator=(const TraceConfigCategoryFilter& rhs);
// Initializes from category filter string. See TraceConfig constructor for
// description of how to write category filter string.
void InitializeFromString(const StringPiece& category_filter_string);
// Initializes TraceConfigCategoryFilter object from the config dictionary.
void InitializeFromConfigDict(const DictionaryValue& dict);
// Merges this with category filter config.
void Merge(const TraceConfigCategoryFilter& config);
void Clear();
// Returns true if at least one category in the list is enabled by this
// trace config. This is used to determine if the category filters are
// enabled in the TRACE_* macros.
bool IsCategoryGroupEnabled(const char* category_group_name) const;
// Returns true if the category is enabled according to this trace config.
// This tells whether a category is enabled from the TraceConfig's
// perspective. Please refer to IsCategoryGroupEnabled() to determine if a
// category is enabled from the tracing runtime's perspective.
bool IsCategoryEnabled(const char* category_name) const;
void ToDict(DictionaryValue* dict) const;
std::string ToFilterString() const;
// Returns true if category name is a valid string.
static bool IsCategoryNameAllowed(StringPiece str);
const StringList& included_categories() const { return included_categories_; }
const StringList& excluded_categories() const { return excluded_categories_; }
const StringList& synthetic_delays() const { return synthetic_delays_; }
private:
void SetCategoriesFromIncludedList(const ListValue& included_list);
void SetCategoriesFromExcludedList(const ListValue& excluded_list);
void SetSyntheticDelaysFromList(const ListValue& list);
void AddCategoriesToDict(const StringList& categories,
const char* param,
DictionaryValue* dict) const;
void WriteCategoryFilterString(const StringList& values,
std::string* out,
bool included) const;
void WriteCategoryFilterString(const StringList& delays,
std::string* out) const;
StringList included_categories_;
StringList disabled_categories_;
StringList excluded_categories_;
StringList synthetic_delays_;
};
} // namespace trace_event
} // namespace base
#endif // BASE_TRACE_EVENT_TRACE_CONFIG_CATEGORY_FILTER_H_
|