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

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: Implement new design 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..59a248b37ba212de8e4283ef1f6aaf02efc1acac
--- /dev/null
+++ b/base/trace_event/persistent_async_event.h
@@ -0,0 +1,45 @@
+// 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
+// (strings or literals), as documented in trace_event_common.h.
charliea (OOO until 10-5) 2016/08/29 17:27:27 nit: aren't "string literals" a thing? "(i.e. lite
alexandermont 2016/08/29 18:59:07 Done
+// Thus, we must makes subclasses that have hard-coded categories
benjhayden 2016/08/28 05:17:20 "must make" not "makes"
alexandermont 2016/08/29 18:59:06 Done
+// and event names, rather than passing these into the PersistentAsyncEvent.
+
+class BASE_EXPORT PersistentAsyncEvent
+ : public trace_event::TraceLog::EnabledStateObserver {
+ public:
charliea (OOO until 10-5) 2016/08/29 17:27:27 nit: I think the whitespace is off here. Would you
alexandermont 2016/08/29 18:59:06 Done
+ PersistentAsyncEvent(size_t id);
+ ~PersistentAsyncEvent() override;
+
+ void Start();
+ void Stop();
+
+ virtual void RecordStartEvent();
benjhayden 2016/08/28 05:17:20 The default implementations of these 3 methods don
alexandermont 2016/08/29 18:59:06 Done
+ virtual void RecordStartEventWithTimestamp(int64_t timestamp);
+ virtual void RecordStopEvent();
+ void OnTraceLogEnabled() override;
+ void OnTraceLogDisabled() override;
+
+ protected:
+
charliea (OOO until 10-5) 2016/08/29 17:27:27 I don't think we usually add a blank line before t
alexandermont 2016/08/29 18:59:06 Done
+ size_t id_;
+ bool active_;
+ int64_t start_time_;
charliea (OOO until 10-5) 2016/08/29 17:27:27 Why are we using int64_t to represent time instead
alexandermont 2016/08/29 18:59:06 See above. TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0
+};
+
+}
benjhayden 2016/08/28 05:17:21 "Terminate namespaces with comments as shown in th
alexandermont 2016/08/29 18:59:07 Done
+}
+
+#endif // BASE_TRACE_EVENT_PERSISTENT_ASYNC_H_

Powered by Google App Engine
This is Rietveld 408576698