OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/trace_event/blame_context.h" | 5 #include "base/trace_event/blame_context.h" |
6 | 6 |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
9 #include "base/trace_event/trace_event_argument.h" | 9 #include "base/trace_event/trace_event_argument.h" |
10 | 10 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 void BlameContext::Leave() { | 48 void BlameContext::Leave() { |
49 DCHECK(WasInitialized()); | 49 DCHECK(WasInitialized()); |
50 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_LEAVE_CONTEXT, | 50 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_LEAVE_CONTEXT, |
51 category_group_enabled_, name_, scope_, id_, | 51 category_group_enabled_, name_, scope_, id_, |
52 0 /* num_args */, nullptr, nullptr, nullptr, | 52 0 /* num_args */, nullptr, nullptr, nullptr, |
53 nullptr, TRACE_EVENT_FLAG_HAS_ID); | 53 nullptr, TRACE_EVENT_FLAG_HAS_ID); |
54 } | 54 } |
55 | 55 |
56 void BlameContext::TakeSnapshot() { | 56 void BlameContext::TakeSnapshot() { |
57 DCHECK(WasInitialized()); | 57 DCHECK(WasInitialized()); |
58 if (!*category_group_enabled_) | 58 if (!(*category_group_enabled_ & TraceLog::ENABLED_FOR_NON_PROFILING_MODE)) |
59 return; | 59 return; |
60 scoped_ptr<trace_event::TracedValue> snapshot(new trace_event::TracedValue); | 60 scoped_ptr<trace_event::TracedValue> snapshot(new trace_event::TracedValue); |
61 AsValueInto(snapshot.get()); | 61 AsValueInto(snapshot.get()); |
62 static const char* kArgName = "snapshot"; | 62 static const char* kArgName = "snapshot"; |
63 const int kNumArgs = 1; | 63 const int kNumArgs = 1; |
64 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; | 64 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
65 scoped_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = { | 65 scoped_ptr<trace_event::ConvertableToTraceFormat> arg_values[1] = { |
66 std::move(snapshot)}; | 66 std::move(snapshot)}; |
67 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, | 67 TRACE_EVENT_API_ADD_TRACE_EVENT(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, |
68 category_group_enabled_, type_, scope_, id_, | 68 category_group_enabled_, type_, scope_, id_, |
(...skipping 27 matching lines...) Expand all Loading... |
96 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); | 96 trace_event::TraceLog::GetInstance()->AddEnabledStateObserver(this); |
97 TakeSnapshot(); | 97 TakeSnapshot(); |
98 } | 98 } |
99 | 99 |
100 bool BlameContext::WasInitialized() const { | 100 bool BlameContext::WasInitialized() const { |
101 return category_group_enabled_ != nullptr; | 101 return category_group_enabled_ != nullptr; |
102 } | 102 } |
103 | 103 |
104 } // namespace trace_event | 104 } // namespace trace_event |
105 } // namespace base | 105 } // namespace base |
OLD | NEW |