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

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

Issue 2656303003: Test virtual interface [NOT FOR REVIEW] (Closed)
Patch Set: results 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.cc
diff --git a/components/tracing/test/tracing_interface_simulator.cc b/components/tracing/test/tracing_interface_simulator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..06938789552c03d1db484b2768107d26fcb61ae9
--- /dev/null
+++ b/components/tracing/test/tracing_interface_simulator.cc
@@ -0,0 +1,66 @@
+// 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.
+
+#include "tracing_interface_simulator.h"
+
+#include <string.h>
+
+#include "base/trace_event/trace_event.h"
+
+namespace tracing {
+
+namespace {
+
+class TracingImplementation;
+
+TracingImplementation *g_instance;
+
+class TracingImplementation : public TracingInterface {
+ public:
+ base::trace_event::TraceEventHandle AddEvent(
+ const char *category, const unsigned char* cat_enabled,
+ char type, const char *name, bool copy_name) const override {
+
+ return trace_event_internal::AddTraceEvent(
+ type, cat_enabled, name,
+ trace_event_internal::kGlobalScope, trace_event_internal::kNoId,
+ 0u, trace_event_internal::kNoId);
+ }
+
+ const unsigned char* GetCategoryPointer(const char *category) const override {
+ const unsigned char* cat_enabled =
+ base::trace_event::TraceLog::GetCategoryGroupEnabled(category);
+ CHECK(cat_enabled);
+ return cat_enabled;
+ }
+};
+
+} // namespace
+
+void InitTracingInterface() {
+ g_instance = new TracingImplementation();
+}
+
+const TracingInterface* GetTracingInterface() {
+ return g_instance;
+}
+
+base::trace_event::TraceEventHandle AddEventDirect(
+ const char *category, const unsigned char* cat_enabled,
+ char type, const char *name, bool copy_name) {
+
+ return trace_event_internal::AddTraceEvent(
+ type, cat_enabled, name,
+ trace_event_internal::kGlobalScope, trace_event_internal::kNoId,
+ 0u, trace_event_internal::kNoId);
+}
+
+const unsigned char* GetCategoryPointerDirect(const char *category) {
+ const unsigned char* cat_enabled =
+ base::trace_event::TraceLog::GetCategoryGroupEnabled(category);
+ CHECK(cat_enabled);
+ return cat_enabled;
+}
+
+} // namespace tracing
« no previous file with comments | « components/tracing/test/tracing_interface_simulator.h ('k') | components/tracing/test/tracing_virtual_tradeoff.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698