| OLD | NEW |
| 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 // Declaration of a Windows event trace controller class. | 5 // Declaration of a Windows event trace controller class. |
| 6 // The controller takes care of creating and manipulating event trace | 6 // The controller takes care of creating and manipulating event trace |
| 7 // sessions. | 7 // sessions. |
| 8 // | 8 // |
| 9 // Event tracing for Windows is a system-provided service that provides | 9 // Event tracing for Windows is a system-provided service that provides |
| 10 // logging control and high-performance transport for generic, binary trace | 10 // logging control and high-performance transport for generic, binary trace |
| 11 // events. Event trace providers register with the system by their name, | 11 // events. Event trace providers register with the system by their name, |
| 12 // which is a GUID, and can from that point forward receive callbacks that | 12 // which is a GUID, and can from that point forward receive callbacks that |
| 13 // start or end tracing and that change their trace level and enable mask. | 13 // start or end tracing and that change their trace level and enable mask. |
| 14 // | 14 // |
| 15 // A trace controller can create an event tracing session, which either | 15 // A trace controller can create an event tracing session, which either |
| 16 // sends events to a binary file, or to a realtime consumer, or both. | 16 // sends events to a binary file, or to a realtime consumer, or both. |
| 17 // | 17 // |
| 18 // A trace consumer consumes events from zero or one realtime session, | 18 // A trace consumer consumes events from zero or one realtime session, |
| 19 // as well as potentially from multiple binary trace files. | 19 // as well as potentially from multiple binary trace files. |
| 20 #ifndef BASE_WIN_EVENT_TRACE_CONTROLLER_H_ | 20 #ifndef BASE_WIN_EVENT_TRACE_CONTROLLER_H_ |
| 21 #define BASE_WIN_EVENT_TRACE_CONTROLLER_H_ | 21 #define BASE_WIN_EVENT_TRACE_CONTROLLER_H_ |
| 22 #pragma once | 22 #pragma once |
| 23 | 23 |
| 24 #include <windows.h> | 24 #include <windows.h> |
| 25 #include <wmistr.h> | 25 #include <wmistr.h> |
| 26 #include <evntrace.h> | 26 #include <evntrace.h> |
| 27 #include <string> | 27 #include <string> |
| 28 | 28 |
| 29 #include "base/base_api.h" | 29 #include "base/base_export.h" |
| 30 #include "base/basictypes.h" | 30 #include "base/basictypes.h" |
| 31 | 31 |
| 32 namespace base { | 32 namespace base { |
| 33 namespace win { | 33 namespace win { |
| 34 | 34 |
| 35 // Utility class to make it easier to work with EVENT_TRACE_PROPERTIES. | 35 // Utility class to make it easier to work with EVENT_TRACE_PROPERTIES. |
| 36 // The EVENT_TRACE_PROPERTIES structure contains information about an | 36 // The EVENT_TRACE_PROPERTIES structure contains information about an |
| 37 // event tracing session. | 37 // event tracing session. |
| 38 class BASE_API EtwTraceProperties { | 38 class BASE_EXPORT EtwTraceProperties { |
| 39 public: | 39 public: |
| 40 EtwTraceProperties(); | 40 EtwTraceProperties(); |
| 41 | 41 |
| 42 EVENT_TRACE_PROPERTIES* get() { | 42 EVENT_TRACE_PROPERTIES* get() { |
| 43 return &properties_; | 43 return &properties_; |
| 44 } | 44 } |
| 45 | 45 |
| 46 const EVENT_TRACE_PROPERTIES* get() const { | 46 const EVENT_TRACE_PROPERTIES* get() const { |
| 47 return reinterpret_cast<const EVENT_TRACE_PROPERTIES*>(&properties_); | 47 return reinterpret_cast<const EVENT_TRACE_PROPERTIES*>(&properties_); |
| 48 } | 48 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 78 // The actual size of the buffer is forced by this member. | 78 // The actual size of the buffer is forced by this member. |
| 79 char buffer_[kBufSize]; | 79 char buffer_[kBufSize]; |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 DISALLOW_COPY_AND_ASSIGN(EtwTraceProperties); | 82 DISALLOW_COPY_AND_ASSIGN(EtwTraceProperties); |
| 83 }; | 83 }; |
| 84 | 84 |
| 85 // This class implements an ETW controller, which knows how to start and | 85 // This class implements an ETW controller, which knows how to start and |
| 86 // stop event tracing sessions, as well as controlling ETW provider | 86 // stop event tracing sessions, as well as controlling ETW provider |
| 87 // log levels and enable bit masks under the session. | 87 // log levels and enable bit masks under the session. |
| 88 class BASE_API EtwTraceController { | 88 class BASE_EXPORT EtwTraceController { |
| 89 public: | 89 public: |
| 90 EtwTraceController(); | 90 EtwTraceController(); |
| 91 ~EtwTraceController(); | 91 ~EtwTraceController(); |
| 92 | 92 |
| 93 // Start a session with given name and properties. | 93 // Start a session with given name and properties. |
| 94 HRESULT Start(const wchar_t* session_name, EtwTraceProperties* prop); | 94 HRESULT Start(const wchar_t* session_name, EtwTraceProperties* prop); |
| 95 | 95 |
| 96 // Starts a session tracing to a file with some default properties. | 96 // Starts a session tracing to a file with some default properties. |
| 97 HRESULT StartFileSession(const wchar_t* session_name, | 97 HRESULT StartFileSession(const wchar_t* session_name, |
| 98 const wchar_t* logfile_path, | 98 const wchar_t* logfile_path, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 std::wstring session_name_; | 143 std::wstring session_name_; |
| 144 TRACEHANDLE session_; | 144 TRACEHANDLE session_; |
| 145 | 145 |
| 146 DISALLOW_COPY_AND_ASSIGN(EtwTraceController); | 146 DISALLOW_COPY_AND_ASSIGN(EtwTraceController); |
| 147 }; | 147 }; |
| 148 | 148 |
| 149 } // namespace win | 149 } // namespace win |
| 150 } // namespace base | 150 } // namespace base |
| 151 | 151 |
| 152 #endif // BASE_WIN_EVENT_TRACE_CONTROLLER_H_ | 152 #endif // BASE_WIN_EVENT_TRACE_CONTROLLER_H_ |
| OLD | NEW |