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

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

Issue 2549103003: tracing: split trace event filter classes out of TraceLog (Closed)
Patch Set: Add BASE_EXPORT Created 4 years 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
(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
OLDNEW
« no previous file with comments | « base/trace_event/trace_event_filter_test_utils.h ('k') | base/trace_event/trace_event_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698