OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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. | |
4 | |
5 #ifndef BASE_AUTO_OPEN_CLOSE_EVENT_H_ | |
6 #define BASE_AUTO_OPEN_CLOSE_EVENT_H_ | |
7 | |
8 #include "base/macros.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "base/threading/thread_checker.h" | |
11 #include "base/time/time.h" | |
12 #include "base/trace_event/trace_event.h" | |
13 | |
14 namespace base { | |
15 namespace trace_event { | |
16 | |
17 /** | |
Primiano Tucci (use gerrit)
2016/09/22 10:05:49
Nit: in general I see always // style comments. Th
| |
18 * Class for tracing events that support "auto-opening" and "auto-closing". | |
19 * "auto-opening" = if the trace event is started (call Begin() before | |
20 * tracing is started,the trace event will be opened, with the start time | |
21 * being the time that the trace event was actually started. | |
22 * "auto-closing" = if the trace event is started but not ended by the time | |
23 * tracing ends, then the trace event will be automatically closed at the | |
24 * end of tracing | |
25 */ | |
26 class BASE_EXPORT AutoOpenCloseEvent | |
27 : public TraceLog::AsyncEnabledStateObserver { | |
28 public: | |
29 enum Type { | |
30 ASYNC | |
31 }; | |
32 | |
33 // As in the rest of the tracing macros, the const char* arguments here | |
34 // must be pointers to indefinitely lived strings (e.g. hard-coded string | |
35 // literals are okay, but not strings created by c_str()) | |
36 AutoOpenCloseEvent(Type type, const char* category, const char* event_name); | |
37 ~AutoOpenCloseEvent() override; | |
38 | |
39 void Begin(); | |
40 void End(); | |
41 | |
42 // AsyncEnabledStateObserver implementation | |
43 void OnTraceLogEnabled() override; | |
44 void OnTraceLogDisabled() override; | |
45 | |
46 private: | |
47 const char* const category_; | |
48 const char* const event_name_; | |
49 base::TimeTicks start_time_; | |
50 base::ThreadChecker thread_checker_; | |
51 WeakPtrFactory<AutoOpenCloseEvent> weak_factory_; | |
52 DISALLOW_COPY_AND_ASSIGN(AutoOpenCloseEvent); | |
53 }; | |
54 | |
55 } // namespace trace_event | |
56 } // namespace base | |
57 | |
58 #endif // BASE_AUTO_OPEN_CLOSE_EVENT_H_ | |
OLD | NEW |