| 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_impl.h" | 5 #include "base/debug/trace_event_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 const int g_category_trace_event_overhead = 3; | 92 const int g_category_trace_event_overhead = 3; |
| 93 const int g_num_builtin_categories = 4; | 93 const int g_num_builtin_categories = 4; |
| 94 int g_category_index = g_num_builtin_categories; // Skip default categories. | 94 int g_category_index = g_num_builtin_categories; // Skip default categories. |
| 95 | 95 |
| 96 // The name of the current thread. This is used to decide if the current | 96 // The name of the current thread. This is used to decide if the current |
| 97 // thread name has changed. We combine all the seen thread names into the | 97 // thread name has changed. We combine all the seen thread names into the |
| 98 // output name for the thread. | 98 // output name for the thread. |
| 99 LazyInstance<ThreadLocalPointer<const char> >::Leaky | 99 LazyInstance<ThreadLocalPointer<const char> >::Leaky |
| 100 g_current_thread_name = LAZY_INSTANCE_INITIALIZER; | 100 g_current_thread_name = LAZY_INSTANCE_INITIALIZER; |
| 101 | 101 |
| 102 const char kRecordUntilFull[] = "record-until-full"; | |
| 103 const char kRecordContinuously[] = "record-continuously"; | |
| 104 const char kEnableSampling[] = "enable-sampling"; | |
| 105 const char kMonitorSampling[] = "monitor-sampling"; | |
| 106 | |
| 107 TimeTicks ThreadNow() { | 102 TimeTicks ThreadNow() { |
| 108 return TimeTicks::IsThreadNowSupported() ? | 103 return TimeTicks::IsThreadNowSupported() ? |
| 109 TimeTicks::ThreadNow() : TimeTicks(); | 104 TimeTicks::ThreadNow() : TimeTicks(); |
| 110 } | 105 } |
| 111 | 106 |
| 112 class TraceBufferRingBuffer : public TraceBuffer { | 107 class TraceBufferRingBuffer : public TraceBuffer { |
| 113 public: | 108 public: |
| 114 TraceBufferRingBuffer(size_t max_chunks) | 109 TraceBufferRingBuffer(size_t max_chunks) |
| 115 : max_chunks_(max_chunks), | 110 : max_chunks_(max_chunks), |
| 116 recyclable_chunks_queue_(new size_t[queue_capacity()]), | 111 recyclable_chunks_queue_(new size_t[queue_capacity()]), |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 // TraceLog | 932 // TraceLog |
| 938 // | 933 // |
| 939 //////////////////////////////////////////////////////////////////////////////// | 934 //////////////////////////////////////////////////////////////////////////////// |
| 940 | 935 |
| 941 class TraceLog::ThreadLocalEventBuffer | 936 class TraceLog::ThreadLocalEventBuffer |
| 942 : public MessageLoop::DestructionObserver { | 937 : public MessageLoop::DestructionObserver { |
| 943 public: | 938 public: |
| 944 ThreadLocalEventBuffer(TraceLog* trace_log); | 939 ThreadLocalEventBuffer(TraceLog* trace_log); |
| 945 virtual ~ThreadLocalEventBuffer(); | 940 virtual ~ThreadLocalEventBuffer(); |
| 946 | 941 |
| 947 TraceEvent* AddTraceEvent(NotificationHelper* notifier, | 942 TraceEvent* AddTraceEvent(TraceEventHandle* handle); |
| 948 TraceEventHandle* handle); | |
| 949 | 943 |
| 950 void ReportOverhead(const TimeTicks& event_timestamp, | 944 void ReportOverhead(const TimeTicks& event_timestamp, |
| 951 const TimeTicks& event_thread_timestamp, | 945 const TimeTicks& event_thread_timestamp); |
| 952 NotificationHelper* notifier); | |
| 953 | 946 |
| 954 TraceEvent* GetEventByHandle(TraceEventHandle handle) { | 947 TraceEvent* GetEventByHandle(TraceEventHandle handle) { |
| 955 if (!chunk_ || handle.chunk_seq != chunk_->seq() || | 948 if (!chunk_ || handle.chunk_seq != chunk_->seq() || |
| 956 handle.chunk_index != chunk_index_) | 949 handle.chunk_index != chunk_index_) |
| 957 return NULL; | 950 return NULL; |
| 958 | 951 |
| 959 return chunk_->GetEventAt(handle.event_index); | 952 return chunk_->GetEventAt(handle.event_index); |
| 960 } | 953 } |
| 961 | 954 |
| 962 int generation() const { return generation_; } | 955 int generation() const { return generation_; } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 999 | 992 |
| 1000 TraceLog::ThreadLocalEventBuffer::~ThreadLocalEventBuffer() { | 993 TraceLog::ThreadLocalEventBuffer::~ThreadLocalEventBuffer() { |
| 1001 CheckThisIsCurrentBuffer(); | 994 CheckThisIsCurrentBuffer(); |
| 1002 MessageLoop::current()->RemoveDestructionObserver(this); | 995 MessageLoop::current()->RemoveDestructionObserver(this); |
| 1003 | 996 |
| 1004 // Zero event_count_ happens in either of the following cases: | 997 // Zero event_count_ happens in either of the following cases: |
| 1005 // - no event generated for the thread; | 998 // - no event generated for the thread; |
| 1006 // - the thread has no message loop; | 999 // - the thread has no message loop; |
| 1007 // - trace_event_overhead is disabled. | 1000 // - trace_event_overhead is disabled. |
| 1008 if (event_count_) { | 1001 if (event_count_) { |
| 1009 NotificationHelper notifier(trace_log_); | 1002 InitializeMetadataEvent(AddTraceEvent(NULL), |
| 1010 InitializeMetadataEvent(AddTraceEvent(¬ifier, NULL), | |
| 1011 static_cast<int>(base::PlatformThread::CurrentId()), | 1003 static_cast<int>(base::PlatformThread::CurrentId()), |
| 1012 "overhead", "average_overhead", | 1004 "overhead", "average_overhead", |
| 1013 overhead_.InMillisecondsF() / event_count_); | 1005 overhead_.InMillisecondsF() / event_count_); |
| 1014 notifier.SendNotificationIfAny(); | |
| 1015 } | 1006 } |
| 1016 | 1007 |
| 1017 { | 1008 { |
| 1018 AutoLock lock(trace_log_->lock_); | 1009 AutoLock lock(trace_log_->lock_); |
| 1019 FlushWhileLocked(); | 1010 FlushWhileLocked(); |
| 1020 trace_log_->thread_message_loops_.erase(MessageLoop::current()); | 1011 trace_log_->thread_message_loops_.erase(MessageLoop::current()); |
| 1021 } | 1012 } |
| 1022 trace_log_->thread_local_event_buffer_.Set(NULL); | 1013 trace_log_->thread_local_event_buffer_.Set(NULL); |
| 1023 } | 1014 } |
| 1024 | 1015 |
| 1025 TraceEvent* TraceLog::ThreadLocalEventBuffer::AddTraceEvent( | 1016 TraceEvent* TraceLog::ThreadLocalEventBuffer::AddTraceEvent( |
| 1026 NotificationHelper* notifier, | |
| 1027 TraceEventHandle* handle) { | 1017 TraceEventHandle* handle) { |
| 1028 CheckThisIsCurrentBuffer(); | 1018 CheckThisIsCurrentBuffer(); |
| 1029 | 1019 |
| 1030 if (chunk_ && chunk_->IsFull()) { | 1020 if (chunk_ && chunk_->IsFull()) { |
| 1031 AutoLock lock(trace_log_->lock_); | 1021 AutoLock lock(trace_log_->lock_); |
| 1032 FlushWhileLocked(); | 1022 FlushWhileLocked(); |
| 1033 chunk_.reset(); | 1023 chunk_.reset(); |
| 1034 } | 1024 } |
| 1035 if (!chunk_) { | 1025 if (!chunk_) { |
| 1036 AutoLock lock(trace_log_->lock_); | 1026 AutoLock lock(trace_log_->lock_); |
| 1037 chunk_ = trace_log_->logged_events_->GetChunk(&chunk_index_); | 1027 chunk_ = trace_log_->logged_events_->GetChunk(&chunk_index_); |
| 1038 trace_log_->CheckIfBufferIsFullWhileLocked(notifier); | 1028 trace_log_->CheckIfBufferIsFullWhileLocked(); |
| 1039 } | 1029 } |
| 1040 if (!chunk_) | 1030 if (!chunk_) |
| 1041 return NULL; | 1031 return NULL; |
| 1042 | 1032 |
| 1043 size_t event_index; | 1033 size_t event_index; |
| 1044 TraceEvent* trace_event = chunk_->AddTraceEvent(&event_index); | 1034 TraceEvent* trace_event = chunk_->AddTraceEvent(&event_index); |
| 1045 if (trace_event && handle) | 1035 if (trace_event && handle) |
| 1046 MakeHandle(chunk_->seq(), chunk_index_, event_index, handle); | 1036 MakeHandle(chunk_->seq(), chunk_index_, event_index, handle); |
| 1047 | 1037 |
| 1048 return trace_event; | 1038 return trace_event; |
| 1049 } | 1039 } |
| 1050 | 1040 |
| 1051 void TraceLog::ThreadLocalEventBuffer::ReportOverhead( | 1041 void TraceLog::ThreadLocalEventBuffer::ReportOverhead( |
| 1052 const TimeTicks& event_timestamp, | 1042 const TimeTicks& event_timestamp, |
| 1053 const TimeTicks& event_thread_timestamp, | 1043 const TimeTicks& event_thread_timestamp) { |
| 1054 NotificationHelper* notifier) { | |
| 1055 if (!g_category_group_enabled[g_category_trace_event_overhead]) | 1044 if (!g_category_group_enabled[g_category_trace_event_overhead]) |
| 1056 return; | 1045 return; |
| 1057 | 1046 |
| 1058 CheckThisIsCurrentBuffer(); | 1047 CheckThisIsCurrentBuffer(); |
| 1059 | 1048 |
| 1060 event_count_++; | 1049 event_count_++; |
| 1061 TimeTicks now = trace_log_->OffsetNow(); | 1050 TimeTicks now = trace_log_->OffsetNow(); |
| 1062 TimeDelta overhead = now - event_timestamp; | 1051 TimeDelta overhead = now - event_timestamp; |
| 1063 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) { | 1052 if (overhead.InMicroseconds() >= kOverheadReportThresholdInMicroseconds) { |
| 1064 TraceEvent* trace_event = AddTraceEvent(notifier, NULL); | 1053 TraceEvent* trace_event = AddTraceEvent(NULL); |
| 1065 if (trace_event) { | 1054 if (trace_event) { |
| 1066 trace_event->Initialize( | 1055 trace_event->Initialize( |
| 1067 static_cast<int>(PlatformThread::CurrentId()), | 1056 static_cast<int>(PlatformThread::CurrentId()), |
| 1068 event_timestamp, event_thread_timestamp, | 1057 event_timestamp, event_thread_timestamp, |
| 1069 TRACE_EVENT_PHASE_COMPLETE, | 1058 TRACE_EVENT_PHASE_COMPLETE, |
| 1070 &g_category_group_enabled[g_category_trace_event_overhead], | 1059 &g_category_group_enabled[g_category_trace_event_overhead], |
| 1071 "overhead", 0, 0, NULL, NULL, NULL, NULL, 0); | 1060 "overhead", 0, 0, NULL, NULL, NULL, NULL, 0); |
| 1072 trace_event->UpdateDuration(now); | 1061 trace_event->UpdateDuration(now); |
| 1073 } | 1062 } |
| 1074 } | 1063 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1085 | 1074 |
| 1086 trace_log_->lock_.AssertAcquired(); | 1075 trace_log_->lock_.AssertAcquired(); |
| 1087 if (trace_log_->CheckGeneration(generation_)) { | 1076 if (trace_log_->CheckGeneration(generation_)) { |
| 1088 // Return the chunk to the buffer only if the generation matches, | 1077 // Return the chunk to the buffer only if the generation matches, |
| 1089 trace_log_->logged_events_->ReturnChunk(chunk_index_, chunk_.Pass()); | 1078 trace_log_->logged_events_->ReturnChunk(chunk_index_, chunk_.Pass()); |
| 1090 } | 1079 } |
| 1091 // Otherwise this method may be called from the destructor, or TraceLog will | 1080 // Otherwise this method may be called from the destructor, or TraceLog will |
| 1092 // find the generation mismatch and delete this buffer soon. | 1081 // find the generation mismatch and delete this buffer soon. |
| 1093 } | 1082 } |
| 1094 | 1083 |
| 1095 TraceLog::NotificationHelper::NotificationHelper(TraceLog* trace_log) | |
| 1096 : trace_log_(trace_log), | |
| 1097 notification_(0) { | |
| 1098 } | |
| 1099 | |
| 1100 TraceLog::NotificationHelper::~NotificationHelper() { | |
| 1101 } | |
| 1102 | |
| 1103 void TraceLog::NotificationHelper::AddNotificationWhileLocked( | |
| 1104 int notification) { | |
| 1105 trace_log_->lock_.AssertAcquired(); | |
| 1106 if (trace_log_->notification_callback_.is_null()) | |
| 1107 return; | |
| 1108 if (notification_ == 0) | |
| 1109 callback_copy_ = trace_log_->notification_callback_; | |
| 1110 notification_ |= notification; | |
| 1111 } | |
| 1112 | |
| 1113 void TraceLog::NotificationHelper::SendNotificationIfAny() { | |
| 1114 if (notification_) | |
| 1115 callback_copy_.Run(notification_); | |
| 1116 } | |
| 1117 | |
| 1118 // static | 1084 // static |
| 1119 TraceLog* TraceLog::GetInstance() { | 1085 TraceLog* TraceLog::GetInstance() { |
| 1120 return Singleton<TraceLog, LeakySingletonTraits<TraceLog> >::get(); | 1086 return Singleton<TraceLog, LeakySingletonTraits<TraceLog> >::get(); |
| 1121 } | 1087 } |
| 1122 | 1088 |
| 1123 // static | |
| 1124 // Note, if you add more options here you also need to update: | |
| 1125 // content/browser/devtools/devtools_tracing_handler:TraceOptionsFromString | |
| 1126 TraceLog::Options TraceLog::TraceOptionsFromString(const std::string& options) { | |
| 1127 std::vector<std::string> split; | |
| 1128 base::SplitString(options, ',', &split); | |
| 1129 int ret = 0; | |
| 1130 for (std::vector<std::string>::iterator iter = split.begin(); | |
| 1131 iter != split.end(); | |
| 1132 ++iter) { | |
| 1133 if (*iter == kRecordUntilFull) { | |
| 1134 ret |= RECORD_UNTIL_FULL; | |
| 1135 } else if (*iter == kRecordContinuously) { | |
| 1136 ret |= RECORD_CONTINUOUSLY; | |
| 1137 } else if (*iter == kEnableSampling) { | |
| 1138 ret |= ENABLE_SAMPLING; | |
| 1139 } else if (*iter == kMonitorSampling) { | |
| 1140 ret |= MONITOR_SAMPLING; | |
| 1141 } else { | |
| 1142 NOTREACHED(); // Unknown option provided. | |
| 1143 } | |
| 1144 } | |
| 1145 if (!(ret & RECORD_UNTIL_FULL) && !(ret & RECORD_CONTINUOUSLY)) | |
| 1146 ret |= RECORD_UNTIL_FULL; // Default when no options are specified. | |
| 1147 | |
| 1148 return static_cast<Options>(ret); | |
| 1149 } | |
| 1150 | |
| 1151 TraceLog::TraceLog() | 1089 TraceLog::TraceLog() |
| 1152 : enabled_(false), | 1090 : enabled_(false), |
| 1153 num_traces_recorded_(0), | 1091 num_traces_recorded_(0), |
| 1154 buffer_is_full_(0), | |
| 1155 event_callback_(0), | 1092 event_callback_(0), |
| 1156 dispatching_to_observer_list_(false), | 1093 dispatching_to_observer_list_(false), |
| 1157 process_sort_index_(0), | 1094 process_sort_index_(0), |
| 1158 process_id_hash_(0), | 1095 process_id_hash_(0), |
| 1159 process_id_(0), | 1096 process_id_(0), |
| 1160 watch_category_(0), | 1097 watch_category_(0), |
| 1161 trace_options_(RECORD_UNTIL_FULL), | 1098 trace_options_(RECORD_UNTIL_FULL), |
| 1162 sampling_thread_handle_(0), | 1099 sampling_thread_handle_(0), |
| 1163 category_filter_(CategoryFilter::kDefaultCategoryFilterString), | 1100 category_filter_(CategoryFilter::kDefaultCategoryFilterString), |
| 1164 event_callback_category_filter_( | 1101 event_callback_category_filter_( |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1321 "Cannot manipulate TraceLog::Enabled state from an observer."; | 1258 "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 1322 return; | 1259 return; |
| 1323 } | 1260 } |
| 1324 | 1261 |
| 1325 enabled_ = true; | 1262 enabled_ = true; |
| 1326 | 1263 |
| 1327 if (options != old_options) { | 1264 if (options != old_options) { |
| 1328 subtle::NoBarrier_Store(&trace_options_, options); | 1265 subtle::NoBarrier_Store(&trace_options_, options); |
| 1329 logged_events_.reset(CreateTraceBuffer()); | 1266 logged_events_.reset(CreateTraceBuffer()); |
| 1330 NextGeneration(); | 1267 NextGeneration(); |
| 1331 subtle::NoBarrier_Store(&buffer_is_full_, 0); | |
| 1332 } | 1268 } |
| 1333 | 1269 |
| 1334 num_traces_recorded_++; | 1270 num_traces_recorded_++; |
| 1335 | 1271 |
| 1336 category_filter_ = CategoryFilter(category_filter); | 1272 category_filter_ = CategoryFilter(category_filter); |
| 1337 UpdateCategoryGroupEnabledFlags(); | 1273 UpdateCategoryGroupEnabledFlags(); |
| 1338 | 1274 |
| 1339 if ((options & ENABLE_SAMPLING) || (options & MONITOR_SAMPLING)) { | 1275 if ((options & ENABLE_SAMPLING) || (options & MONITOR_SAMPLING)) { |
| 1340 sampling_thread_.reset(new TraceSamplingThread); | 1276 sampling_thread_.reset(new TraceSamplingThread); |
| 1341 sampling_thread_->RegisterSampleBucket( | 1277 sampling_thread_->RegisterSampleBucket( |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1368 dispatching_to_observer_list_ = false; | 1304 dispatching_to_observer_list_ = false; |
| 1369 } | 1305 } |
| 1370 } | 1306 } |
| 1371 | 1307 |
| 1372 CategoryFilter TraceLog::GetCurrentCategoryFilter() { | 1308 CategoryFilter TraceLog::GetCurrentCategoryFilter() { |
| 1373 AutoLock lock(lock_); | 1309 AutoLock lock(lock_); |
| 1374 return category_filter_; | 1310 return category_filter_; |
| 1375 } | 1311 } |
| 1376 | 1312 |
| 1377 void TraceLog::SetDisabled() { | 1313 void TraceLog::SetDisabled() { |
| 1378 std::vector<EnabledStateObserver*> observer_list; | 1314 AutoLock lock(lock_); |
| 1379 { | 1315 SetDisabledWhileLocked(); |
| 1380 AutoLock lock(lock_); | 1316 } |
| 1381 if (!enabled_) | |
| 1382 return; | |
| 1383 | 1317 |
| 1384 if (dispatching_to_observer_list_) { | 1318 void TraceLog::SetDisabledWhileLocked() { |
| 1385 DLOG(ERROR) | 1319 lock_.AssertAcquired(); |
| 1386 << "Cannot manipulate TraceLog::Enabled state from an observer."; | |
| 1387 return; | |
| 1388 } | |
| 1389 | 1320 |
| 1390 enabled_ = false; | 1321 if (!enabled_) |
| 1322 return; |
| 1391 | 1323 |
| 1392 if (sampling_thread_.get()) { | 1324 if (dispatching_to_observer_list_) { |
| 1393 // Stop the sampling thread. | 1325 DLOG(ERROR) |
| 1394 sampling_thread_->Stop(); | 1326 << "Cannot manipulate TraceLog::Enabled state from an observer."; |
| 1395 lock_.Release(); | 1327 return; |
| 1396 PlatformThread::Join(sampling_thread_handle_); | |
| 1397 lock_.Acquire(); | |
| 1398 sampling_thread_handle_ = PlatformThreadHandle(); | |
| 1399 sampling_thread_.reset(); | |
| 1400 } | |
| 1401 | |
| 1402 category_filter_.Clear(); | |
| 1403 subtle::NoBarrier_Store(&watch_category_, 0); | |
| 1404 watch_event_name_ = ""; | |
| 1405 UpdateCategoryGroupEnabledFlags(); | |
| 1406 AddMetadataEventsWhileLocked(); | |
| 1407 | |
| 1408 dispatching_to_observer_list_ = true; | |
| 1409 observer_list = enabled_state_observer_list_; | |
| 1410 } | 1328 } |
| 1411 | 1329 |
| 1412 // Dispatch to observers outside the lock in case the observer triggers a | 1330 enabled_ = false; |
| 1413 // trace event. | 1331 |
| 1414 for (size_t i = 0; i < observer_list.size(); ++i) | 1332 if (sampling_thread_.get()) { |
| 1415 observer_list[i]->OnTraceLogDisabled(); | 1333 // Stop the sampling thread. |
| 1334 sampling_thread_->Stop(); |
| 1335 lock_.Release(); |
| 1336 PlatformThread::Join(sampling_thread_handle_); |
| 1337 lock_.Acquire(); |
| 1338 sampling_thread_handle_ = PlatformThreadHandle(); |
| 1339 sampling_thread_.reset(); |
| 1340 } |
| 1341 |
| 1342 category_filter_.Clear(); |
| 1343 subtle::NoBarrier_Store(&watch_category_, 0); |
| 1344 watch_event_name_ = ""; |
| 1345 UpdateCategoryGroupEnabledFlags(); |
| 1346 AddMetadataEventsWhileLocked(); |
| 1347 |
| 1348 dispatching_to_observer_list_ = true; |
| 1349 std::vector<EnabledStateObserver*> observer_list = |
| 1350 enabled_state_observer_list_; |
| 1416 | 1351 |
| 1417 { | 1352 { |
| 1418 AutoLock lock(lock_); | 1353 // Dispatch to observers outside the lock in case the observer triggers a |
| 1419 dispatching_to_observer_list_ = false; | 1354 // trace event. |
| 1355 AutoUnlock unlock(lock_); |
| 1356 for (size_t i = 0; i < observer_list.size(); ++i) |
| 1357 observer_list[i]->OnTraceLogDisabled(); |
| 1420 } | 1358 } |
| 1359 dispatching_to_observer_list_ = false; |
| 1421 } | 1360 } |
| 1422 | 1361 |
| 1423 int TraceLog::GetNumTracesRecorded() { | 1362 int TraceLog::GetNumTracesRecorded() { |
| 1424 AutoLock lock(lock_); | 1363 AutoLock lock(lock_); |
| 1425 if (!enabled_) | 1364 if (!enabled_) |
| 1426 return -1; | 1365 return -1; |
| 1427 return num_traces_recorded_; | 1366 return num_traces_recorded_; |
| 1428 } | 1367 } |
| 1429 | 1368 |
| 1430 void TraceLog::AddEnabledStateObserver(EnabledStateObserver* listener) { | 1369 void TraceLog::AddEnabledStateObserver(EnabledStateObserver* listener) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1442 | 1381 |
| 1443 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const { | 1382 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const { |
| 1444 std::vector<EnabledStateObserver*>::const_iterator it = | 1383 std::vector<EnabledStateObserver*>::const_iterator it = |
| 1445 std::find(enabled_state_observer_list_.begin(), | 1384 std::find(enabled_state_observer_list_.begin(), |
| 1446 enabled_state_observer_list_.end(), | 1385 enabled_state_observer_list_.end(), |
| 1447 listener); | 1386 listener); |
| 1448 return it != enabled_state_observer_list_.end(); | 1387 return it != enabled_state_observer_list_.end(); |
| 1449 } | 1388 } |
| 1450 | 1389 |
| 1451 float TraceLog::GetBufferPercentFull() const { | 1390 float TraceLog::GetBufferPercentFull() const { |
| 1391 AutoLock lock(lock_); |
| 1452 return static_cast<float>(static_cast<double>(logged_events_->Size()) / | 1392 return static_cast<float>(static_cast<double>(logged_events_->Size()) / |
| 1453 logged_events_->Capacity()); | 1393 logged_events_->Capacity()); |
| 1454 } | 1394 } |
| 1455 | 1395 |
| 1456 void TraceLog::SetNotificationCallback( | 1396 bool TraceLog::BufferIsFull() const { |
| 1457 const TraceLog::NotificationCallback& cb) { | |
| 1458 AutoLock lock(lock_); | 1397 AutoLock lock(lock_); |
| 1459 notification_callback_ = cb; | 1398 return logged_events_->IsFull(); |
| 1460 } | 1399 } |
| 1461 | 1400 |
| 1462 TraceBuffer* TraceLog::CreateTraceBuffer() { | 1401 TraceBuffer* TraceLog::CreateTraceBuffer() { |
| 1463 Options options = trace_options(); | 1402 Options options = trace_options(); |
| 1464 if (options & RECORD_CONTINUOUSLY) | 1403 if (options & RECORD_CONTINUOUSLY) |
| 1465 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks); | 1404 return new TraceBufferRingBuffer(kTraceEventRingBufferChunks); |
| 1466 else if (options & MONITOR_SAMPLING) | 1405 else if (options & MONITOR_SAMPLING) |
| 1467 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks); | 1406 return new TraceBufferRingBuffer(kMonitorTraceEventBufferChunks); |
| 1468 else if (options & ECHO_TO_CONSOLE) | 1407 else if (options & ECHO_TO_CONSOLE) |
| 1469 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks); | 1408 return new TraceBufferRingBuffer(kEchoToConsoleTraceEventBufferChunks); |
| 1470 return new TraceBufferVector(); | 1409 return new TraceBufferVector(); |
| 1471 } | 1410 } |
| 1472 | 1411 |
| 1473 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked( | 1412 TraceEvent* TraceLog::AddEventToThreadSharedChunkWhileLocked( |
| 1474 NotificationHelper* notifier, TraceEventHandle* handle) { | 1413 TraceEventHandle* handle, bool check_buffer_is_full) { |
| 1475 lock_.AssertAcquired(); | 1414 lock_.AssertAcquired(); |
| 1476 | 1415 |
| 1477 if (thread_shared_chunk_ && thread_shared_chunk_->IsFull()) { | 1416 if (thread_shared_chunk_ && thread_shared_chunk_->IsFull()) { |
| 1478 logged_events_->ReturnChunk(thread_shared_chunk_index_, | 1417 logged_events_->ReturnChunk(thread_shared_chunk_index_, |
| 1479 thread_shared_chunk_.Pass()); | 1418 thread_shared_chunk_.Pass()); |
| 1480 } | 1419 } |
| 1481 | 1420 |
| 1482 if (!thread_shared_chunk_) { | 1421 if (!thread_shared_chunk_) { |
| 1483 thread_shared_chunk_ = logged_events_->GetChunk( | 1422 thread_shared_chunk_ = logged_events_->GetChunk( |
| 1484 &thread_shared_chunk_index_); | 1423 &thread_shared_chunk_index_); |
| 1485 if (notifier) | 1424 if (check_buffer_is_full) |
| 1486 CheckIfBufferIsFullWhileLocked(notifier); | 1425 CheckIfBufferIsFullWhileLocked(); |
| 1487 } | 1426 } |
| 1488 if (!thread_shared_chunk_) | 1427 if (!thread_shared_chunk_) |
| 1489 return NULL; | 1428 return NULL; |
| 1490 | 1429 |
| 1491 size_t event_index; | 1430 size_t event_index; |
| 1492 TraceEvent* trace_event = thread_shared_chunk_->AddTraceEvent(&event_index); | 1431 TraceEvent* trace_event = thread_shared_chunk_->AddTraceEvent(&event_index); |
| 1493 if (trace_event && handle) { | 1432 if (trace_event && handle) { |
| 1494 MakeHandle(thread_shared_chunk_->seq(), thread_shared_chunk_index_, | 1433 MakeHandle(thread_shared_chunk_->seq(), thread_shared_chunk_index_, |
| 1495 event_index, handle); | 1434 event_index, handle); |
| 1496 } | 1435 } |
| 1497 return trace_event; | 1436 return trace_event; |
| 1498 } | 1437 } |
| 1499 | 1438 |
| 1500 void TraceLog::CheckIfBufferIsFullWhileLocked(NotificationHelper* notifier) { | 1439 void TraceLog::CheckIfBufferIsFullWhileLocked() { |
| 1501 lock_.AssertAcquired(); | 1440 lock_.AssertAcquired(); |
| 1502 if (!subtle::NoBarrier_Load(&buffer_is_full_) && logged_events_->IsFull()) { | 1441 if (logged_events_->IsFull()) |
| 1503 subtle::NoBarrier_Store(&buffer_is_full_, | 1442 SetDisabledWhileLocked(); |
| 1504 static_cast<subtle::AtomicWord>(1)); | |
| 1505 notifier->AddNotificationWhileLocked(TRACE_BUFFER_FULL); | |
| 1506 } | |
| 1507 } | 1443 } |
| 1508 | 1444 |
| 1509 void TraceLog::SetEventCallbackEnabled(const CategoryFilter& category_filter, | 1445 void TraceLog::SetEventCallbackEnabled(const CategoryFilter& category_filter, |
| 1510 EventCallback cb) { | 1446 EventCallback cb) { |
| 1511 AutoLock lock(lock_); | 1447 AutoLock lock(lock_); |
| 1512 subtle::NoBarrier_Store(&event_callback_, | 1448 subtle::NoBarrier_Store(&event_callback_, |
| 1513 reinterpret_cast<subtle::AtomicWord>(cb)); | 1449 reinterpret_cast<subtle::AtomicWord>(cb)); |
| 1514 event_callback_category_filter_ = category_filter; | 1450 event_callback_category_filter_ = category_filter; |
| 1515 UpdateCategoryGroupEnabledFlags(); | 1451 UpdateCategoryGroupEnabledFlags(); |
| 1516 }; | 1452 }; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 | 1549 |
| 1614 if (!CheckGeneration(generation)) | 1550 if (!CheckGeneration(generation)) |
| 1615 return; | 1551 return; |
| 1616 | 1552 |
| 1617 { | 1553 { |
| 1618 AutoLock lock(lock_); | 1554 AutoLock lock(lock_); |
| 1619 | 1555 |
| 1620 previous_logged_events.swap(logged_events_); | 1556 previous_logged_events.swap(logged_events_); |
| 1621 logged_events_.reset(CreateTraceBuffer()); | 1557 logged_events_.reset(CreateTraceBuffer()); |
| 1622 NextGeneration(); | 1558 NextGeneration(); |
| 1623 subtle::NoBarrier_Store(&buffer_is_full_, 0); | |
| 1624 thread_message_loops_.clear(); | 1559 thread_message_loops_.clear(); |
| 1625 | 1560 |
| 1626 flush_message_loop_proxy_ = NULL; | 1561 flush_message_loop_proxy_ = NULL; |
| 1627 flush_output_callback = flush_output_callback_; | 1562 flush_output_callback = flush_output_callback_; |
| 1628 flush_output_callback_.Reset(); | 1563 flush_output_callback_.Reset(); |
| 1629 } | 1564 } |
| 1630 | 1565 |
| 1631 ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(), | 1566 ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(), |
| 1632 flush_output_callback); | 1567 flush_output_callback); |
| 1633 } | 1568 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 return handle; | 1668 return handle; |
| 1734 | 1669 |
| 1735 DCHECK(name); | 1670 DCHECK(name); |
| 1736 | 1671 |
| 1737 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) | 1672 if (flags & TRACE_EVENT_FLAG_MANGLE_ID) |
| 1738 id ^= process_id_hash_; | 1673 id ^= process_id_hash_; |
| 1739 | 1674 |
| 1740 TimeTicks now = OffsetTimestamp(timestamp); | 1675 TimeTicks now = OffsetTimestamp(timestamp); |
| 1741 TimeTicks thread_now = ThreadNow(); | 1676 TimeTicks thread_now = ThreadNow(); |
| 1742 | 1677 |
| 1743 NotificationHelper notifier(this); | |
| 1744 | |
| 1745 ThreadLocalEventBuffer* thread_local_event_buffer = NULL; | 1678 ThreadLocalEventBuffer* thread_local_event_buffer = NULL; |
| 1746 // A ThreadLocalEventBuffer needs the message loop | 1679 // A ThreadLocalEventBuffer needs the message loop |
| 1747 // - to know when the thread exits; | 1680 // - to know when the thread exits; |
| 1748 // - to handle the final flush. | 1681 // - to handle the final flush. |
| 1749 // For a thread without a message loop or the message loop may be blocked, the | 1682 // For a thread without a message loop or the message loop may be blocked, the |
| 1750 // trace events will be added into the main buffer directly. | 1683 // trace events will be added into the main buffer directly. |
| 1751 if (!thread_blocks_message_loop_.Get() && MessageLoop::current()) { | 1684 if (!thread_blocks_message_loop_.Get() && MessageLoop::current()) { |
| 1752 thread_local_event_buffer = thread_local_event_buffer_.Get(); | 1685 thread_local_event_buffer = thread_local_event_buffer_.Get(); |
| 1753 if (thread_local_event_buffer && | 1686 if (thread_local_event_buffer && |
| 1754 !CheckGeneration(thread_local_event_buffer->generation())) { | 1687 !CheckGeneration(thread_local_event_buffer->generation())) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 new_name) != existing_names.end(); | 1724 new_name) != existing_names.end(); |
| 1792 if (!found) { | 1725 if (!found) { |
| 1793 existing_name->second.push_back(','); | 1726 existing_name->second.push_back(','); |
| 1794 existing_name->second.append(new_name); | 1727 existing_name->second.append(new_name); |
| 1795 } | 1728 } |
| 1796 } | 1729 } |
| 1797 } | 1730 } |
| 1798 } | 1731 } |
| 1799 | 1732 |
| 1800 TraceEvent* trace_event = NULL; | 1733 TraceEvent* trace_event = NULL; |
| 1801 if ((*category_group_enabled & ENABLED_FOR_RECORDING) && | 1734 if ((*category_group_enabled & ENABLED_FOR_RECORDING)) { |
| 1802 !subtle::NoBarrier_Load(&buffer_is_full_)) { | |
| 1803 if (thread_local_event_buffer) { | 1735 if (thread_local_event_buffer) { |
| 1804 lock.EnsureReleased(); | 1736 lock.EnsureReleased(); |
| 1805 trace_event = thread_local_event_buffer->AddTraceEvent(¬ifier, | 1737 trace_event = thread_local_event_buffer->AddTraceEvent(&handle); |
| 1806 &handle); | |
| 1807 } else { | 1738 } else { |
| 1808 lock.EnsureAcquired(); | 1739 lock.EnsureAcquired(); |
| 1809 trace_event = AddEventToThreadSharedChunkWhileLocked(¬ifier, &handle); | 1740 trace_event = AddEventToThreadSharedChunkWhileLocked(&handle, true); |
| 1810 } | 1741 } |
| 1811 | 1742 |
| 1812 if (trace_event) { | 1743 if (trace_event) { |
| 1813 trace_event->Initialize(thread_id, now, thread_now, phase, | 1744 trace_event->Initialize(thread_id, now, thread_now, phase, |
| 1814 category_group_enabled, name, id, | 1745 category_group_enabled, name, id, |
| 1815 num_args, arg_names, arg_types, arg_values, | 1746 num_args, arg_names, arg_types, arg_values, |
| 1816 convertable_values, flags); | 1747 convertable_values, flags); |
| 1817 | 1748 |
| 1818 #if defined(OS_ANDROID) | 1749 #if defined(OS_ANDROID) |
| 1819 trace_event->SendToATrace(); | 1750 trace_event->SendToATrace(); |
| 1820 #endif | 1751 #endif |
| 1821 } | 1752 } |
| 1822 } | |
| 1823 | 1753 |
| 1824 if (trace_options() & ECHO_TO_CONSOLE) { | 1754 if (trace_options() & ECHO_TO_CONSOLE) { |
| 1825 lock.EnsureAcquired(); | 1755 lock.EnsureAcquired(); |
| 1826 OutputEventToConsoleWhileLocked( | 1756 OutputEventToConsoleWhileLocked( |
| 1827 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, | 1757 phase == TRACE_EVENT_PHASE_COMPLETE ? TRACE_EVENT_PHASE_BEGIN : phase, |
| 1828 timestamp, trace_event); | 1758 timestamp, trace_event); |
| 1759 } |
| 1829 } | 1760 } |
| 1830 | 1761 |
| 1831 if (reinterpret_cast<const unsigned char*>(subtle::NoBarrier_Load( | 1762 if (reinterpret_cast<const unsigned char*>(subtle::NoBarrier_Load( |
| 1832 &watch_category_)) == category_group_enabled) { | 1763 &watch_category_)) == category_group_enabled) { |
| 1833 lock.EnsureAcquired(); | 1764 lock.EnsureAcquired(); |
| 1834 if (watch_event_name_ == name) | 1765 if (watch_event_name_ == name) { |
| 1835 notifier.AddNotificationWhileLocked(EVENT_WATCH_NOTIFICATION); | 1766 WatchEventCallback watch_event_callback_copy = watch_event_callback_; |
| 1767 lock.EnsureReleased(); |
| 1768 if (!watch_event_callback_copy.is_null()) |
| 1769 watch_event_callback_copy.Run(); |
| 1770 } |
| 1836 } | 1771 } |
| 1837 | 1772 |
| 1838 lock.EnsureReleased(); | 1773 lock.EnsureReleased(); |
| 1839 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { | 1774 if (*category_group_enabled & ENABLED_FOR_EVENT_CALLBACK) { |
| 1840 EventCallback event_callback = reinterpret_cast<EventCallback>( | 1775 EventCallback event_callback = reinterpret_cast<EventCallback>( |
| 1841 subtle::NoBarrier_Load(&event_callback_)); | 1776 subtle::NoBarrier_Load(&event_callback_)); |
| 1842 if (event_callback) { | 1777 if (event_callback) { |
| 1843 event_callback(now, | 1778 event_callback(now, |
| 1844 phase == TRACE_EVENT_PHASE_COMPLETE ? | 1779 phase == TRACE_EVENT_PHASE_COMPLETE ? |
| 1845 TRACE_EVENT_PHASE_BEGIN : phase, | 1780 TRACE_EVENT_PHASE_BEGIN : phase, |
| 1846 category_group_enabled, name, id, | 1781 category_group_enabled, name, id, |
| 1847 num_args, arg_names, arg_types, arg_values, | 1782 num_args, arg_names, arg_types, arg_values, |
| 1848 flags); | 1783 flags); |
| 1849 } | 1784 } |
| 1850 } | 1785 } |
| 1851 | 1786 |
| 1852 if (thread_local_event_buffer) | 1787 if (thread_local_event_buffer) |
| 1853 thread_local_event_buffer->ReportOverhead(now, thread_now, ¬ifier); | 1788 thread_local_event_buffer->ReportOverhead(now, thread_now); |
| 1854 | |
| 1855 notifier.SendNotificationIfAny(); | |
| 1856 | 1789 |
| 1857 return handle; | 1790 return handle; |
| 1858 } | 1791 } |
| 1859 | 1792 |
| 1860 // May be called when a COMPELETE event ends and the unfinished event has been | 1793 // May be called when a COMPELETE event ends and the unfinished event has been |
| 1861 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). | 1794 // recycled (phase == TRACE_EVENT_PHASE_END and trace_event == NULL). |
| 1862 void TraceLog::OutputEventToConsoleWhileLocked(unsigned char phase, | 1795 void TraceLog::OutputEventToConsoleWhileLocked(unsigned char phase, |
| 1863 const TimeTicks& timestamp, | 1796 const TimeTicks& timestamp, |
| 1864 TraceEvent* trace_event) { | 1797 TraceEvent* trace_event) { |
| 1865 // The caller should translate TRACE_EVENT_PHASE_COMPLETE to | 1798 // The caller should translate TRACE_EVENT_PHASE_COMPLETE to |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 subtle::NoBarrier_Load(&event_callback_)); | 1888 subtle::NoBarrier_Load(&event_callback_)); |
| 1956 if (event_callback) { | 1889 if (event_callback) { |
| 1957 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, | 1890 event_callback(now, TRACE_EVENT_PHASE_END, category_group_enabled, name, |
| 1958 trace_event_internal::kNoEventId, 0, NULL, NULL, NULL, | 1891 trace_event_internal::kNoEventId, 0, NULL, NULL, NULL, |
| 1959 TRACE_EVENT_FLAG_NONE); | 1892 TRACE_EVENT_FLAG_NONE); |
| 1960 } | 1893 } |
| 1961 } | 1894 } |
| 1962 } | 1895 } |
| 1963 | 1896 |
| 1964 void TraceLog::SetWatchEvent(const std::string& category_name, | 1897 void TraceLog::SetWatchEvent(const std::string& category_name, |
| 1965 const std::string& event_name) { | 1898 const std::string& event_name, |
| 1899 const WatchEventCallback& callback) { |
| 1966 const unsigned char* category = GetCategoryGroupEnabled( | 1900 const unsigned char* category = GetCategoryGroupEnabled( |
| 1967 category_name.c_str()); | 1901 category_name.c_str()); |
| 1968 AutoLock lock(lock_); | 1902 AutoLock lock(lock_); |
| 1969 subtle::NoBarrier_Store(&watch_category_, | 1903 subtle::NoBarrier_Store(&watch_category_, |
| 1970 reinterpret_cast<subtle::AtomicWord>(category)); | 1904 reinterpret_cast<subtle::AtomicWord>(category)); |
| 1971 watch_event_name_ = event_name; | 1905 watch_event_name_ = event_name; |
| 1906 watch_event_callback_ = callback; |
| 1972 } | 1907 } |
| 1973 | 1908 |
| 1974 void TraceLog::CancelWatchEvent() { | 1909 void TraceLog::CancelWatchEvent() { |
| 1975 AutoLock lock(lock_); | 1910 AutoLock lock(lock_); |
| 1976 subtle::NoBarrier_Store(&watch_category_, 0); | 1911 subtle::NoBarrier_Store(&watch_category_, 0); |
| 1977 watch_event_name_ = ""; | 1912 watch_event_name_ = ""; |
| 1913 watch_event_callback_.Reset(); |
| 1978 } | 1914 } |
| 1979 | 1915 |
| 1980 void TraceLog::AddMetadataEventsWhileLocked() { | 1916 void TraceLog::AddMetadataEventsWhileLocked() { |
| 1981 lock_.AssertAcquired(); | 1917 lock_.AssertAcquired(); |
| 1982 | 1918 |
| 1983 int current_thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1919 int current_thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
| 1984 if (process_sort_index_ != 0) { | 1920 if (process_sort_index_ != 0) { |
| 1985 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, NULL), | 1921 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
| 1986 current_thread_id, | 1922 current_thread_id, |
| 1987 "process_sort_index", "sort_index", | 1923 "process_sort_index", "sort_index", |
| 1988 process_sort_index_); | 1924 process_sort_index_); |
| 1989 } | 1925 } |
| 1990 | 1926 |
| 1991 if (process_name_.size()) { | 1927 if (process_name_.size()) { |
| 1992 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, NULL), | 1928 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
| 1993 current_thread_id, | 1929 current_thread_id, |
| 1994 "process_name", "name", | 1930 "process_name", "name", |
| 1995 process_name_); | 1931 process_name_); |
| 1996 } | 1932 } |
| 1997 | 1933 |
| 1998 if (process_labels_.size() > 0) { | 1934 if (process_labels_.size() > 0) { |
| 1999 std::vector<std::string> labels; | 1935 std::vector<std::string> labels; |
| 2000 for(base::hash_map<int, std::string>::iterator it = process_labels_.begin(); | 1936 for(base::hash_map<int, std::string>::iterator it = process_labels_.begin(); |
| 2001 it != process_labels_.end(); | 1937 it != process_labels_.end(); |
| 2002 it++) { | 1938 it++) { |
| 2003 labels.push_back(it->second); | 1939 labels.push_back(it->second); |
| 2004 } | 1940 } |
| 2005 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, NULL), | 1941 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
| 2006 current_thread_id, | 1942 current_thread_id, |
| 2007 "process_labels", "labels", | 1943 "process_labels", "labels", |
| 2008 JoinString(labels, ',')); | 1944 JoinString(labels, ',')); |
| 2009 } | 1945 } |
| 2010 | 1946 |
| 2011 // Thread sort indices. | 1947 // Thread sort indices. |
| 2012 for(hash_map<int, int>::iterator it = thread_sort_indices_.begin(); | 1948 for(hash_map<int, int>::iterator it = thread_sort_indices_.begin(); |
| 2013 it != thread_sort_indices_.end(); | 1949 it != thread_sort_indices_.end(); |
| 2014 it++) { | 1950 it++) { |
| 2015 if (it->second == 0) | 1951 if (it->second == 0) |
| 2016 continue; | 1952 continue; |
| 2017 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, NULL), | 1953 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
| 2018 it->first, | 1954 it->first, |
| 2019 "thread_sort_index", "sort_index", | 1955 "thread_sort_index", "sort_index", |
| 2020 it->second); | 1956 it->second); |
| 2021 } | 1957 } |
| 2022 | 1958 |
| 2023 // Thread names. | 1959 // Thread names. |
| 2024 for(hash_map<int, std::string>::iterator it = thread_names_.begin(); | 1960 for(hash_map<int, std::string>::iterator it = thread_names_.begin(); |
| 2025 it != thread_names_.end(); | 1961 it != thread_names_.end(); |
| 2026 it++) { | 1962 it++) { |
| 2027 if (it->second.empty()) | 1963 if (it->second.empty()) |
| 2028 continue; | 1964 continue; |
| 2029 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, NULL), | 1965 InitializeMetadataEvent(AddEventToThreadSharedChunkWhileLocked(NULL, false), |
| 2030 it->first, | 1966 it->first, |
| 2031 "thread_name", "name", | 1967 "thread_name", "name", |
| 2032 it->second); | 1968 it->second); |
| 2033 } | 1969 } |
| 2034 } | 1970 } |
| 2035 | 1971 |
| 2036 void TraceLog::WaitSamplingEventForTesting() { | 1972 void TraceLog::WaitSamplingEventForTesting() { |
| 2037 if (!sampling_thread_) | 1973 if (!sampling_thread_) |
| 2038 return; | 1974 return; |
| 2039 sampling_thread_->WaitSamplingEventForTesting(); | 1975 sampling_thread_->WaitSamplingEventForTesting(); |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2314 } | 2250 } |
| 2315 | 2251 |
| 2316 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 2252 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
| 2317 if (*category_group_enabled_) { | 2253 if (*category_group_enabled_) { |
| 2318 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, | 2254 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, |
| 2319 name_, event_handle_); | 2255 name_, event_handle_); |
| 2320 } | 2256 } |
| 2321 } | 2257 } |
| 2322 | 2258 |
| 2323 } // namespace trace_event_internal | 2259 } // namespace trace_event_internal |
| OLD | NEW |