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

Side by Side Diff: components/tracing/test/tracing_interface_simulator.h

Issue 2656303003: Test virtual interface [NOT FOR REVIEW] (Closed)
Patch Set: Created 3 years, 10 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
OLDNEW
(Empty)
1 // Copyright 2017 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 #ifndef COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_
6 #define COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_
7
8 namespace tracing {
9
10 class TracingInterface {
11 public:
12 virtual void AddEvent(const char *category, char type,
13 const char *name, bool copy_name) const = 0;
14 virtual const bool* GetPointerForCategory(const char *category) const = 0;
15 };
16
17 void InitTracingInterface();
18 const TracingInterface* GetTracingInterface();
19
20 void AddEventDirect(const char *category, char type,
21 const char *name, bool copy_name);
22 const bool* GetPointerForCategoryDirect(const char *category);
23
24
25 #define TRACE_EVENT_VIRTUAL_TEST(category, name) \
26 TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, cat_enabled_ptr_ ## __LINE__)
27
28 #define TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, enabled_ptr) \
29 static const bool* enabled_ptr = nullptr; \
Primiano Tucci (use gerrit) 2017/01/27 21:26:10 see comments below
30 if (!enabled_ptr) \
31 enabled_ptr = GetTracingInterface()->GetPointerForCategory(category); \
32 if (*enabled_ptr) \
33 GetTracingInterface()->AddEvent(category, 'X', name, false);
34
35
36 #define TRACE_EVENT_DIRECT_TEST(category, name) \
37 TRACE_EVENT_DIRECT_TEST_BODY(category, name, cat_enabled_ptr_ ## __LINE__)
38
39 #define TRACE_EVENT_DIRECT_TEST_BODY(category, name, enabled_ptr) \
40 static const bool* enabled_ptr = nullptr; \
Primiano Tucci (use gerrit) 2017/01/27 21:26:10 see INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO here. i
41 if (!enabled_ptr) \
Primiano Tucci (use gerrit) 2017/01/27 21:26:10 ditto. see INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENA
42 enabled_ptr = GetPointerForCategoryDirect(category); \
43 if (*enabled_ptr) \
44 AddEventDirect(category, 'X', name, false);
45
46 } // namespace tracing
47
48 #endif // COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698