OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/trace_log.h" | 5 #include "base/trace_event/trace_log.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. | 82 // ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events. |
83 const size_t kEchoToConsoleTraceEventBufferChunks = 256; | 83 const size_t kEchoToConsoleTraceEventBufferChunks = 256; |
84 | 84 |
85 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; | 85 const size_t kTraceEventBufferSizeInBytes = 100 * 1024; |
86 const int kThreadFlushTimeoutMs = 3000; | 86 const int kThreadFlushTimeoutMs = 3000; |
87 | 87 |
88 #define MAX_TRACE_EVENT_FILTERS 32 | 88 #define MAX_TRACE_EVENT_FILTERS 32 |
89 | 89 |
90 // List of TraceEventFilter objects from the most recent tracing session. | 90 // List of TraceEventFilter objects from the most recent tracing session. |
91 std::vector<std::unique_ptr<TraceEventFilter>>& GetCategoryGroupFilters() { | 91 std::vector<std::unique_ptr<TraceEventFilter>>& GetCategoryGroupFilters() { |
92 static auto filters = new std::vector<std::unique_ptr<TraceEventFilter>>(); | 92 static auto* filters = new std::vector<std::unique_ptr<TraceEventFilter>>(); |
93 return *filters; | 93 return *filters; |
94 } | 94 } |
95 | 95 |
96 ThreadTicks ThreadNow() { | 96 ThreadTicks ThreadNow() { |
97 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); | 97 return ThreadTicks::IsSupported() ? ThreadTicks::Now() : ThreadTicks(); |
98 } | 98 } |
99 | 99 |
100 template <typename T> | 100 template <typename T> |
101 void InitializeMetadataEvent(TraceEvent* trace_event, | 101 void InitializeMetadataEvent(TraceEvent* trace_event, |
102 int thread_id, | 102 int thread_id, |
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 | 1212 |
1213 // Check and update the current thread name only if the event is for the | 1213 // Check and update the current thread name only if the event is for the |
1214 // current thread to avoid locks in most cases. | 1214 // current thread to avoid locks in most cases. |
1215 if (thread_id == static_cast<int>(PlatformThread::CurrentId())) { | 1215 if (thread_id == static_cast<int>(PlatformThread::CurrentId())) { |
1216 const char* new_name = | 1216 const char* new_name = |
1217 ThreadIdNameManager::GetInstance()->GetName(thread_id); | 1217 ThreadIdNameManager::GetInstance()->GetName(thread_id); |
1218 // Check if the thread name has been set or changed since the previous | 1218 // Check if the thread name has been set or changed since the previous |
1219 // call (if any), but don't bother if the new name is empty. Note this will | 1219 // call (if any), but don't bother if the new name is empty. Note this will |
1220 // not detect a thread name change within the same char* buffer address: we | 1220 // not detect a thread name change within the same char* buffer address: we |
1221 // favor common case performance over corner case correctness. | 1221 // favor common case performance over corner case correctness. |
1222 static auto current_thread_name = new ThreadLocalPointer<const char>(); | 1222 static auto* current_thread_name = new ThreadLocalPointer<const char>(); |
1223 if (new_name != current_thread_name->Get() && new_name && *new_name) { | 1223 if (new_name != current_thread_name->Get() && new_name && *new_name) { |
1224 current_thread_name->Set(new_name); | 1224 current_thread_name->Set(new_name); |
1225 | 1225 |
1226 AutoLock thread_info_lock(thread_info_lock_); | 1226 AutoLock thread_info_lock(thread_info_lock_); |
1227 | 1227 |
1228 hash_map<int, std::string>::iterator existing_name = | 1228 hash_map<int, std::string>::iterator existing_name = |
1229 thread_names_.find(thread_id); | 1229 thread_names_.find(thread_id); |
1230 if (existing_name == thread_names_.end()) { | 1230 if (existing_name == thread_names_.end()) { |
1231 // This is a new thread id, and a new name. | 1231 // This is a new thread id, and a new name. |
1232 thread_names_[thread_id] = new_name; | 1232 thread_names_[thread_id] = new_name; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1721 } | 1721 } |
1722 | 1722 |
1723 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1723 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
1724 if (*category_group_enabled_) { | 1724 if (*category_group_enabled_) { |
1725 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1725 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
1726 event_handle_); | 1726 event_handle_); |
1727 } | 1727 } |
1728 } | 1728 } |
1729 | 1729 |
1730 } // namespace trace_event_internal | 1730 } // namespace trace_event_internal |
OLD | NEW |