| Index: base/debug/trace_event_impl.cc
|
| diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
|
| index cbcf54b81c6aac08b08d5f71fb6796f6869b84de..d5a88edd3e5f0c5db26e25774c62a52bbab41176 100644
|
| --- a/base/debug/trace_event_impl.cc
|
| +++ b/base/debug/trace_event_impl.cc
|
| @@ -348,10 +348,28 @@ TraceLog* TraceLog::GetInstance() {
|
| return Singleton<TraceLog, StaticMemorySingletonTraits<TraceLog> >::get();
|
| }
|
|
|
| +// static
|
| +TraceLog::TraceMode TraceLog::TraceModeFromString(const std::string& str) {
|
| + if (str == "until_full")
|
| + return UNTIL_FULL;
|
| + return UNTIL_FULL;
|
| +}
|
| +
|
| +// static
|
| +const std::string TraceLog::StringFromTraceMode(TraceMode mode) {
|
| + switch(mode) {
|
| + case UNTIL_FULL:
|
| + return "until_full";
|
| + default:
|
| + return "";
|
| + }
|
| +}
|
| +
|
| TraceLog::TraceLog()
|
| : enable_count_(0),
|
| dispatching_to_observer_list_(false),
|
| - watch_category_(NULL) {
|
| + watch_category_(NULL),
|
| + trace_mode_(UNTIL_FULL) {
|
| // Trace is enabled or disabled on one thread while other threads are
|
| // accessing the enabled flag. We don't care whether edge-case events are
|
| // traced or not, so we allow races on the enabled flag to keep the trace
|
| @@ -478,10 +496,15 @@ void TraceLog::GetKnownCategories(std::vector<std::string>* categories) {
|
| }
|
|
|
| void TraceLog::SetEnabled(const std::vector<std::string>& included_categories,
|
| - const std::vector<std::string>& excluded_categories) {
|
| + const std::vector<std::string>& excluded_categories,
|
| + TraceMode mode) {
|
| AutoLock lock(lock_);
|
|
|
| if (enable_count_++ > 0) {
|
| + if (mode != trace_mode_) {
|
| + DLOG(ERROR) << "Attemting to re-enable tracing with a different mode.";
|
| + }
|
| +
|
| // Tracing is already enabled, so just merge in enabled categories.
|
| // We only expand the set of enabled categories upon nested SetEnable().
|
| if (!included_categories_.empty() && !included_categories.empty()) {
|
| @@ -497,6 +520,7 @@ void TraceLog::SetEnabled(const std::vector<std::string>& included_categories,
|
| }
|
| return;
|
| }
|
| + trace_mode_ = mode;
|
|
|
| if (dispatching_to_observer_list_) {
|
| DLOG(ERROR) <<
|
| @@ -520,7 +544,7 @@ void TraceLog::SetEnabled(const std::vector<std::string>& included_categories,
|
| EnableMatchingCategories(excluded_categories_, 0, CATEGORY_ENABLED);
|
| }
|
|
|
| -void TraceLog::SetEnabled(const std::string& categories) {
|
| +void TraceLog::SetEnabled(const std::string& categories, TraceMode mode) {
|
| std::vector<std::string> included, excluded;
|
| // Tokenize list of categories, delimited by ','.
|
| StringTokenizer tokens(categories, ",");
|
| @@ -538,7 +562,7 @@ void TraceLog::SetEnabled(const std::string& categories) {
|
| else
|
| excluded.push_back(category);
|
| }
|
| - SetEnabled(included, excluded);
|
| + SetEnabled(included, excluded, mode);
|
| }
|
|
|
| void TraceLog::GetEnabledTraceCategories(
|
| @@ -577,9 +601,9 @@ void TraceLog::SetDisabled() {
|
| AddThreadNameMetadataEvents();
|
| }
|
|
|
| -void TraceLog::SetEnabled(bool enabled) {
|
| +void TraceLog::SetEnabled(bool enabled, TraceMode mode) {
|
| if (enabled)
|
| - SetEnabled(std::vector<std::string>(), std::vector<std::string>());
|
| + SetEnabled(std::vector<std::string>(), std::vector<std::string>(), mode);
|
| else
|
| SetDisabled();
|
| }
|
|
|