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

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: code review changes 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() : 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::Begin() {
25 RecordBeginEvent();
26 active_ = true;
27 start_time_ = base::TimeTicks::Now();
28 }
29
30 void PersistentAsyncEvent::End() {
31 RecordEndEvent();
32 active_ = false;
33 }
34
35 void PersistentAsyncEvent::OnTraceLogEnabled() {
36 if (active_)
37 RecordBeginEventWithTimestamp(start_time_);
38 }
39
40 void PersistentAsyncEvent::OnTraceLogDisabled() {
fmeawad 2016/09/02 19:43:25 I think we decided that we are going to leave the
benjhayden 2016/09/02 20:57:45 Fadi, the latest patch changes TraceLog::SetDisabl
41 // TODO(alexandermont): How do we call RecordStopEvent before log disabled?
42 if (active_)
43 RecordEndEvent();
44 }
45
46 } // namespace trace_event
47 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698