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..f47fa7f1ad1ca7d59cd294ae63de2225822e2a1c 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; |
// 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_; |
}; |
class TraceSamplingThread; |
@@ -422,6 +423,95 @@ struct BASE_EXPORT TraceOptions { |
bool enable_systrace; |
}; |
+class BASE_EXPORT TraceConfig { |
+ public: |
+ typedef std::vector<std::string> StringList; |
+ |
+ 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 dictionary formatted as a JSON string, containing both |
+ // category filters and trace options. |
+ explicit TraceConfig(const std::string& config_string); |
+ |
+ explicit TraceConfig(const TraceConfig& tc); |
+ |
+ ~TraceConfig(); |
+ |
+ TraceConfig& operator=(const TraceConfig& rhs); |
+ |
+ // Return a list of the synthetic delays specified in this category filter. |
+ const StringList& GetSyntheticDelayValues() const; |
+ |
+ // Convert TraceConfig to the dict representation of the TraceConfig. |
+ void ToDict(base::DictionaryValue& dict) const; |
+ |
+ // 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 |
+ // trace config. |
+ bool IsCategoryGroupEnabled(const char* category_group) const; |
+ |
+ // Merges config with the current TraceConfig |
+ void Merge(const TraceConfig& config); |
+ |
+ void Clear(); |
+ |
+ private: |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidLegacyString); |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidLegacyString); |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, ConstructDefaultTraceConfig); |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromValidString); |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, TraceConfigFromInvalidString); |
+ FRIEND_TEST_ALL_PREFIXES(TraceConfigTest, |
+ IsEmptyOrContainsLeadingOrTrailingWhitespace); |
+ friend class CategoryFilter; |
+ |
+ void Initialize(const std::string& config_string); |
+ |
+ // The default trace config, used when none is provided. |
+ // Allows all categories through, except if they end in the suffix 'Debug' or |
+ // 'Test'. |
+ void InitializeDefault(); |
+ |
+ 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_; |
+ |
+ StringList included_categories_; |
+ StringList disabled_categories_; |
+ StringList excluded_categories_; |
+ StringList synthetic_delays_; |
+}; |
+ |
struct BASE_EXPORT TraceLogStatus { |
TraceLogStatus(); |
~TraceLogStatus(); |