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

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 11823016: Trace category groups and category filter. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/debug/trace_event_impl.h" 5 #include "base/debug/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/leak_annotations.h" 10 #include "base/debug/leak_annotations.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_enabled); 386 uintptr_t category_ptr = reinterpret_cast<uintptr_t>(category_enabled);
387 DCHECK(category_ptr >= category_begin && 387 DCHECK(category_ptr >= category_begin &&
388 category_ptr < reinterpret_cast<uintptr_t>(g_category_enabled + 388 category_ptr < reinterpret_cast<uintptr_t>(g_category_enabled +
389 TRACE_EVENT_MAX_CATEGORIES)) << 389 TRACE_EVENT_MAX_CATEGORIES)) <<
390 "out of bounds category pointer"; 390 "out of bounds category pointer";
391 uintptr_t category_index = 391 uintptr_t category_index =
392 (category_ptr - category_begin) / sizeof(g_category_enabled[0]); 392 (category_ptr - category_begin) / sizeof(g_category_enabled[0]);
393 return g_categories[category_index]; 393 return g_categories[category_index];
394 } 394 }
395 395
396 static bool IsTagInCategory(const char* tag_expr, const char* category) {
397 CStringTokenizer tokens(category, category + strlen(category), ",");
398 while (tokens.GetNext()) {
399 if (MatchPattern(tokens.token().c_str(), tag_expr))
400 return true;
401 }
402 return false;
403 }
404
405 // A tag composite category name would be something like: "webkit,input"
406 static bool IsTagCompositeCategory(const char* category) {
407 return strchr(category, ',');
408 }
409
396 static void EnableMatchingCategory(int category_index, 410 static void EnableMatchingCategory(int category_index,
nduca 2013/01/09 09:43:33 I'd like to update the naming convention throughou
397 const std::vector<std::string>& patterns, 411 const std::vector<std::string>& patterns,
398 unsigned char matched_value, 412 unsigned char matched_value,
399 unsigned char unmatched_value) { 413 unsigned char unmatched_value) {
400 std::vector<std::string>::const_iterator ci = patterns.begin(); 414 std::vector<std::string>::const_iterator ci = patterns.begin();
401 bool is_match = false; 415 bool is_match = false;
416 bool has_matching_tag = false;
417 bool is_tag_composite_category =
418 IsTagCompositeCategory(g_categories[category_index]);
402 for (; ci != patterns.end(); ++ci) { 419 for (; ci != patterns.end(); ++ci) {
403 is_match = MatchPattern(g_categories[category_index], ci->c_str()); 420 is_match = MatchPattern(g_categories[category_index], ci->c_str());
404 if (is_match) 421 has_matching_tag = is_tag_composite_category &&
nduca 2013/01/09 09:43:33 cant you make this just a change to MatchPattern?
422 IsTagInCategory(ci->c_str(),
423 g_categories[category_index]);
424
425 if (is_match || has_matching_tag)
405 break; 426 break;
406 } 427 }
407 g_category_enabled[category_index] = is_match ? 428 g_category_enabled[category_index] = is_match || has_matching_tag ?
408 matched_value : unmatched_value; 429 matched_value : unmatched_value;
409 } 430 }
410 431
411 // Enable/disable each category based on the category filters in |patterns|. 432 // Enable/disable each category based on the category filters in |patterns|.
412 // If the category name matches one of the patterns, its enabled status is set 433 // If the category name matches one of the patterns, its enabled status is set
413 // to |matched_value|. Otherwise its enabled status is set to |unmatched_value|. 434 // to |matched_value|. Otherwise its enabled status is set to |unmatched_value|.
414 static void EnableMatchingCategories(const std::vector<std::string>& patterns, 435 static void EnableMatchingCategories(const std::vector<std::string>& patterns,
415 unsigned char matched_value, 436 unsigned char matched_value,
416 unsigned char unmatched_value) { 437 unsigned char unmatched_value) {
417 for (int i = 0; i < g_category_index; i++) 438 for (int i = 0; i < g_category_index; i++)
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 unsigned long long pid = static_cast<unsigned long long>(process_id_); 801 unsigned long long pid = static_cast<unsigned long long>(process_id_);
781 process_id_hash_ = (offset_basis ^ pid) * fnv_prime; 802 process_id_hash_ = (offset_basis ^ pid) * fnv_prime;
782 } 803 }
783 804
784 void TraceLog::SetTimeOffset(TimeDelta offset) { 805 void TraceLog::SetTimeOffset(TimeDelta offset) {
785 time_offset_ = offset; 806 time_offset_ = offset;
786 } 807 }
787 808
788 } // namespace debug 809 } // namespace debug
789 } // namespace base 810 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698