Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: base/trace_event/trace_config.cc

Issue 2624583002: Remove redundant c_str() calls. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 bool had_enabled_by_default = false; 314 bool had_enabled_by_default = false;
315 DCHECK(category_group_name); 315 DCHECK(category_group_name);
316 std::string category_group_name_str = category_group_name; 316 std::string category_group_name_str = category_group_name;
317 StringTokenizer category_group_tokens(category_group_name_str, ","); 317 StringTokenizer category_group_tokens(category_group_name_str, ",");
318 while (category_group_tokens.GetNext()) { 318 while (category_group_tokens.GetNext()) {
319 std::string category_group_token = category_group_tokens.token(); 319 std::string category_group_token = category_group_tokens.token();
320 // Don't allow empty tokens, nor tokens with leading or trailing space. 320 // Don't allow empty tokens, nor tokens with leading or trailing space.
321 DCHECK(!TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( 321 DCHECK(!TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
322 category_group_token)) 322 category_group_token))
323 << "Disallowed category string"; 323 << "Disallowed category string";
324 if (IsCategoryEnabled(category_group_token.c_str())) 324 if (IsCategoryEnabled(category_group_token))
325 return true; 325 return true;
326 326
327 if (!MatchPattern(category_group_token, TRACE_DISABLED_BY_DEFAULT("*"))) 327 if (!MatchPattern(category_group_token, TRACE_DISABLED_BY_DEFAULT("*")))
328 had_enabled_by_default = true; 328 had_enabled_by_default = true;
329 } 329 }
330 // Do a second pass to check for explicitly disabled categories 330 // Do a second pass to check for explicitly disabled categories
331 // (those explicitly enabled have priority due to first pass). 331 // (those explicitly enabled have priority due to first pass).
332 category_group_tokens.Reset(); 332 category_group_tokens.Reset();
333 bool category_group_disabled = false; 333 bool category_group_disabled = false;
334 while (category_group_tokens.GetNext()) { 334 while (category_group_tokens.GetNext()) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
848 int token_cnt = 0; 848 int token_cnt = 0;
849 for (const std::string& category : delays) { 849 for (const std::string& category : delays) {
850 if (token_cnt > 0 || prepend_comma) 850 if (token_cnt > 0 || prepend_comma)
851 StringAppendF(out, ","); 851 StringAppendF(out, ",");
852 StringAppendF(out, "%s%s)", kSyntheticDelayCategoryFilterPrefix, 852 StringAppendF(out, "%s%s)", kSyntheticDelayCategoryFilterPrefix,
853 category.c_str()); 853 category.c_str());
854 ++token_cnt; 854 ++token_cnt;
855 } 855 }
856 } 856 }
857 857
858 bool TraceConfig::IsCategoryEnabled(const char* category_name) const { 858 bool TraceConfig::IsCategoryEnabled(StringPiece category_name) const {
Andrey Kraynov 2017/01/09 21:50:45 Later |category_name| will be used as an argument
Primiano Tucci (use gerrit) 2017/01/09 23:52:37 Please don't change this signature. This is used b
Andrey Kraynov 2017/01/10 06:24:53 My point was that in case of the old signature of
Primiano Tucci (use gerrit) 2017/01/10 10:48:43 ahh sorry you are right, it would actually happen
859 // Check the disabled- filters and the disabled-* wildcard first so that a 859 // Check the disabled- filters and the disabled-* wildcard first so that a
860 // "*" filter does not include the disabled. 860 // "*" filter does not include the disabled.
861 for (const std::string& category : disabled_categories_) { 861 for (const std::string& category : disabled_categories_) {
862 if (MatchPattern(category_name, category)) 862 if (MatchPattern(category_name, category))
863 return true; 863 return true;
864 } 864 }
865 865
866 if (MatchPattern(category_name, TRACE_DISABLED_BY_DEFAULT("*"))) 866 if (MatchPattern(category_name, TRACE_DISABLED_BY_DEFAULT("*")))
867 return false; 867 return false;
868 868
869 for (const std::string& category : included_categories_) { 869 for (const std::string& category : included_categories_) {
870 if (MatchPattern(category_name, category)) 870 if (MatchPattern(category_name, category))
871 return true; 871 return true;
872 } 872 }
873 873
874 return false; 874 return false;
875 } 875 }
876 876
877 bool TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace( 877 bool TraceConfig::IsEmptyOrContainsLeadingOrTrailingWhitespace(
878 StringPiece str) { 878 StringPiece str) {
879 return str.empty() || str.front() == ' ' || str.back() == ' '; 879 return str.empty() || str.front() == ' ' || str.back() == ' ';
880 } 880 }
881 881
882 bool TraceConfig::HasIncludedPatterns() const { 882 bool TraceConfig::HasIncludedPatterns() const {
883 return !included_categories_.empty(); 883 return !included_categories_.empty();
884 } 884 }
885 885
886 } // namespace trace_event 886 } // namespace trace_event
887 } // namespace base 887 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698