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

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: Created 4 years, 5 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/macros.h"
6 #include "base/trace_event/trace_event.h"
7 #include "base/trace_event/persistent_async_event.h"
8 #include <string>
9 #include <ctime>
10
11 // test
12
13 namespace base {
14 namespace trace_event {
15
16 PersistentAsyncEvent::PersistentAsyncEvent()
17 : active_(false) {}
18
19 PersistentAsyncEvent::~PersistentAsyncEvent() {}
20
21 void PersistentAsyncEvent::Start(std::string param_value) {
22 param_value_ = param_value;
23 RecordStartEvent();
24 active_ = true;
25 gettimeofday(&start_time_, 0);
benjhayden 2016/08/10 18:30:00 charliea can help you figure out what function to
26 }
27
28 void PersistentAsyncEvent::Stop(std::string param_value) {
29 param_value_ = param_value;
30 RecordStopEvent();
31 active_ = false;
32 }
33
34 void PersistentAsyncEvent::RecordStartEvent() {
35 TRACE_EVENT0("media", "PersistentAsyncStart");
36 }
37
38 void PersistentAsyncEvent::RecordStartEventWithOffset(double offset) {
39 TRACE_EVENT0("media", "PersistentAsyncStartOffset");
40 }
41
42 void PersistentAsyncEvent::RecordStopEvent() {
43 TRACE_EVENT0("media", "PersistentAsyncStop");
44 }
45
46 void PersistentAsyncEvent::OnTraceLogEnabled() {
47 if (active_)
benjhayden 2016/08/10 18:30:00 braces should go on the same line
48 {
49 timeval finish_time;
50 gettimeofday(&finish_time, 0);
51 double offset = (start_time_.tv_sec - finish_time.tv_sec) + 0.00 0001*(start_time_.tv_usec - finish_time.tv_usec);
52 RecordStartEventWithOffset(offset);
53 }
54 }
55
56 void PersistentAsyncEvent::OnTraceLogDisabled() {
57 // TODO: how to get this to go off before the trace log gets disabled
58 if (active_)
59 {
60 RecordStopEvent();
61 }
62 }
63
64 }
benjhayden 2016/08/10 18:30:00 } // namespace trace_event
65 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698