Index: base/trace_event/persistent_async_event.h |
diff --git a/base/trace_event/persistent_async_event.h b/base/trace_event/persistent_async_event.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2151c49f98a4bfa51ce992fdf065117337902e2c |
--- /dev/null |
+++ b/base/trace_event/persistent_async_event.h |
@@ -0,0 +1,48 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef BASE_TRACE_EVENT_PERSISTENT_ASYNC_H_ |
+#define BASE_TRACE_EVENT_PERSISTENT_ASYNC_H_ |
+ |
+#include "base/macros.h" |
+#include "base/time/time.h" |
+#include "base/trace_event/trace_event.h" |
+ |
+namespace base { |
+ |
+namespace trace_event { |
+ |
+// Note: The categories and event names must have application lifetime |
+// (i.e. literals), as documented in trace_event_common.h. |
+// Thus, we must make subclasses that have hard-coded categories |
+// and event names, rather than passing these into the PersistentAsyncEvent. |
+ |
+class BASE_EXPORT PersistentAsyncEvent |
+ : public trace_event::TraceLog::EnabledStateObserver { |
+ public: |
+ PersistentAsyncEvent(); |
+ ~PersistentAsyncEvent() override; |
+ |
+ void Begin(); |
+ void End(); |
+ |
+ void OnTraceLogEnabled() override; |
+ void OnTraceLogDisabled() override; |
+ |
+ protected: |
+ virtual void RecordBeginEvent() = 0; |
+ virtual void RecordBeginEventWithTimestamp(base::TimeTicks timestamp) = 0; |
+ virtual void RecordEndEvent() = 0; |
+ void* id() { return id_; } |
+ |
+ private: |
+ void* id_; |
+ bool active_; |
fmeawad
2016/09/02 19:43:25
Should this be atomic, can OnTraceLogEnabled be ca
benjhayden
2016/09/09 21:54:00
If a PersistentAsyncEvent subclass is not on the s
|
+ base::TimeTicks start_time_; |
+}; |
+ |
+} // namespace trace_event |
+} // namespace base |
+ |
+#endif // BASE_TRACE_EVENT_PERSISTENT_ASYNC_H_ |