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 // test | |
charliea (OOO until 10-5)
2016/08/29 17:27:27
Huh?
alexandermont
2016/08/29 18:59:06
Deleted. I don't remember why i put this comment t
| |
12 | |
13 namespace base { | |
charliea (OOO until 10-5)
2016/08/29 17:27:27
As strange as it seems, I think there's normall a
alexandermont
2016/08/29 18:59:06
Done
| |
14 namespace trace_event { | |
15 | |
16 PersistentAsyncEvent::PersistentAsyncEvent(size_t id) | |
17 : id_(id), active_(false) {} | |
18 | |
19 PersistentAsyncEvent::~PersistentAsyncEvent() {} | |
20 | |
21 void PersistentAsyncEvent::Start() { | |
22 RecordStartEvent(); | |
23 active_ = true; | |
24 start_time_ = base::TimeTicks::Now().ToInternalValue(); | |
charliea (OOO until 10-5)
2016/08/29 17:27:27
Generally, if you ever find yourself using "ToInte
alexandermont
2016/08/29 18:59:06
The TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0 macro
| |
25 } | |
26 | |
27 void PersistentAsyncEvent::Stop() { | |
28 RecordStopEvent(); | |
29 active_ = false; | |
30 } | |
31 | |
32 void PersistentAsyncEvent::RecordStartEvent() { | |
33 TRACE_EVENT_ASYNC_BEGIN0("benchmark", "PersistentAsyncStart", id_); | |
34 } | |
35 | |
36 void PersistentAsyncEvent::RecordStartEventWithTimestamp(int64_t timestamp) { | |
37 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0( | |
38 "benchmark", "PersistentAsyncStart", id_, timestamp); | |
39 } | |
40 | |
41 void PersistentAsyncEvent::RecordStopEvent() { | |
42 TRACE_EVENT_ASYNC_END0("benchmark", "PersistentAsyncStop", id_); | |
43 } | |
44 | |
45 void PersistentAsyncEvent::OnTraceLogEnabled() { | |
46 if (active_) | |
47 { | |
48 RecordStartEventWithTimestamp(start_time_); | |
49 } | |
50 } | |
51 | |
52 void PersistentAsyncEvent::OnTraceLogDisabled() { | |
53 // TODO(alexandermont): How do we call RecordStopEvent before log disabled? | |
54 if (active_) | |
55 { | |
56 RecordStopEvent(); | |
57 } | |
58 } | |
59 | |
60 } | |
61 } | |
OLD | NEW |