| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/trace_event/trace_config.h" | 5 #include "base/trace_event/trace_config.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/strings/pattern.h" | 9 #include "base/strings/pattern.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 if (dict->GetList(kExcludedCategoriesParam, &category_list)) | 286 if (dict->GetList(kExcludedCategoriesParam, &category_list)) |
| 287 SetCategoriesFromExcludedList(*category_list); | 287 SetCategoriesFromExcludedList(*category_list); |
| 288 if (dict->GetList(kSyntheticDelaysParam, &category_list)) | 288 if (dict->GetList(kSyntheticDelaysParam, &category_list)) |
| 289 SetSyntheticDelaysFromList(*category_list); | 289 SetSyntheticDelaysFromList(*category_list); |
| 290 } | 290 } |
| 291 | 291 |
| 292 void TraceConfig::InitializeFromStrings( | 292 void TraceConfig::InitializeFromStrings( |
| 293 const std::string& category_filter_string, | 293 const std::string& category_filter_string, |
| 294 const std::string& trace_options_string) { | 294 const std::string& trace_options_string) { |
| 295 if (!category_filter_string.empty()) { | 295 if (!category_filter_string.empty()) { |
| 296 std::vector<std::string> split = base::SplitString( | 296 std::vector<std::string> split; |
| 297 category_filter_string, ",", base::TRIM_WHITESPACE, | |
| 298 base::SPLIT_WANT_ALL); | |
| 299 std::vector<std::string>::iterator iter; | 297 std::vector<std::string>::iterator iter; |
| 298 base::SplitString(category_filter_string, ',', &split); |
| 300 for (iter = split.begin(); iter != split.end(); ++iter) { | 299 for (iter = split.begin(); iter != split.end(); ++iter) { |
| 301 std::string category = *iter; | 300 std::string category = *iter; |
| 302 // Ignore empty categories. | 301 // Ignore empty categories. |
| 303 if (category.empty()) | 302 if (category.empty()) |
| 304 continue; | 303 continue; |
| 305 // Synthetic delays are of the form 'DELAY(delay;option;option;...)'. | 304 // Synthetic delays are of the form 'DELAY(delay;option;option;...)'. |
| 306 if (category.find(kSyntheticDelayCategoryFilterPrefix) == 0 && | 305 if (category.find(kSyntheticDelayCategoryFilterPrefix) == 0 && |
| 307 category.at(category.size() - 1) == ')') { | 306 category.at(category.size() - 1) == ')') { |
| 308 category = category.substr( | 307 category = category.substr( |
| 309 strlen(kSyntheticDelayCategoryFilterPrefix), | 308 strlen(kSyntheticDelayCategoryFilterPrefix), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 325 included_categories_.push_back(category); | 324 included_categories_.push_back(category); |
| 326 } | 325 } |
| 327 } | 326 } |
| 328 } | 327 } |
| 329 | 328 |
| 330 record_mode_ = RECORD_UNTIL_FULL; | 329 record_mode_ = RECORD_UNTIL_FULL; |
| 331 enable_sampling_ = false; | 330 enable_sampling_ = false; |
| 332 enable_systrace_ = false; | 331 enable_systrace_ = false; |
| 333 enable_argument_filter_ = false; | 332 enable_argument_filter_ = false; |
| 334 if(!trace_options_string.empty()) { | 333 if(!trace_options_string.empty()) { |
| 335 std::vector<std::string> split = base::SplitString( | 334 std::vector<std::string> split; |
| 336 trace_options_string, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 337 std::vector<std::string>::iterator iter; | 335 std::vector<std::string>::iterator iter; |
| 336 base::SplitString(trace_options_string, ',', &split); |
| 338 for (iter = split.begin(); iter != split.end(); ++iter) { | 337 for (iter = split.begin(); iter != split.end(); ++iter) { |
| 339 if (*iter == kRecordUntilFull) { | 338 if (*iter == kRecordUntilFull) { |
| 340 record_mode_ = RECORD_UNTIL_FULL; | 339 record_mode_ = RECORD_UNTIL_FULL; |
| 341 } else if (*iter == kRecordContinuously) { | 340 } else if (*iter == kRecordContinuously) { |
| 342 record_mode_ = RECORD_CONTINUOUSLY; | 341 record_mode_ = RECORD_CONTINUOUSLY; |
| 343 } else if (*iter == kTraceToConsole) { | 342 } else if (*iter == kTraceToConsole) { |
| 344 record_mode_ = ECHO_TO_CONSOLE; | 343 record_mode_ = ECHO_TO_CONSOLE; |
| 345 } else if (*iter == kRecordAsMuchAsPossible) { | 344 } else if (*iter == kRecordAsMuchAsPossible) { |
| 346 record_mode_ = RECORD_AS_MUCH_AS_POSSIBLE; | 345 record_mode_ = RECORD_AS_MUCH_AS_POSSIBLE; |
| 347 } else if (*iter == kEnableSampling) { | 346 } else if (*iter == kEnableSampling) { |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 str.at(0) == ' ' || | 539 str.at(0) == ' ' || |
| 541 str.at(str.length() - 1) == ' '; | 540 str.at(str.length() - 1) == ' '; |
| 542 } | 541 } |
| 543 | 542 |
| 544 bool TraceConfig::HasIncludedPatterns() const { | 543 bool TraceConfig::HasIncludedPatterns() const { |
| 545 return !included_categories_.empty(); | 544 return !included_categories_.empty(); |
| 546 } | 545 } |
| 547 | 546 |
| 548 } // namespace trace_event | 547 } // namespace trace_event |
| 549 } // namespace base | 548 } // namespace base |
| OLD | NEW |