OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/trace_event/trace_event_filter_test_utils.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 |
| 9 namespace base { |
| 10 namespace trace_event { |
| 11 |
| 12 namespace { |
| 13 TestEventFilter::HitsCounter* g_hits_counter; |
| 14 } // namespace; |
| 15 |
| 16 // static |
| 17 const char TestEventFilter::kName[] = "testing_predicate"; |
| 18 bool TestEventFilter::filter_return_value_; |
| 19 |
| 20 // static |
| 21 std::unique_ptr<TraceEventFilter> TestEventFilter::Factory( |
| 22 const std::string& predicate_name) { |
| 23 std::unique_ptr<TraceEventFilter> res; |
| 24 if (predicate_name == kName) |
| 25 res.reset(new TestEventFilter()); |
| 26 return res; |
| 27 } |
| 28 |
| 29 TestEventFilter::TestEventFilter() {} |
| 30 TestEventFilter::~TestEventFilter() {} |
| 31 |
| 32 bool TestEventFilter::FilterTraceEvent(const TraceEvent& trace_event) const { |
| 33 if (g_hits_counter) |
| 34 g_hits_counter->filter_trace_event_hit_count++; |
| 35 return filter_return_value_; |
| 36 } |
| 37 |
| 38 void TestEventFilter::EndEvent(const char* category_name, |
| 39 const char* name) const { |
| 40 if (g_hits_counter) |
| 41 g_hits_counter->end_event_hit_count++; |
| 42 } |
| 43 |
| 44 TestEventFilter::HitsCounter::HitsCounter() { |
| 45 Reset(); |
| 46 DCHECK(!g_hits_counter); |
| 47 g_hits_counter = this; |
| 48 } |
| 49 |
| 50 TestEventFilter::HitsCounter::~HitsCounter() { |
| 51 DCHECK(g_hits_counter); |
| 52 g_hits_counter = nullptr; |
| 53 } |
| 54 |
| 55 void TestEventFilter::HitsCounter::Reset() { |
| 56 filter_trace_event_hit_count = 0; |
| 57 end_event_hit_count = 0; |
| 58 } |
| 59 |
| 60 } // namespace trace_event |
| 61 } // namespace base |
OLD | NEW |