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

Side by Side Diff: base/trace_event/trace_event_etw_export_win.h

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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
OLDNEW
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_EVENT_ETW_EXPORT_WIN_H_ 6 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
7 #define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ 7 #define BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
8 8
9 #include <map>
10
9 #include "base/base_export.h" 11 #include "base/base_export.h"
12 #include "base/strings/string_piece.h"
10 #include "base/trace_event/trace_event_impl.h" 13 #include "base/trace_event/trace_event_impl.h"
11 14
12 // Fwd. 15 // Fwd.
13 template <typename Type> 16 template <typename Type>
14 struct StaticMemorySingletonTraits; 17 struct StaticMemorySingletonTraits;
15 18
16 namespace base { 19 namespace base {
17 namespace trace_event { 20 namespace trace_event {
18 21
19 class BASE_EXPORT TraceEventETWExport { 22 class BASE_EXPORT TraceEventETWExport {
20 public: 23 public:
21 ~TraceEventETWExport(); 24 ~TraceEventETWExport();
22 25
23 // Retrieves the singleton. 26 // Retrieves the singleton.
24 // Note that this may return NULL post-AtExit processing. 27 // Note that this may return NULL post-AtExit processing.
25 static TraceEventETWExport* GetInstance(); 28 static TraceEventETWExport* GetInstance();
26 29
27 // Enables/disables exporting of events to ETW. If disabled, 30 // Enables/disables exporting of events to ETW. If disabled,
28 // AddEvent and AddCustomEvent will simply return when called. 31 // AddEvent and AddCustomEvent will simply return when called.
29 static void EnableETWExport(); 32 static void EnableETWExport();
30 static void DisableETWExport(); 33 static void DisableETWExport();
31 34
32 static bool isETWExportEnabled() { 35 // Returns true if ETW is enabled. For now, this is true if the command line
33 return (GetInstance() && GetInstance()->ETWExportEnabled_); 36 // flag is specified.
34 } 37 static bool IsETWExportEnabled();
35 38
36 // Exports an event to ETW. This is mainly used in 39 // Exports an event to ETW. This is mainly used in
37 // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events. 40 // TraceLog::AddTraceEventWithThreadIdAndTimestamp to export internal events.
38 static void AddEvent( 41 static void AddEvent(
39 char phase, 42 char phase,
40 const unsigned char* category_group_enabled, 43 const unsigned char* category_group_enabled,
41 const char* name, 44 const char* name,
42 unsigned long long id, 45 unsigned long long id,
43 int num_args, 46 int num_args,
44 const char** arg_names, 47 const char** arg_names,
45 const unsigned char* arg_types, 48 const unsigned char* arg_types,
46 const unsigned long long* arg_values, 49 const unsigned long long* arg_values,
47 const scoped_refptr<ConvertableToTraceFormat>* convertable_values); 50 const scoped_refptr<ConvertableToTraceFormat>* convertable_values);
48 51
49 // Exports an event to ETW. This should be used when exporting an event only 52 // Exports an event to ETW. This should be used when exporting an event only
50 // to ETW. Supports three arguments to be passed to ETW. 53 // to ETW. Supports three arguments to be passed to ETW.
51 // TODO(georgesak): Allow different providers. 54 // TODO(georgesak): Allow different providers.
52 static void AddCustomEvent(const char* name, 55 static void AddCustomEvent(const char* name,
53 char const* phase, 56 const char* phase,
54 const char* arg_name_1, 57 const char* arg_name_1,
55 const char* arg_value_1, 58 const char* arg_value_1,
56 const char* arg_name_2, 59 const char* arg_name_2,
57 const char* arg_value_2, 60 const char* arg_value_2,
58 const char* arg_name_3, 61 const char* arg_name_3,
59 const char* arg_value_3); 62 const char* arg_value_3);
60 63
61 void Resurrect(); 64 // Returns true if any category in the group is enabled.
65 static bool IsCategoryGroupEnabled(const char* category_group_name);
62 66
63 private: 67 private:
64 bool ETWExportEnabled_;
65 // Ensure only the provider can construct us. 68 // Ensure only the provider can construct us.
66 friend struct StaticMemorySingletonTraits<TraceEventETWExport>; 69 friend struct StaticMemorySingletonTraits<TraceEventETWExport>;
67 TraceEventETWExport(); 70 TraceEventETWExport();
68 71
72 // Updates the list of enabled categories by consulting the ETW keyword.
73 // Returns true if there was a change, false otherwise.
74 bool UpdateEnabledCategories();
75
76 // Returns true if the category is enabled.
77 bool IsCategoryEnabled(const char* category_name) const;
78
79 // True if ETW is enabled. Allows hiding the exporting behind a flag.
80 bool etw_export_enabled_;
81
82 // Maps category names to their status (enabled/disabled).
83 std::map<base::StringPiece, bool> categories_status_;
84
85 // Local copy of the ETW keyword.
86 uint64 etw_match_any_keyword_;
87
69 DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport); 88 DISALLOW_COPY_AND_ASSIGN(TraceEventETWExport);
70 }; 89 };
71 90
72 } // namespace trace_event 91 } // namespace trace_event
73 } // namespace base 92 } // namespace base
74 93
75 #endif // BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_ 94 #endif // BASE_TRACE_EVENT_TRACE_EVENT_ETW_EXPORT_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698