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

Side by Side Diff: base/debug/trace_event_win.h

Issue 6933035: Revert 84284 - Merge gpu_trace_event back into base/debug/trace_event.Initial land attempt at htt... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « base/debug/trace_event_unittest.cc ('k') | base/debug/trace_event_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This file contains the Windows-specific declarations for trace_event.h. 5 // This file contains the Windows-specific declarations for trace_event.h.
6 #ifndef BASE_DEBUG_TRACE_EVENT_WIN_H_ 6 #ifndef BASE_DEBUG_TRACE_EVENT_WIN_H_
7 #define BASE_DEBUG_TRACE_EVENT_WIN_H_ 7 #define BASE_DEBUG_TRACE_EVENT_WIN_H_
8 #pragma once 8 #pragma once
9 9
10 #include <string> 10 #include <string>
11 11
12 #include "base/base_api.h" 12 #include "base/base_api.h"
13 #include "base/debug/trace_event.h"
14 #include "base/win/event_trace_provider.h" 13 #include "base/win/event_trace_provider.h"
15 14
15 #define TRACE_EVENT_BEGIN(name, id, extra) \
16 base::debug::TraceLog::Trace( \
17 name, \
18 base::debug::TraceLog::EVENT_BEGIN, \
19 reinterpret_cast<const void*>(id), \
20 extra);
21
22 #define TRACE_EVENT_END(name, id, extra) \
23 base::debug::TraceLog::Trace( \
24 name, \
25 base::debug::TraceLog::EVENT_END, \
26 reinterpret_cast<const void*>(id), \
27 extra);
28
29 #define TRACE_EVENT_INSTANT(name, id, extra) \
30 base::debug::TraceLog::Trace( \
31 name, \
32 base::debug::TraceLog::EVENT_INSTANT, \
33 reinterpret_cast<const void*>(id), \
34 extra);
35
16 // Fwd. 36 // Fwd.
17 template <typename Type> 37 template <typename Type>
18 struct StaticMemorySingletonTraits; 38 struct StaticMemorySingletonTraits;
19 39
20 namespace base { 40 namespace base {
21 namespace debug { 41 namespace debug {
22 42
23 // This EtwTraceProvider subclass implements ETW logging 43 // This EtwTraceProvider subclass implements ETW logging
24 // for the macros above on Windows. 44 // for the macros above on Windows.
25 class BASE_API TraceEventETWProvider : public base::win::EtwTraceProvider { 45 class BASE_API TraceLog : public base::win::EtwTraceProvider {
26 public: 46 public:
47 enum EventType {
48 EVENT_BEGIN,
49 EVENT_END,
50 EVENT_INSTANT
51 };
52
27 // Start logging trace events. 53 // Start logging trace events.
28 // This is a noop in this implementation. 54 // This is a noop in this implementation.
29 static bool StartTracing(); 55 static bool StartTracing();
30 56
31 // Trace begin/end/instant events, this is the bottleneck implementation 57 // Trace begin/end/instant events, this is the bottleneck implementation
32 // all the others defer to. 58 // all the others defer to.
33 // Allowing the use of std::string for name or extra is a convenience, 59 // Allowing the use of std::string for name or extra is a convenience,
34 // whereas passing name or extra as a const char* avoids the construction 60 // whereas passing name or extra as a const char* avoids the construction
35 // of temporary std::string instances. 61 // of temporary std::string instances.
36 // If -1 is passed for name_len or extra_len, the strlen of the string will 62 // If -1 is passed for name_len or extra_len, the strlen of the string will
37 // be used for length. 63 // be used for length.
38 static void Trace(const char* name, 64 static void Trace(const char* name,
39 size_t name_len, 65 size_t name_len,
40 TraceEventPhase type, 66 EventType type,
41 const void* id, 67 const void* id,
42 const char* extra, 68 const char* extra,
43 size_t extra_len); 69 size_t extra_len);
44 70
45 // Allows passing extra as a std::string for convenience. 71 // Allows passing extra as a std::string for convenience.
46 static void Trace(const char* name, 72 static void Trace(const char* name,
47 TraceEventPhase type, 73 EventType type,
48 const void* id, 74 const void* id,
49 const std::string& extra) { 75 const std::string& extra) {
50 return Trace(name, -1, type, id, extra.c_str(), extra.length()); 76 return Trace(name, -1, type, id, extra.c_str(), extra.length());
51 } 77 }
52 78
53 // Allows passing extra as a const char* to avoid constructing temporary 79 // Allows passing extra as a const char* to avoid constructing temporary
54 // std::string instances where not needed. 80 // std::string instances where not needed.
55 static void Trace(const char* name, 81 static void Trace(const char* name,
56 TraceEventPhase type, 82 EventType type,
57 const void* id, 83 const void* id,
58 const char* extra) { 84 const char* extra) {
59 return Trace(name, -1, type, id, extra, -1); 85 return Trace(name, -1, type, id, extra, -1);
60 } 86 }
61 87
62 // Retrieves the singleton. 88 // Retrieves the singleton.
63 // Note that this may return NULL post-AtExit processing. 89 // Note that this may return NULL post-AtExit processing.
64 static TraceEventETWProvider* GetInstance(); 90 static TraceLog* GetInstance();
65 91
66 // Returns true iff tracing is turned on. 92 // Returns true iff tracing is turned on.
67 bool IsTracing() { 93 bool IsTracing() {
68 return enable_level() >= TRACE_LEVEL_INFORMATION; 94 return enable_level() >= TRACE_LEVEL_INFORMATION;
69 } 95 }
70 96
71 // Emit a trace of type |type| containing |name|, |id|, and |extra|. 97 // Emit a trace of type |type| containing |name|, |id|, and |extra|.
72 // Note: |name| and |extra| must be NULL, or a zero-terminated string of 98 // Note: |name| and |extra| must be NULL, or a zero-terminated string of
73 // length |name_len| or |extra_len| respectively. 99 // length |name_len| or |extra_len| respectively.
74 // Note: if name_len or extra_len are -1, the length of the corresponding 100 // Note: if name_len or extra_len are -1, the length of the corresponding
75 // string will be used. 101 // string will be used.
76 void TraceEvent(const char* name, 102 void TraceEvent(const char* name,
77 size_t name_len, 103 size_t name_len,
78 TraceEventPhase type, 104 EventType type,
79 const void* id, 105 const void* id,
80 const char* extra, 106 const char* extra,
81 size_t extra_len); 107 size_t extra_len);
82 108
83 // Exposed for unittesting only, allows resurrecting our 109 // Exposed for unittesting only, allows resurrecting our
84 // singleton instance post-AtExit processing. 110 // singleton instance post-AtExit processing.
85 static void Resurrect(); 111 static void Resurrect();
86 112
87 private: 113 private:
88 // Ensure only the provider can construct us. 114 // Ensure only the provider can construct us.
89 friend struct StaticMemorySingletonTraits<TraceEventETWProvider>; 115 friend struct StaticMemorySingletonTraits<TraceLog>;
90 TraceEventETWProvider(); 116 TraceLog();
91 117
92 DISALLOW_COPY_AND_ASSIGN(TraceEventETWProvider); 118 DISALLOW_COPY_AND_ASSIGN(TraceLog);
93 }; 119 };
94 120
95 // The ETW trace provider GUID. 121 // The ETW trace provider GUID.
96 BASE_API extern const GUID kChromeTraceProviderName; 122 BASE_API extern const GUID kChromeTraceProviderName;
97 123
98 // The ETW event class GUID for 32 bit events. 124 // The ETW event class GUID for 32 bit events.
99 BASE_API extern const GUID kTraceEventClass32; 125 BASE_API extern const GUID kTraceEventClass32;
100 126
101 // The ETW event class GUID for 64 bit events. 127 // The ETW event class GUID for 64 bit events.
102 BASE_API extern const GUID kTraceEventClass64; 128 BASE_API extern const GUID kTraceEventClass64;
(...skipping 15 matching lines...) Expand all
118 // Optionally the stack trace, consisting of a DWORD "depth", followed 144 // Optionally the stack trace, consisting of a DWORD "depth", followed
119 // by an array of void* (machine bitness) of length "depth". 145 // by an array of void* (machine bitness) of length "depth".
120 146
121 // Forward decl. 147 // Forward decl.
122 struct TraceLogSingletonTraits; 148 struct TraceLogSingletonTraits;
123 149
124 } // nemspace debug 150 } // nemspace debug
125 } // namespace base 151 } // namespace base
126 152
127 #endif // BASE_DEBUG_TRACE_EVENT_WIN_H_ 153 #endif // BASE_DEBUG_TRACE_EVENT_WIN_H_
OLDNEW
« no previous file with comments | « base/debug/trace_event_unittest.cc ('k') | base/debug/trace_event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698