OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/debug/trace_event.h" | 5 #include "base/debug/trace_event.h" |
6 | 6 |
7 namespace trace_event_internal { | 7 namespace trace_event_internal { |
8 | 8 |
9 void TraceEndOnScopeClose::Initialize(const unsigned char* category_enabled, | 9 void TraceEndOnScopeClose::Initialize(const unsigned char* category_enabled, |
10 const char* name) { | 10 const char* name) { |
11 data_.category_enabled = category_enabled; | 11 data_.category_enabled = category_enabled; |
12 data_.name = name; | 12 data_.name = name; |
13 p_data_ = &data_; | 13 p_data_ = &data_; |
14 } | 14 } |
15 | 15 |
16 void TraceEndOnScopeClose::AddEventIfEnabled() { | 16 void TraceEndOnScopeClose::AddEventIfEnabled() { |
17 // Only called when p_data_ is non-null. | 17 // Only called when p_data_ is non-null. |
18 if (*p_data_->category_enabled) { | 18 if (TRACE_EVENT_API_IS_ATRACE_ENABLED() || *p_data_->category_enabled) { |
19 TRACE_EVENT_API_ADD_TRACE_EVENT( | 19 TRACE_EVENT_API_ADD_TRACE_EVENT( |
20 TRACE_EVENT_PHASE_END, | 20 TRACE_EVENT_PHASE_END, |
21 p_data_->category_enabled, | 21 p_data_->category_enabled, |
22 p_data_->name, kNoEventId, | 22 p_data_->name, kNoEventId, |
23 kZeroNumArgs, NULL, NULL, NULL, | 23 kZeroNumArgs, NULL, NULL, NULL, |
24 kNoThreshholdBeginId, kNoThresholdValue, TRACE_EVENT_FLAG_NONE); | 24 kNoThreshholdBeginId, kNoThresholdValue, TRACE_EVENT_FLAG_NONE); |
25 } | 25 } |
26 } | 26 } |
27 | 27 |
28 void TraceEndOnScopeCloseThreshold::Initialize( | 28 void TraceEndOnScopeCloseThreshold::Initialize( |
29 const unsigned char* category_enabled, | 29 const unsigned char* category_enabled, |
30 const char* name, | 30 const char* name, |
31 int threshold_begin_id, | 31 int threshold_begin_id, |
32 long long threshold) { | 32 long long threshold) { |
33 data_.category_enabled = category_enabled; | 33 data_.category_enabled = category_enabled; |
34 data_.name = name; | 34 data_.name = name; |
35 data_.threshold_begin_id = threshold_begin_id; | 35 data_.threshold_begin_id = threshold_begin_id; |
36 data_.threshold = threshold; | 36 data_.threshold = threshold; |
37 p_data_ = &data_; | 37 p_data_ = &data_; |
38 } | 38 } |
39 | 39 |
40 void TraceEndOnScopeCloseThreshold::AddEventIfEnabled() { | 40 void TraceEndOnScopeCloseThreshold::AddEventIfEnabled() { |
41 // Only called when p_data_ is non-null. | 41 // Only called when p_data_ is non-null. |
42 if (*p_data_->category_enabled) { | 42 if (TRACE_EVENT_API_IS_ATRACE_ENABLED() || *p_data_->category_enabled) { |
43 TRACE_EVENT_API_ADD_TRACE_EVENT( | 43 TRACE_EVENT_API_ADD_TRACE_EVENT( |
44 TRACE_EVENT_PHASE_END, | 44 TRACE_EVENT_PHASE_END, |
45 p_data_->category_enabled, | 45 p_data_->category_enabled, |
46 p_data_->name, kNoEventId, | 46 p_data_->name, kNoEventId, |
47 kZeroNumArgs, NULL, NULL, NULL, | 47 kZeroNumArgs, NULL, NULL, NULL, |
48 p_data_->threshold_begin_id, p_data_->threshold, | 48 p_data_->threshold_begin_id, p_data_->threshold, |
49 TRACE_EVENT_FLAG_NONE); | 49 TRACE_EVENT_FLAG_NONE); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 } // namespace trace_event_internal | 53 } // namespace trace_event_internal |
OLD | NEW |