Index: base/trace_event/persistent_async_event.cc |
diff --git a/base/trace_event/persistent_async_event.cc b/base/trace_event/persistent_async_event.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5e1927d941a77768379cee57f83d07abe47d888c |
--- /dev/null |
+++ b/base/trace_event/persistent_async_event.cc |
@@ -0,0 +1,65 @@ |
+// 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. |
+ |
+#include "base/macros.h" |
+#include "base/trace_event/trace_event.h" |
+#include "base/trace_event/persistent_async_event.h" |
+#include <string> |
+#include <ctime> |
+ |
+// test |
+ |
+namespace base { |
+namespace trace_event { |
+ |
+PersistentAsyncEvent::PersistentAsyncEvent() |
+ : active_(false) {} |
+ |
+PersistentAsyncEvent::~PersistentAsyncEvent() {} |
+ |
+void PersistentAsyncEvent::Start(std::string param_value) { |
+ param_value_ = param_value; |
+ RecordStartEvent(); |
+ active_ = true; |
+ gettimeofday(&start_time_, 0); |
benjhayden
2016/08/10 18:30:00
charliea can help you figure out what function to
|
+} |
+ |
+void PersistentAsyncEvent::Stop(std::string param_value) { |
+ param_value_ = param_value; |
+ RecordStopEvent(); |
+ active_ = false; |
+} |
+ |
+void PersistentAsyncEvent::RecordStartEvent() { |
+ TRACE_EVENT0("media", "PersistentAsyncStart"); |
+} |
+ |
+void PersistentAsyncEvent::RecordStartEventWithOffset(double offset) { |
+ TRACE_EVENT0("media", "PersistentAsyncStartOffset"); |
+} |
+ |
+void PersistentAsyncEvent::RecordStopEvent() { |
+ TRACE_EVENT0("media", "PersistentAsyncStop"); |
+} |
+ |
+void PersistentAsyncEvent::OnTraceLogEnabled() { |
+ if (active_) |
benjhayden
2016/08/10 18:30:00
braces should go on the same line
|
+ { |
+ timeval finish_time; |
+ gettimeofday(&finish_time, 0); |
+ double offset = (start_time_.tv_sec - finish_time.tv_sec) + 0.000001*(start_time_.tv_usec - finish_time.tv_usec); |
+ RecordStartEventWithOffset(offset); |
+ } |
+} |
+ |
+void PersistentAsyncEvent::OnTraceLogDisabled() { |
+ // TODO: how to get this to go off before the trace log gets disabled |
+ if (active_) |
+ { |
+ RecordStopEvent(); |
+ } |
+} |
+ |
+} |
benjhayden
2016/08/10 18:30:00
} // namespace trace_event
|
+} |