Chromium Code Reviews| 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 | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
nit: remove this extra line
alexandermont
2016/09/15 21:05:12
Done
| |
| 13 namespace trace_event { | |
| 14 | |
| 15 PersistentAsyncEvent::PersistentAsyncEvent(PersistentAsyncEvent::Type type, | |
| 16 const char* category, const char* event_name): | |
| 17 active_(false), | |
| 18 category_(category), | |
| 19 event_name_(event_name), | |
| 20 weak_factory_(this) { | |
| 21 DCHECK(thread_checker_.CalledOnValidThread()); | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
remove this line, as it is tautological.
The threa
alexandermont
2016/09/15 21:05:13
Done
| |
| 22 base::trace_event::TraceLog::GetInstance()->AddAsyncEnabledStateObserver( | |
| 23 weak_factory_.GetWeakPtr()); | |
| 24 } | |
| 25 | |
| 26 PersistentAsyncEvent::~PersistentAsyncEvent() { | |
| 27 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 28 base::trace_event::TraceLog::GetInstance()->RemoveAsyncEnabledStateObserver( | |
| 29 this); | |
| 30 } | |
| 31 | |
| 32 void PersistentAsyncEvent::Begin() { | |
| 33 DCHECK(thread_checker_.CalledOnValidThread()); | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
oh I didn't think about enforce begin/end to be al
alexandermont
2016/09/15 21:05:13
okay
| |
| 34 // We need to use the COPY version of the macro because the category and | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
nit: add a line between comments and the previous
| |
| 35 // event names aren't string literals; they're passed in through | |
| 36 // the constructor. | |
| 37 TRACE_EVENT_COPY_ASYNC_BEGIN0(category_, event_name_, | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
I dupe my previou (unresolved) question:
Why _COPY
alexandermont
2016/09/15 21:05:13
Fixed
| |
| 38 static_cast<void*>(this)); | |
| 39 active_ = true; | |
| 40 start_time_ = base::TimeTicks::Now(); | |
| 41 } | |
| 42 | |
| 43 void PersistentAsyncEvent::End() { | |
| 44 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 45 TRACE_EVENT_COPY_ASYNC_END0(category_, event_name_, static_cast<void*>(this)); | |
| 46 active_ = false; | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
just clear start_Time_?
alexandermont
2016/09/15 21:05:13
Done
| |
| 47 } | |
| 48 | |
| 49 void PersistentAsyncEvent::OnTraceLogEnabled() { | |
| 50 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 51 if (active_) | |
| 52 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0( | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
ditto about s/_COPY_//
| |
| 53 category_, event_name_, static_cast<void*>(this), | |
| 54 start_time_.ToInternalValue()); | |
|
Primiano Tucci (use gerrit)
2016/09/15 10:08:29
I think here you want InMicroseconds() not ToInter
alexandermont
2016/09/15 21:05:12
This is a TimeTicks value, not a TimeDelta value.
Primiano Tucci (use gerrit)
2016/09/15 22:06:25
ah right, my bad. do whatever we do for the other
| |
| 55 } | |
| 56 | |
| 57 void PersistentAsyncEvent::OnTraceLogDisabled() {} | |
| 58 | |
| 59 } // namespace trace_event | |
| 60 } // namespace base | |
| OLD | NEW |