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