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

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

Issue 9155024: Allow tracing in third_party libraries (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: win compile Created 8 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 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>
(...skipping 19 matching lines...) Expand all
30 30
31 // Trace begin/end/instant events, this is the bottleneck implementation 31 // Trace begin/end/instant events, this is the bottleneck implementation
32 // all the others defer to. 32 // all the others defer to.
33 // Allowing the use of std::string for name or extra is a convenience, 33 // 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 34 // whereas passing name or extra as a const char* avoids the construction
35 // of temporary std::string instances. 35 // of temporary std::string instances.
36 // If -1 is passed for name_len or extra_len, the strlen of the string will 36 // If -1 is passed for name_len or extra_len, the strlen of the string will
37 // be used for length. 37 // be used for length.
38 static void Trace(const char* name, 38 static void Trace(const char* name,
39 size_t name_len, 39 size_t name_len,
40 TraceEventPhase type, 40 char type,
41 const void* id, 41 const void* id,
42 const char* extra, 42 const char* extra,
43 size_t extra_len); 43 size_t extra_len);
44 44
45 // Allows passing extra as a std::string for convenience. 45 // Allows passing extra as a std::string for convenience.
46 static void Trace(const char* name, 46 static void Trace(const char* name,
47 TraceEventPhase type, 47 char type,
48 const void* id, 48 const void* id,
49 const std::string& extra) { 49 const std::string& extra) {
50 return Trace(name, -1, type, id, extra.c_str(), extra.length()); 50 return Trace(name, -1, type, id, extra.c_str(), extra.length());
51 } 51 }
52 52
53 // Allows passing extra as a const char* to avoid constructing temporary 53 // Allows passing extra as a const char* to avoid constructing temporary
54 // std::string instances where not needed. 54 // std::string instances where not needed.
55 static void Trace(const char* name, 55 static void Trace(const char* name,
56 TraceEventPhase type, 56 char type,
57 const void* id, 57 const void* id,
58 const char* extra) { 58 const char* extra) {
59 return Trace(name, -1, type, id, extra, -1); 59 return Trace(name, -1, type, id, extra, -1);
60 } 60 }
61 61
62 // Retrieves the singleton. 62 // Retrieves the singleton.
63 // Note that this may return NULL post-AtExit processing. 63 // Note that this may return NULL post-AtExit processing.
64 static TraceEventETWProvider* GetInstance(); 64 static TraceEventETWProvider* GetInstance();
65 65
66 // Returns true iff tracing is turned on. 66 // Returns true iff tracing is turned on.
67 bool IsTracing() { 67 bool IsTracing() {
68 return enable_level() >= TRACE_LEVEL_INFORMATION; 68 return enable_level() >= TRACE_LEVEL_INFORMATION;
69 } 69 }
70 70
71 // Emit a trace of type |type| containing |name|, |id|, and |extra|. 71 // 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 72 // Note: |name| and |extra| must be NULL, or a zero-terminated string of
73 // length |name_len| or |extra_len| respectively. 73 // length |name_len| or |extra_len| respectively.
74 // Note: if name_len or extra_len are -1, the length of the corresponding 74 // Note: if name_len or extra_len are -1, the length of the corresponding
75 // string will be used. 75 // string will be used.
76 void TraceEvent(const char* name, 76 void TraceEvent(const char* name,
77 size_t name_len, 77 size_t name_len,
78 TraceEventPhase type, 78 char type,
79 const void* id, 79 const void* id,
80 const char* extra, 80 const char* extra,
81 size_t extra_len); 81 size_t extra_len);
82 82
83 // Exposed for unittesting only, allows resurrecting our 83 // Exposed for unittesting only, allows resurrecting our
84 // singleton instance post-AtExit processing. 84 // singleton instance post-AtExit processing.
85 static void Resurrect(); 85 static void Resurrect();
86 86
87 private: 87 private:
88 // Ensure only the provider can construct us. 88 // Ensure only the provider can construct us.
(...skipping 26 matching lines...) Expand all
115 // The "name" string as a zero-terminated ASCII string. 115 // The "name" string as a zero-terminated ASCII string.
116 // The id pointer in the machine bitness. 116 // The id pointer in the machine bitness.
117 // The "extra" string as a zero-terminated ASCII string. 117 // The "extra" string as a zero-terminated ASCII string.
118 // Optionally the stack trace, consisting of a DWORD "depth", followed 118 // Optionally the stack trace, consisting of a DWORD "depth", followed
119 // by an array of void* (machine bitness) of length "depth". 119 // by an array of void* (machine bitness) of length "depth".
120 120
121 } // namespace debug 121 } // namespace debug
122 } // namespace base 122 } // namespace base
123 123
124 #endif // BASE_DEBUG_TRACE_EVENT_WIN_H_ 124 #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