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 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this); | |
22 } | |
23 | |
24 void PersistentAsyncEvent::Start() { | |
25 RecordStartEvent(); | |
26 active_ = true; | |
27 start_time_ = base::TimeTicks::Now().ToInternalValue(); | |
28 } | |
29 | |
30 void PersistentAsyncEvent::Stop() { | |
31 RecordStopEvent(); | |
32 active_ = false; | |
33 } | |
34 | |
35 void PersistentAsyncEvent::OnTraceLogEnabled() { | |
36 if (active_) { | |
charliea (OOO until 10-5)
2016/08/31 17:30:38
Looks like it's okay to leave off the brace for on
alexandermont
2016/08/31 18:31:59
Done
| |
37 RecordStartEventWithTimestamp(start_time_); | |
38 } | |
39 } | |
40 | |
41 void PersistentAsyncEvent::OnTraceLogDisabled() { | |
42 // TODO(alexandermont): How do we call RecordStopEvent before log disabled? | |
43 if (active_) { | |
44 RecordStopEvent(); | |
45 } | |
46 } | |
47 | |
48 } // namespace trace_event | |
49 } // namespace base | |
OLD | NEW |