Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: base/trace_event/persistent_async_event.cc

Issue 2159323002: Add tracing AutoOpenCloseEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: implement new design Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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(
16 const char* category, const char* event_name): active_(false),
benjhayden 2016/09/14 01:03:33 active_(false) should go on the next line.
alexandermont 2016/09/14 20:14:56 Done
17 id_(static_cast<void*>(this)),
benjhayden 2016/09/14 01:03:33 I thought you were going to take the VFC* in the c
Primiano Tucci (use gerrit) 2016/09/14 09:38:53 RIght. as this code is right now, this id_ field s
alexandermont 2016/09/14 20:14:56 Done
18 category_(category),
19 event_name_(event_name) {
20 base::trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this);
21 }
22
23 PersistentAsyncEvent::~PersistentAsyncEvent() {
24 base::trace_event::TraceLog::GetInstance()->RemoveEnabledStateObserver(this);
Primiano Tucci (use gerrit) 2016/09/14 09:38:53 You cannot use the standard EnabledStateObserver f
alexandermont 2016/09/14 20:14:56 Done
25 }
26
27 void PersistentAsyncEvent::Begin() {
28 TRACE_EVENT_COPY_ASYNC_BEGIN0(category_, event_name_, id_);
Primiano Tucci (use gerrit) 2016/09/14 09:38:53 Why _COPY_? Aren't the argument supposed to be lon
alexandermont 2016/09/14 20:14:56 Done
29 active_ = true;
30 start_time_ = base::TimeTicks::Now();
31 }
32
33 void PersistentAsyncEvent::End() {
34 TRACE_EVENT_COPY_ASYNC_END0(category_, event_name_, id_);
35 active_ = false;
36 }
37
38 void PersistentAsyncEvent::OnTraceLogEnabled() {
39 if (active_)
40 TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(
41 category_, event_name_, id_, start_time_.ToInternalValue());
42 }
43
44 void PersistentAsyncEvent::OnTraceLogDisabled() {
45 // TODO(alexandermont): How do we call RecordStopEvent before log disabled?
benjhayden 2016/09/14 01:03:33 Wait for this CL to land then use OnBeforeTraceLog
46 if (active_)
47 TRACE_EVENT_COPY_ASYNC_END0(category_, event_name_, id_);
Primiano Tucci (use gerrit) 2016/09/14 09:38:53 This one doesn't work, it's too late to add events
alexandermont 2016/09/14 20:14:56 Will hold off until we decide whether we are in fa
48 }
49
50 } // namespace trace_event
51 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698