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

Unified Diff: base/trace_event/persistent_async_event.h

Issue 2159323002: Add tracing AutoOpenCloseEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: code review changes Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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_

Powered by Google App Engine
This is Rietveld 408576698