OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 exporting to ETW. | 5 // This file contains the Windows-specific exporting to ETW. |
6 #ifndef BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_ | 6 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ |
7 #define BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_ | 7 #define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ |
8 | 8 |
9 #include "base/base_export.h" | 9 #include "base/base_export.h" |
10 #include "base/trace_event/trace_event_impl.h" | 10 #include "base/trace_event/trace_event_impl.h" |
11 | 11 |
12 // Fwd. | 12 // Fwd. |
13 template <typename Type> | 13 template <typename Type> |
14 struct StaticMemorySingletonTraits; | 14 struct StaticMemorySingletonTraits; |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 namespace trace_event { | 17 namespace trace_event { |
18 | 18 |
19 class BASE_EXPORT TraceEventETWExport { | 19 class BASE_EXPORT TraceEventETWExport { |
20 public: | 20 public: |
21 ~TraceEventETWExport(); | 21 ~TraceEventETWExport(); |
22 | 22 |
23 // Retrieves the singleton. | 23 // Retrieves the singleton. |
24 // Note that this may return NULL post-AtExit processing. | 24 // Note that this may return NULL post-AtExit processing. |
25 static TraceEventETWExport* GetInstance(); | 25 static TraceEventETWExport* GetInstance(); |
26 | 26 |
27 // Enables/disables exporting of events to ETW. If disabled, | 27 // Enables/disables exporting of events to ETW. If disabled, |
28 // AddEvent and AddCustomEvent will simply return when called. | 28 // AddEvent and AddCustomEvent will simply return when called. |
29 static void EnableETWExport(); | 29 static void EnableETWExport(); |
30 static void DisableETWExport(); | 30 static void DisableETWExport(); |
31 | 31 |
32 static bool isETWExportEnabled() { return GetInstance()->ETWExportEnabled_; } | 32 static bool isETWExportEnabled() { |
| 33 return (GetInstance() && GetInstance()->ETWExportEnabled_); |
| 34 } |
33 | 35 |
34 // Exports an event to ETW. This is mainly used in | 36 // Exports an event to ETW. This is mainly used in |
35 // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events. | 37 // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events. |
36 static void AddEvent( | 38 static void AddEvent( |
37 char phase, | 39 char phase, |
38 const unsigned char* category_group_enabled, | 40 const unsigned char* category_group_enabled, |
39 const char* name, | 41 const char* name, |
40 unsigned long long id, | 42 unsigned long long id, |
41 int num_args, | 43 int num_args, |
42 const char** arg_names, | 44 const char** arg_names, |
(...skipping 20 matching lines...) Expand all Loading... |
63 // Ensure only the provider can construct us. | 65 // Ensure only the provider can construct us. |
64 friend struct StaticMemorySingletonTraits<TraceEventETWExport>; | 66 friend struct StaticMemorySingletonTraits<TraceEventETWExport>; |
65 TraceEventETWExport(); | 67 TraceEventETWExport(); |
66 | 68 |
67 DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport); | 69 DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport); |
68 }; | 70 }; |
69 | 71 |
70 } // namespace trace_event | 72 } // namespace trace_event |
71 } // namespace base | 73 } // namespace base |
72 | 74 |
73 #endif // BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_ | 75 #endif // BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ |
OLD | NEW |