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

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

Issue 2656303003: Test virtual interface [NOT FOR REVIEW] (Closed)
Patch Set: 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 #include "tracing_interface_simulator.h"
6
7 #include <string.h>
8
9 #include "base/trace_event/trace_event.h"
10
11 namespace tracing {
12
13 namespace {
14
15 class TracingImplementation;
16
17 bool g_category_test = true;
18 TracingImplementation *g_instance;
19
20 class TracingImplementation : public TracingInterface {
21 public:
22 void AddEvent(const char *category, char type,
23 const char *name, bool copy_name) const override {
24 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
25 }
26
27 const bool* GetPointerForCategory(const char *category) const override {
28 if (::strcmp(category, "test_category") == 0)
Primiano Tucci (use gerrit) 2017/01/27 21:26:10 base::trace_event::TraceLog::GetCategoryGroupEnabl
29 return &g_category_test;
30 CHECK(false);
31 return nullptr;
32 }
33 };
34
35 } // namespace
36
37 void InitTracingInterface() {
38 g_instance = new TracingImplementation();
39 }
40
41 const TracingInterface* GetTracingInterface() {
42 return g_instance;
43 }
44
45 void AddEventDirect(const char *category, char type,
46 const char *name, bool copy_name) {
47 TRACE_EVENT0(category, name);
48 }
49
50 const bool* GetPointerForCategoryDirect(const char *category) {
51 if (::strcmp(category, "test_category") == 0)
52 return &g_category_test;
53 CHECK(false);
54 return nullptr;
55 }
56
57 } // namespace tracing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698