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

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

Issue 2656303003: Test virtual interface [NOT FOR REVIEW] (Closed)
Patch Set: results 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 #include "base/trace_event/trace_event.h"
9
10 namespace tracing {
11
12 class TracingInterface {
13 public:
14 virtual base::trace_event::TraceEventHandle AddEvent(
15 const char *category, const unsigned char* cat_enabled,
16 char type, const char *name, bool copy_name) const = 0;
17 virtual const unsigned char*
18 GetCategoryPointer(const char *category) const = 0;
19 };
20
21 void InitTracingInterface();
22 const TracingInterface* GetTracingInterface();
23
24 base::trace_event::TraceEventHandle AddEventDirect(
25 const char *category, const unsigned char* cat_enabled,
26 char type, const char *name, bool copy_name);
27 const unsigned char* GetCategoryPointerDirect(const char *category);
28
29
30 #define TRACE_EVENT_VIRTUAL_TEST(category, name) \
31 TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, \
32 cat_enabled_ptr_ ## __LINE__, cat_enabled_atomic_ ## __LINE__)
33
34 #define TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, enabled_ptr, enabled_atomi c) \
35 static base::subtle::AtomicWord enabled_atomic = 0; \
36 const unsigned char* enabled_ptr = reinterpret_cast<const unsigned char*>( \
37 base::subtle::NoBarrier_Load(&enabled_atomic)); \
38 if (UNLIKELY(!enabled_ptr)) { \
39 enabled_ptr = GetTracingInterface()->GetCategoryPointer(category); \
40 base::subtle::NoBarrier_Store(&enabled_atomic, \
41 reinterpret_cast<base::subtle::AtomicWord>(enabled_ptr)); \
42 } \
43 trace_event_internal::ScopedTracer scoped_tracer_ ## __LINE__; \
44 if (UNLIKELY(*enabled_ptr)) { \
45 scoped_tracer_ ## __LINE__.Initialize(enabled_ptr, name, \
46 GetTracingInterface()->AddEvent(category, enabled_ptr, 'X', name, false) ); \
47 }
48
49
50 #define TRACE_EVENT_DIRECT_TEST(category, name) \
51 TRACE_EVENT_DIRECT_TEST_BODY(category, name, \
52 cat_enabled_ptr_ ## __LINE__, cat_enabled_atomic_ ## __LINE__)
53
54 #define TRACE_EVENT_DIRECT_TEST_BODY(category, name, enabled_ptr, enabled_atomic ) \
55 static base::subtle::AtomicWord enabled_atomic = 0; \
56 const unsigned char* enabled_ptr = reinterpret_cast<const unsigned char*>( \
57 base::subtle::NoBarrier_Load(&enabled_atomic)); \
58 if (UNLIKELY(!enabled_ptr)) { \
59 enabled_ptr = GetCategoryPointerDirect(category); \
60 base::subtle::NoBarrier_Store(&enabled_atomic, \
61 reinterpret_cast<base::subtle::AtomicWord>(enabled_ptr)); \
62 } \
63 trace_event_internal::ScopedTracer scoped_tracer_ ## __LINE__; \
64 if (UNLIKELY(*enabled_ptr)) { \
65 scoped_tracer_ ## __LINE__.Initialize(enabled_ptr, name, \
66 AddEventDirect(category, enabled_ptr, 'X', name, false)); \
67 }
68
69 } // namespace tracing
70
71 #endif // COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_
OLDNEW
« no previous file with comments | « components/tracing/test/trace_event_perftest.cc ('k') | components/tracing/test/tracing_interface_simulator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698