| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/trace_event/persistent_async_event.h" |
| 6 |
| 7 #include "base/macros.h" |
| 8 #include "base/time/time.h" |
| 9 #include "base/trace_event/trace_event.h" |
| 10 |
| 11 namespace base { |
| 12 |
| 13 namespace trace_event { |
| 14 |
| 15 PersistentAsyncEvent::PersistentAsyncEvent() : active_(false) { |
| 16 id_ = static_cast<void*>(this); |
| 17 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); |
| 18 } |
| 19 |
| 20 PersistentAsyncEvent::~PersistentAsyncEvent() {} |
| 21 |
| 22 void PersistentAsyncEvent::Start() { |
| 23 RecordStartEvent(); |
| 24 active_ = true; |
| 25 start_time_ = base::TimeTicks::Now().ToInternalValue(); |
| 26 } |
| 27 |
| 28 void PersistentAsyncEvent::Stop() { |
| 29 RecordStopEvent(); |
| 30 active_ = false; |
| 31 } |
| 32 |
| 33 void PersistentAsyncEvent::OnTraceLogEnabled() { |
| 34 if (active_) { |
| 35 RecordStartEventWithTimestamp(start_time_); |
| 36 } |
| 37 } |
| 38 |
| 39 void PersistentAsyncEvent::OnTraceLogDisabled() { |
| 40 // TODO(alexandermont): How do we call RecordStopEvent before log disabled? |
| 41 if (active_) { |
| 42 RecordStopEvent(); |
| 43 } |
| 44 } |
| 45 |
| 46 } // namespace trace_event |
| 47 } // namespace base |
| OLD | NEW |