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

Unified Diff: components/tracing/test/tracing_interface_simulator.h

Issue 2656303003: Test virtual interface [NOT FOR REVIEW] (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698