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

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

Issue 971673004: Enable trace with multiple categories with any one category ON (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | base/trace_event/trace_event_unittest.cc » ('j') | 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/trace_event/trace_event_impl.h" 5 #include "base/trace_event/trace_event_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 2472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 if (IsCategoryEnabled(category_group_token.c_str())) { 2483 if (IsCategoryEnabled(category_group_token.c_str())) {
2484 return true; 2484 return true;
2485 } 2485 }
2486 if (!MatchPattern(category_group_token.c_str(), 2486 if (!MatchPattern(category_group_token.c_str(),
2487 TRACE_DISABLED_BY_DEFAULT("*"))) 2487 TRACE_DISABLED_BY_DEFAULT("*")))
2488 had_enabled_by_default = true; 2488 had_enabled_by_default = true;
2489 } 2489 }
2490 // Do a second pass to check for explicitly disabled categories 2490 // Do a second pass to check for explicitly disabled categories
2491 // (those explicitly enabled have priority due to first pass). 2491 // (those explicitly enabled have priority due to first pass).
2492 category_group_tokens.Reset(); 2492 category_group_tokens.Reset();
2493 bool had_category_group_enabled = true;
dsinclair 2015/03/03 14:54:05 This flag is backwards to what we're checking and
2493 while (category_group_tokens.GetNext()) { 2494 while (category_group_tokens.GetNext()) {
2494 std::string category_group_token = category_group_tokens.token(); 2495 std::string category_group_token = category_group_tokens.token();
2495 for (StringList::const_iterator ci = excluded_.begin(); 2496 for (StringList::const_iterator ci = excluded_.begin();
2496 ci != excluded_.end(); ++ci) { 2497 ci != excluded_.end(); ++ci) {
2497 if (MatchPattern(category_group_token.c_str(), ci->c_str())) 2498 if (MatchPattern(category_group_token.c_str(), ci->c_str())) {
2498 return false; 2499 // Current token of category_group_name is present in excluded_ list.
dsinclair 2015/03/03 14:54:05 Nit: remove space between excluded_ and list.
2500 // Flag the exclusion and proceed further to check if any of the
2501 // remaining categories of category_group_name is not present in the
2502 // excluded_ list.
2503 had_category_group_enabled = false;
2504 break;
2505 } else {
dsinclair 2015/03/03 14:54:05 Since the if () has a break, you don't need else h
2506 // One of the category of category_group_name is not present in
2507 // excluded_ list. So, it has to be included_ list. Enable the
2508 // category_group_name for recording.
2509 had_category_group_enabled = true;
2510 }
2499 } 2511 }
2512 // One of the categories present in category_group_name is not present in
2513 // excluded_ list. Implies this category_group_name group can be enabled
2514 // for recording, since one of its groups is enabled for recording.
2515 if (had_category_group_enabled)
2516 break;
2500 } 2517 }
2518 // None of the categories part of category_group_name are enabled.
2519 // Don't allow recording of this category_group_name.
2520 if (!had_category_group_enabled)
2521 return false;
2522
2501 // If the category group is not excluded, and there are no included patterns 2523 // If the category group is not excluded, and there are no included patterns
2502 // we consider this category group enabled, as long as it had categories 2524 // we consider this category group enabled, as long as it had categories
2503 // other than disabled-by-default. 2525 // other than disabled-by-default.
2504 return included_.empty() && had_enabled_by_default; 2526 return included_.empty() && had_enabled_by_default;
2505 } 2527 }
2506 2528
2507 bool CategoryFilter::IsCategoryEnabled(const char* category_name) const { 2529 bool CategoryFilter::IsCategoryEnabled(const char* category_name) const {
2508 StringList::const_iterator ci; 2530 StringList::const_iterator ci;
2509 2531
2510 // Check the disabled- filters and the disabled-* wildcard first so that a 2532 // Check the disabled- filters and the disabled-* wildcard first so that a
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
2588 } 2610 }
2589 2611
2590 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 2612 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
2591 if (*category_group_enabled_) { 2613 if (*category_group_enabled_) {
2592 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, 2614 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_,
2593 name_, event_handle_); 2615 name_, event_handle_);
2594 } 2616 }
2595 } 2617 }
2596 2618
2597 } // namespace trace_event_internal 2619 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698