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

Side by Side Diff: include/utils/SkEventTracer.h

Issue 149563004: initial import of Chrome's trace_event into skia framework (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: use SkOnce to sensibly initialize the singleton Created 6 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 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
reed1 2014/01/29 18:38:40 This copyright header seems a lot bigger than the
humper 2014/01/29 18:52:06 Whoops, you're right. Shortened.
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef EventTracer_h
32 #define EventTracer_h
reed1 2014/01/29 18:38:40 skia's pattern would be to qualify this guard thus
humper 2014/01/29 18:52:06 Yeah, this is another copy/paste bug; fixed.
33
34 #include "SkTypes.h"
35
36 // This will mark the trace event as disabled by default. The user will need
37 // to explicitly enable the event.
38 #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
39
40 namespace skia {
reed1 2014/01/29 18:38:40 skia namespace not needed for types like SkEventTr
41 namespace tracing {
reed1 2014/01/29 18:38:40 why this other namespace? Is this explicitly to ac
humper 2014/01/29 18:52:06 It's probably unnecessary; it just mirrors the Chr
42
43 typedef uint32_t TraceEventHandle;
44
45 // FIXME: Make these global variables thread-safe. Make a value update atomic.
46 SK_API extern long* traceSamplingState[3];
47
48 class SK_API SkEventTracer {
reed1 2014/01/29 18:38:40 This name is very generic looking (and somewhat a
humper 2014/01/29 18:52:06 Sure, I'm open to any name here. SkEventTracer im
49 public:
50
51 static SkEventTracer* GetInstance();
52
53 static void SetInstance(SkEventTracer* tracer) {
54 SkDELETE(SkEventTracer::_instance);
55 SkEventTracer::_instance = tracer;
56 }
57
58 virtual ~SkEventTracer() { SkDELETE(SkEventTracer::_instance); }
59
60 // The pointer returned from GetCategoryGroupEnabled() points to a
61 // value with zero or more of the following bits. Used in this class only.
62 // The TRACE_EVENT macros should only use the value as a bool.
63 // These values must be in sync with macro values in trace_event.h in chromi um.
64 enum CategoryGroupEnabledFlags {
65 // Category group enabled for the recording mode.
66 ENABLED_FOR_RECORDING = 1 << 0,
67 // Category group enabled for the monitoring mode.
68 ENABLED_FOR_MONITORING = 1 << 1,
69 // Category group enabled by SetEventCallbackEnabled().
70 ENABLED_FOR_EVENT_CALLBACK = 1 << 2,
71 };
72
73 virtual const unsigned char* GetCategoryGroupEnabled(const char* name) = 0;
74 virtual const char* GetCategoryGroupName(
75 const unsigned char* category_group_enabled) = 0;
76
77 virtual TraceEventHandle
78 AddTraceEvent(char phase,
79 const unsigned char* categoryEnabledFlag,
80 const char* name,
81 unsigned long long id,
82 int numArgs,
83 const char** argNames,
84 const unsigned char* argTypes,
85 const unsigned long long* argValues,
86 unsigned char flags) = 0;
87
88 virtual void
89 UpdateTraceEventDuration(const unsigned char* categoryEnabledFlag,
90 const char* name,
91 tracing::TraceEventHandle) = 0;
92 private:
93 static SkEventTracer *_instance;
94 };
95
96 } // namespace tracing
97 } // namespace skia
98
99 #endif // EventTracer_h
OLDNEW
« no previous file with comments | « gyp/utils.gyp ('k') | src/core/SkTraceEvent.h » ('j') | src/core/SkTraceEvent.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698