Chromium Code Reviews| Index: base/trace_event/trace_event_impl.h |
| diff --git a/base/trace_event/trace_event_impl.h b/base/trace_event/trace_event_impl.h |
| index 50d33ca7da9129a62f1a4518381bb6bce4898033..6ee94f6167a5e03af112bcafb8031f3bcb478eea 100644 |
| --- a/base/trace_event/trace_event_impl.h |
| +++ b/base/trace_event/trace_event_impl.h |
| @@ -24,6 +24,7 @@ |
| #include "base/synchronization/lock.h" |
| #include "base/threading/thread.h" |
| #include "base/threading/thread_local.h" |
| +#include "base/values.h" |
| // Older style trace macros with explicit id and extra data |
| // Only these macros result in publishing data to ETW as currently implemented. |
| @@ -53,6 +54,8 @@ class MessageLoop; |
| namespace trace_event { |
| +class TraceConfig; |
| + |
| // For any argument of type TRACE_VALUE_TYPE_CONVERTABLE the provided |
| // class must implement this interface. |
| class BASE_EXPORT ConvertableToTraceFormat |
| @@ -342,6 +345,7 @@ class BASE_EXPORT CategoryFilter { |
| private: |
| FRIEND_TEST_ALL_PREFIXES(TraceEventTestFixture, CategoryFilter); |
| + friend class TraceConfig; |
|
dsinclair
2015/05/08 17:44:50
Can we just merge this straight into TraceConfig w
Zhen Wang
2015/05/13 00:01:11
Many places are using CategoryFilter. Do you mean
|
| // Returns true if category is enable according to this filter. |
| bool IsCategoryEnabled(const char* category_name) const; |
| @@ -356,10 +360,7 @@ class BASE_EXPORT CategoryFilter { |
| void WriteString(const StringList& delays, std::string* out) const; |
| bool HasIncludedPatterns() const; |
| - StringList included_; |
| - StringList disabled_; |
| - StringList excluded_; |
| - StringList delays_; |
| + scoped_ptr<TraceConfig> config_; |
|
nednguyen
2015/05/11 17:59:28
Why not just make this a value instead of scoped_p
Zhen Wang
2015/05/13 00:01:11
There will be extra copies in the constructors, ri
nednguyen
2015/05/13 18:16:31
Chatted offline. It doesn't matter much & the comp
Zhen Wang
2015/05/13 20:59:16
Done.
|
| }; |
| class TraceSamplingThread; |
| @@ -422,6 +423,95 @@ struct BASE_EXPORT TraceOptions { |
| bool enable_systrace; |
| }; |
| +class BASE_EXPORT TraceConfig { |
| + public: |
| + typedef std::vector<std::string> StringList; |
|
dsinclair
2015/05/08 17:44:49
Is this worth typedef'ing?
Zhen Wang
2015/05/13 00:01:11
I was following the style used in CategoryFilter,
|
| + |
| + // The default trace config, used when none is provided. |
| + // Allows all categories through, except if they end in the suffix 'Debug' or |
|
dsinclair
2015/05/08 17:44:49
Is this true? We don't want to allow disable-by-de
Zhen Wang
2015/05/13 00:01:11
This is converted from kDefaultCategoryFilterStrin
|
| + // 'Test'. |
| + static const char kDefaultTraceConfigString[]; |
|
dsinclair
2015/05/08 17:44:49
Does this need to be in the public header? Can it
Zhen Wang
2015/05/13 00:01:11
This is removed now as we will use InitializeDefau
|
| + |
| + TraceConfig(); |
| + |
| + // Create TraceConfig object from CategoryFilter and TraceOptions. |
| + TraceConfig(const CategoryFilter& cf, const TraceOptions& options); |
| + |
| + // Create TraceConfig object from category filter and trace options strings. |
| + TraceConfig(const std::string& category_filter_string, |
| + const std::string& trace_options_string); |
| + |
| + // |config_string| is a JSON formated string, containing both category filters |
|
dsinclair
2015/05/08 17:44:49
Can you add a similar comment to the above here:
Zhen Wang
2015/05/13 00:01:11
Done.
|
| + // and trace options. |
| + TraceConfig(const std::string& config_string); |
|
dsinclair
2015/05/08 17:44:50
nit: explicit
Zhen Wang
2015/05/13 00:01:11
Done.
|
| + |
| + TraceConfig(const TraceConfig& tc); |
|
dsinclair
2015/05/08 17:44:50
nit: explicit
Zhen Wang
2015/05/13 00:01:10
Done.
|
| + |
| + ~TraceConfig(); |
| + |
| + TraceConfig& operator=(const TraceConfig& rhs); |
|
dsinclair
2015/05/08 17:44:49
Do we use copy and assign for this?
Zhen Wang
2015/05/13 00:01:11
Not now. But it may be used later when updating th
dsinclair
2015/05/21 13:42:07
In that case, let's add the DISALLOW for now and w
Zhen Wang
2015/05/22 23:38:04
COPY and ASSIGN are needed to implement CategoryFi
dsinclair
2015/05/25 13:36:02
I'm confused, above you said they aren't used? So,
|
| + |
| + // Return a list of the synthetic delays specified in this category filter. |
| + const StringList& GetSyntheticDelayValues() const; |
| + |
| + // Convert TraceConfig to CategoryFilter. |
| + void ToCategoryFilter(CategoryFilter& cf) const; |
|
dsinclair
2015/05/08 17:44:49
Are these ToXXX methods only for tests? I don't se
Zhen Wang
2015/05/13 00:01:11
Removed now.
|
| + |
| + // Convert TraceConfig to TraceOptions. |
| + void ToTraceOptions(TraceOptions& options) const; |
| + |
| + // Convert TraceConfig to the dict representation of the TraceConfig. |
| + void ToDict(base::DictionaryValue& dict) const; |
|
nednguyen
2015/05/11 17:59:28
Do we actually need this API?
Zhen Wang
2015/05/13 00:01:11
I think this can be used by slow report.
dsinclair
2015/05/21 13:42:07
Can we determine if it is or isn't? I'd prefer to
Zhen Wang
2015/05/22 23:38:04
Fadi has confirmed that this is not needed in the
|
| + |
| + // Writes the string representation of the TraceConfig. The string is JSON |
| + // formatted. |
| + std::string ToString() const; |
| + |
| + // Write the string representation of the CategoryFilter part. |
| + std::string ToCategoryFilterString() const; |
| + |
| + // Write the string representation of the TraceOptions part. |
| + std::string ToTraceOptionsString() const; |
| + |
| + // Returns true if at least one category in the list is enabled by this |
|
dsinclair
2015/05/08 17:44:49
How does this interact with disabled categories? I
Zhen Wang
2015/05/13 00:01:11
Yes, it will be considered enabled. This comes fro
|
| + // trace config. |
| + bool IsCategoryGroupEnabled(const char* category_group) const; |
| + |
| + // Merges config with the current TraceConfig |
| + void Merge(const TraceConfig& config); |
|
dsinclair
2015/05/08 17:44:49
Will this go away when CategoryFilter is removed?
Zhen Wang
2015/05/13 00:01:11
This will live on. It is used by TraceLog. See htt
|
| + |
| + void Clear(); |
|
dsinclair
2015/05/08 17:44:50
Is this needed? Or just for tests? If for tests, d
Zhen Wang
2015/05/13 00:01:11
Clear() will be used by TraceLog. See https://code
|
| + |
| + private: |
| + FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromAndToString); |
| + FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfig); |
| + friend class CategoryFilter; |
| + |
| + void Initialize(const std::string& config_string); |
| + void SetCategoriesFromList(StringList& categories, |
| + const base::ListValue& list); |
| + void AddCategoryToDict(base::DictionaryValue& dict, |
| + const char* param, |
| + const StringList& categories) const; |
| + |
| + // Returns true if category is enable according to this trace config. |
| + bool IsCategoryEnabled(const char* category_name) const; |
| + |
| + static bool IsEmptyOrContainsLeadingOrTrailingWhitespace( |
| + const std::string& str); |
| + |
| + bool HasIncludedPatterns() const; |
| + |
| + TraceRecordMode record_mode_; |
| + bool enable_sampling_; |
| + bool enable_systrace_; |
|
dsinclair
2015/05/08 17:44:50
bool enable_sampling_ : 1;
bool enable_systrace_ :
Zhen Wang
2015/05/13 00:01:11
Those two members will be used in TraceConfig::Ini
dsinclair
2015/05/21 13:42:07
Sure, but we can also easily change the initialize
Zhen Wang
2015/05/22 23:38:04
Done.
|
| + |
| + StringList included_categories_; |
| + StringList disabled_categories_; |
| + StringList excluded_categories_; |
| + StringList synthetic_delays_; |
| +}; |
|
dsinclair
2015/05/08 17:44:50
Should this have a DISALLOW_COPY_AND_ASSIGN?
Zhen Wang
2015/05/13 00:01:10
Existing CategoryFilter has copy constructor and o
dsinclair
2015/05/21 13:42:07
If it isn't needed let, let's put in the DISALLOW.
Zhen Wang
2015/05/22 23:38:04
COPY and ASSIGN are needed to implement CategoryFi
|
| + |
| struct BASE_EXPORT TraceLogStatus { |
| TraceLogStatus(); |
| ~TraceLogStatus(); |