Chromium Code Reviews| 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..3c2269f13f49739c96b7c7249a14a80a7708b7b0 |
| --- /dev/null |
| +++ b/components/tracing/test/tracing_interface_simulator.cc |
| @@ -0,0 +1,57 @@ |
| +// 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; |
| + |
| +bool g_category_test = true; |
| +TracingImplementation *g_instance; |
| + |
| +class TracingImplementation : public TracingInterface { |
| + public: |
| + void AddEvent(const char *category, char type, |
| + const char *name, bool copy_name) const override { |
| + TRACE_EVENT0(category, name); |
|
Primiano Tucci (use gerrit)
2017/01/27 21:26:10
this is over-penalizing this case. if you use a tr
|
| + } |
| + |
| + const bool* GetPointerForCategory(const char *category) const override { |
| + if (::strcmp(category, "test_category") == 0) |
|
Primiano Tucci (use gerrit)
2017/01/27 21:26:10
base::trace_event::TraceLog::GetCategoryGroupEnabl
|
| + return &g_category_test; |
| + CHECK(false); |
| + return nullptr; |
| + } |
| +}; |
| + |
| +} // namespace |
| + |
| +void InitTracingInterface() { |
| + g_instance = new TracingImplementation(); |
| +} |
| + |
| +const TracingInterface* GetTracingInterface() { |
| + return g_instance; |
| +} |
| + |
| +void AddEventDirect(const char *category, char type, |
| + const char *name, bool copy_name) { |
| + TRACE_EVENT0(category, name); |
| +} |
| + |
| +const bool* GetPointerForCategoryDirect(const char *category) { |
| + if (::strcmp(category, "test_category") == 0) |
| + return &g_category_test; |
| + CHECK(false); |
| + return nullptr; |
| +} |
| + |
| +} // namespace tracing |