[tracing] Introduce MemoryDumpSessionState
[chromium-blink-merge.git] / base / trace_event / trace_event_etw_export_win.h
blob0a551c3cf0fde5eee541ef61cdb77642201d3276
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
3 // found in the LICENSE file.
5 // This file contains the Windows-specific exporting to ETW.
6 #ifndef BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_
7 #define BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_
9 #include "base/base_export.h"
10 #include "base/trace_event/trace_event_impl.h"
12 // Fwd.
13 template <typename Type>
14 struct StaticMemorySingletonTraits;
16 namespace base {
17 namespace trace_event {
19 class BASE_EXPORT TraceEventETWExport {
20 public:
21 ~TraceEventETWExport();
23 // Retrieves the singleton.
24 // Note that this may return NULL post-AtExit processing.
25 static TraceEventETWExport* GetInstance();
27 // Enables/disables exporting of events to ETW. If disabled,
28 // AddEvent and AddCustomEvent will simply return when called.
29 static void EnableETWExport();
30 static void DisableETWExport();
32 static bool isETWExportEnabled() { return GetInstance()->ETWExportEnabled_; }
34 // Exports an event to ETW. This is mainly used in
35 // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events.
36 static void AddEvent(
37 char phase,
38 const unsigned char* category_group_enabled,
39 const char* name,
40 unsigned long long id,
41 int num_args,
42 const char** arg_names,
43 const unsigned char* arg_types,
44 const unsigned long long* arg_values,
45 const scoped_refptr<ConvertableToTraceFormat>* convertable_values);
47 // Exports an event to ETW. This should be used when exporting an event only
48 // to ETW. Supports three arguments to be passed to ETW.
49 // TODO(georgesak): Allow different providers.
50 static void AddCustomEvent(const char* name,
51 char const* phase,
52 const char* arg_name_1,
53 const char* arg_value_1,
54 const char* arg_name_2,
55 const char* arg_value_2,
56 const char* arg_name_3,
57 const char* arg_value_3);
59 void Resurrect();
61 private:
62 bool ETWExportEnabled_;
63 // Ensure only the provider can construct us.
64 friend struct StaticMemorySingletonTraits<TraceEventETWExport>;
65 TraceEventETWExport();
67 DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport);
70 } // namespace trace_event
71 } // namespace base
73 #endif // BASE_TRACE_EVENT_TRACE_ETW_EXPORT_H_