Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 all_category_groups_disabled = false; | |
| 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. |
| 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 all_category_groups_disabled = true; | |
|
dsinclair
2015/03/06 04:04:45
This isn't really all_, it's one category group di
r.kasibhatla
2015/03/06 04:19:32
Done.
| |
| 2504 break; | |
| 2505 } | |
| 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 all_category_groups_disabled = false; | |
| 2499 } | 2510 } |
| 2511 // One of the categories present in category_group_name is not present in | |
| 2512 // excluded_ list. Implies this category_group_name group can be enabled | |
| 2513 // for recording, since one of its groups is enabled for recording. | |
| 2514 if (!all_category_groups_disabled) | |
| 2515 break; | |
| 2500 } | 2516 } |
| 2501 // If the category group is not excluded, and there are no included patterns | 2517 // 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 | 2518 // we consider this category group enabled, as long as it had categories |
| 2503 // other than disabled-by-default. | 2519 // other than disabled-by-default. |
| 2504 return included_.empty() && had_enabled_by_default; | 2520 return !all_category_groups_disabled && |
| 2521 (included_.empty() && had_enabled_by_default); | |
|
dsinclair
2015/03/06 04:04:45
nit: Don't need the brackets.
r.kasibhatla
2015/03/06 04:19:32
Done.
| |
| 2505 } | 2522 } |
| 2506 | 2523 |
| 2507 bool CategoryFilter::IsCategoryEnabled(const char* category_name) const { | 2524 bool CategoryFilter::IsCategoryEnabled(const char* category_name) const { |
| 2508 StringList::const_iterator ci; | 2525 StringList::const_iterator ci; |
| 2509 | 2526 |
| 2510 // Check the disabled- filters and the disabled-* wildcard first so that a | 2527 // Check the disabled- filters and the disabled-* wildcard first so that a |
| 2511 // "*" filter does not include the disabled. | 2528 // "*" filter does not include the disabled. |
| 2512 for (ci = disabled_.begin(); ci != disabled_.end(); ++ci) { | 2529 for (ci = disabled_.begin(); ci != disabled_.end(); ++ci) { |
| 2513 if (MatchPattern(category_name, ci->c_str())) | 2530 if (MatchPattern(category_name, ci->c_str())) |
| 2514 return true; | 2531 return true; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2588 } | 2605 } |
| 2589 | 2606 |
| 2590 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2607 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 2591 if (*category_group_enabled_) { | 2608 if (*category_group_enabled_) { |
| 2592 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2609 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
| 2593 name_, event_handle_); | 2610 name_, event_handle_); |
| 2594 } | 2611 } |
| 2595 } | 2612 } |
| 2596 | 2613 |
| 2597 } // namespace trace_event_internal | 2614 } // namespace trace_event_internal |
| OLD | NEW |