| Index: base/debug/trace_event_impl.cc
|
| diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
|
| index f9ff510c575356369d8af2edd8c1ad07ad29807d..611852a41d86a619f7e3ca9e965bcda1878393a9 100644
|
| --- a/base/debug/trace_event_impl.cc
|
| +++ b/base/debug/trace_event_impl.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/command_line.h"
|
| #include "base/debug/leak_annotations.h"
|
| #include "base/debug/trace_event.h"
|
| +#include "base/debug/trace_event_synthetic_delay.h"
|
| #include "base/format_macros.h"
|
| #include "base/json/string_escape.h"
|
| #include "base/lazy_instance.h"
|
| @@ -1200,6 +1201,31 @@ void TraceLog::UpdateCategoryGroupEnabledFlags() {
|
| UpdateCategoryGroupEnabledFlag(i);
|
| }
|
|
|
| +void TraceLog::UpdateSyntheticDelaysFromCategoryFilter() {
|
| + ResetTraceEventSyntheticDelays();
|
| + const CategoryFilter::DelayValueList& delays =
|
| + category_filter_.GetSyntheticDelayValues();
|
| + CategoryFilter::DelayValueList::const_iterator ci;
|
| + for (ci = delays.begin(); ci != delays.end(); ++ci) {
|
| + TraceEventSyntheticDelay* delay =
|
| + TraceEventSyntheticDelay::Lookup(ci->first);
|
| + StringTokenizer tokens(ci->second, ";");
|
| + while (tokens.GetNext()) {
|
| + double target_duration;
|
| + if (StringToDouble(tokens.token(), &target_duration)) {
|
| + delay->SetTargetDuration(
|
| + TimeDelta::FromMicroseconds(target_duration * 1e6));
|
| + } else if (tokens.token() == "static") {
|
| + delay->SetMode(TraceEventSyntheticDelay::STATIC);
|
| + } else if (tokens.token() == "oneshot") {
|
| + delay->SetMode(TraceEventSyntheticDelay::ONE_SHOT);
|
| + } else if (tokens.token() == "alternating") {
|
| + delay->SetMode(TraceEventSyntheticDelay::ALTERNATING);
|
| + }
|
| + }
|
| + }
|
| +}
|
| +
|
| const unsigned char* TraceLog::GetCategoryGroupEnabledInternal(
|
| const char* category_group) {
|
| DCHECK(!strchr(category_group, '"')) <<
|
| @@ -1290,6 +1316,7 @@ void TraceLog::SetEnabled(const CategoryFilter& category_filter,
|
|
|
| category_filter_ = CategoryFilter(category_filter);
|
| UpdateCategoryGroupEnabledFlags();
|
| + UpdateSyntheticDelaysFromCategoryFilter();
|
|
|
| if ((options & ENABLE_SAMPLING) || (options & MONITOR_SAMPLING)) {
|
| sampling_thread_.reset(new TraceSamplingThread);
|
| @@ -2156,7 +2183,8 @@ CategoryFilter::CategoryFilter(const std::string& filter_string) {
|
| CategoryFilter::CategoryFilter(const CategoryFilter& cf)
|
| : included_(cf.included_),
|
| disabled_(cf.disabled_),
|
| - excluded_(cf.excluded_) {
|
| + excluded_(cf.excluded_),
|
| + delays_(cf.delays_) {
|
| }
|
|
|
| CategoryFilter::~CategoryFilter() {
|
| @@ -2169,6 +2197,7 @@ CategoryFilter& CategoryFilter::operator=(const CategoryFilter& rhs) {
|
| included_ = rhs.included_;
|
| disabled_ = rhs.disabled_;
|
| excluded_ = rhs.excluded_;
|
| + delays_ = rhs.delays_;
|
| return *this;
|
| }
|
|
|
| @@ -2181,8 +2210,13 @@ void CategoryFilter::Initialize(const std::string& filter_string) {
|
| // Ignore empty categories.
|
| if (category.empty())
|
| continue;
|
| - // Excluded categories start with '-'.
|
| - if (category.at(0) == '-') {
|
| + std::vector<std::string> parts;
|
| + SplitString(category, '=', &parts);
|
| + if (parts.size() == 2) {
|
| + // Synthetic delays are of the form 'delay=options'.
|
| + delays_.push_back(DelayValue(parts[0], parts[1]));
|
| + } else if (category.at(0) == '-') {
|
| + // Excluded categories start with '-'.
|
| // Remove '-' from category string.
|
| category = category.substr(1);
|
| excluded_.push_back(category);
|
| @@ -2209,11 +2243,25 @@ void CategoryFilter::WriteString(const StringList& values,
|
| }
|
| }
|
|
|
| +void CategoryFilter::WriteString(const DelayValueList& delays,
|
| + std::string* out) const {
|
| + bool prepend_comma = !out->empty();
|
| + int token_cnt = 0;
|
| + for (DelayValueList::const_iterator ci = delays.begin();
|
| + ci != delays.end(); ++ci) {
|
| + if (token_cnt > 0 || prepend_comma)
|
| + StringAppendF(out, ",");
|
| + StringAppendF(out, "%s=%s", ci->first.c_str(), ci->second.c_str());
|
| + ++token_cnt;
|
| + }
|
| +}
|
| +
|
| std::string CategoryFilter::ToString() const {
|
| std::string filter_string;
|
| WriteString(included_, &filter_string, true);
|
| WriteString(disabled_, &filter_string, true);
|
| WriteString(excluded_, &filter_string, false);
|
| + WriteString(delays_, &filter_string);
|
| return filter_string;
|
| }
|
|
|
| @@ -2277,6 +2325,11 @@ void CategoryFilter::Clear() {
|
| excluded_.clear();
|
| }
|
|
|
| +const CategoryFilter::DelayValueList&
|
| + CategoryFilter::GetSyntheticDelayValues() const {
|
| + return delays_;
|
| +}
|
| +
|
| } // namespace debug
|
| } // namespace base
|
|
|
|
|