Chromium Code Reviews| Index: components/tracing/test/tracing_interface_simulator.h |
| diff --git a/components/tracing/test/tracing_interface_simulator.h b/components/tracing/test/tracing_interface_simulator.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..29f13836779485d440ec7a112f673783b227286f |
| --- /dev/null |
| +++ b/components/tracing/test/tracing_interface_simulator.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_ |
| +#define COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_ |
| + |
| +namespace tracing { |
| + |
| +class TracingInterface { |
| + public: |
| + virtual void AddEvent(const char *category, char type, |
| + const char *name, bool copy_name) const = 0; |
| + virtual const bool* GetPointerForCategory(const char *category) const = 0; |
| +}; |
| + |
| +void InitTracingInterface(); |
| +const TracingInterface* GetTracingInterface(); |
| + |
| +void AddEventDirect(const char *category, char type, |
| + const char *name, bool copy_name); |
| +const bool* GetPointerForCategoryDirect(const char *category); |
| + |
| + |
| +#define TRACE_EVENT_VIRTUAL_TEST(category, name) \ |
| + TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, cat_enabled_ptr_ ## __LINE__) |
| + |
| +#define TRACE_EVENT_VIRTUAL_TEST_BODY(category, name, enabled_ptr) \ |
| + static const bool* enabled_ptr = nullptr; \ |
|
Primiano Tucci (use gerrit)
2017/01/27 21:26:10
see comments below
|
| + if (!enabled_ptr) \ |
| + enabled_ptr = GetTracingInterface()->GetPointerForCategory(category); \ |
| + if (*enabled_ptr) \ |
| + GetTracingInterface()->AddEvent(category, 'X', name, false); |
| + |
| + |
| +#define TRACE_EVENT_DIRECT_TEST(category, name) \ |
| + TRACE_EVENT_DIRECT_TEST_BODY(category, name, cat_enabled_ptr_ ## __LINE__) |
| + |
| +#define TRACE_EVENT_DIRECT_TEST_BODY(category, name, enabled_ptr) \ |
| + 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
|
| + if (!enabled_ptr) \ |
|
Primiano Tucci (use gerrit)
2017/01/27 21:26:10
ditto. see INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENA
|
| + enabled_ptr = GetPointerForCategoryDirect(category); \ |
| + if (*enabled_ptr) \ |
| + AddEventDirect(category, 'X', name, false); |
| + |
| +} // namespace tracing |
| + |
| +#endif // COMPONENTS_TRACING_TEST_TRACING_INTERFACE_SIMULATOR_H_ |