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

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: update design Created 4 years, 3 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..eaf2d678d401085496cfe3c38a3b14860e026dc4
--- /dev/null
+++ b/base/trace_event/persistent_async_event.h
@@ -0,0 +1,50 @@
+// 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/threading/thread_checker.h"
+#include "base/time/time.h"
+#include "base/trace_event/trace_event.h"
Primiano Tucci (use gerrit) 2016/09/15 10:08:29 don't think you need to include trace_event here a
Primiano Tucci (use gerrit) 2016/09/15 10:08:29 IWYU (include what you use): add an include base/m
alexandermont 2016/09/15 21:05:13 Done. But you do still need to include trace_event
+
+namespace base {
+namespace trace_event {
+
+class BASE_EXPORT PersistentAsyncEvent
Primiano Tucci (use gerrit) 2016/09/15 10:08:29 Add a comment explaining what this class does and
alexandermont 2016/09/15 21:05:13 Done
+ : public trace_event::TraceLog::AsyncEnabledStateObserver {
Primiano Tucci (use gerrit) 2016/09/15 10:08:30 you don't need trace_event:: here as you are alrea
alexandermont 2016/09/15 21:05:13 Done
+ public:
+ enum Type {
+ ASYNC
+ };
+
+ PersistentAsyncEvent(PersistentAsyncEvent::Type type,
Primiano Tucci (use gerrit) 2016/09/15 10:08:29 you don't need PersistentAsyncEvent:: here I belie
Primiano Tucci (use gerrit) 2016/09/15 10:08:30 Can you add a comment saying // As in the rest of
alexandermont 2016/09/15 21:05:13 Done
+ const char* category, const char* event_name);
+ ~PersistentAsyncEvent() override;
+
+ void Begin();
+ void End();
+
+ // EnabledStateObserver implementation
Primiano Tucci (use gerrit) 2016/09/15 10:08:30 nit, +Async. This is now extending AsyncEnabledSta
alexandermont 2016/09/15 21:05:13 Done
+ void OnTraceLogEnabled() override;
+ void OnTraceLogDisabled() override;
+
+ // TODO(alexandermont): Add in auto-close in OnBeforeTraceLogDisabled once the
+ // OnBeforeTraceLogDisabled CL lands.
+
+ private:
+ bool active_;
+ const char* const category_;
+ const char* const event_name_;
+ base::TimeTicks start_time_;
+ base::ThreadChecker thread_checker_;
+ WeakPtrFactory<PersistentAsyncEvent> weak_factory_;
+ DISALLOW_COPY_AND_ASSIGN(PersistentAsyncEvent);
Primiano Tucci (use gerrit) 2016/09/15 10:08:30 nit: add a blankline between fields and DISALLOW..
alexandermont 2016/09/15 21:05:13 Done
+};
+
+} // namespace trace_event
+} // namespace base
+
+#endif // BASE_TRACE_EVENT_PERSISTENT_ASYNC_H_

Powered by Google App Engine
This is Rietveld 408576698