| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/debug/leak_annotations.h" | 10 #include "base/debug/leak_annotations.h" |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 #if defined(OS_ANDROID) | 993 #if defined(OS_ANDROID) |
| 994 SendToATrace(phase, GetCategoryGroupName(category_group_enabled), name, id, | 994 SendToATrace(phase, GetCategoryGroupName(category_group_enabled), name, id, |
| 995 num_args, arg_names, arg_types, arg_values, flags); | 995 num_args, arg_names, arg_types, arg_values, flags); |
| 996 #endif | 996 #endif |
| 997 | 997 |
| 998 TimeTicks now = timestamp - time_offset_; | 998 TimeTicks now = timestamp - time_offset_; |
| 999 EventCallback event_callback_copy; | 999 EventCallback event_callback_copy; |
| 1000 | 1000 |
| 1001 NotificationHelper notifier(this); | 1001 NotificationHelper notifier(this); |
| 1002 | 1002 |
| 1003 { | 1003 do { |
| 1004 AutoLock lock(lock_); | 1004 AutoLock lock(lock_); |
| 1005 if (*category_group_enabled != CATEGORY_ENABLED) | 1005 if (*category_group_enabled != CATEGORY_ENABLED) |
| 1006 return; | 1006 return; |
| 1007 |
| 1008 event_callback_copy = event_callback_; |
| 1007 if (logged_events_->IsFull()) | 1009 if (logged_events_->IsFull()) |
| 1008 return; | 1010 break; |
| 1009 | 1011 |
| 1010 const char* new_name = ThreadIdNameManager::GetInstance()-> | 1012 const char* new_name = ThreadIdNameManager::GetInstance()-> |
| 1011 GetName(thread_id); | 1013 GetName(thread_id); |
| 1012 // Check if the thread name has been set or changed since the previous | 1014 // Check if the thread name has been set or changed since the previous |
| 1013 // call (if any), but don't bother if the new name is empty. Note this will | 1015 // call (if any), but don't bother if the new name is empty. Note this will |
| 1014 // not detect a thread name change within the same char* buffer address: we | 1016 // not detect a thread name change within the same char* buffer address: we |
| 1015 // favor common case performance over corner case correctness. | 1017 // favor common case performance over corner case correctness. |
| 1016 if (new_name != g_current_thread_name.Get().Get() && | 1018 if (new_name != g_current_thread_name.Get().Get() && |
| 1017 new_name && *new_name) { | 1019 new_name && *new_name) { |
| 1018 g_current_thread_name.Get().Set(new_name); | 1020 g_current_thread_name.Get().Set(new_name); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1040 logged_events_->AddEvent(TraceEvent(thread_id, | 1042 logged_events_->AddEvent(TraceEvent(thread_id, |
| 1041 now, phase, category_group_enabled, name, id, | 1043 now, phase, category_group_enabled, name, id, |
| 1042 num_args, arg_names, arg_types, arg_values, | 1044 num_args, arg_names, arg_types, arg_values, |
| 1043 flags)); | 1045 flags)); |
| 1044 | 1046 |
| 1045 if (logged_events_->IsFull()) | 1047 if (logged_events_->IsFull()) |
| 1046 notifier.AddNotificationWhileLocked(TRACE_BUFFER_FULL); | 1048 notifier.AddNotificationWhileLocked(TRACE_BUFFER_FULL); |
| 1047 | 1049 |
| 1048 if (watch_category_ == category_group_enabled && watch_event_name_ == name) | 1050 if (watch_category_ == category_group_enabled && watch_event_name_ == name) |
| 1049 notifier.AddNotificationWhileLocked(EVENT_WATCH_NOTIFICATION); | 1051 notifier.AddNotificationWhileLocked(EVENT_WATCH_NOTIFICATION); |
| 1050 | 1052 } while (0); // release lock |
| 1051 event_callback_copy = event_callback_; | |
| 1052 } // release lock | |
| 1053 | 1053 |
| 1054 notifier.SendNotificationIfAny(); | 1054 notifier.SendNotificationIfAny(); |
| 1055 if (event_callback_copy != NULL) { | 1055 if (event_callback_copy != NULL) { |
| 1056 event_callback_copy(phase, category_group_enabled, name, id, | 1056 event_callback_copy(phase, category_group_enabled, name, id, |
| 1057 num_args, arg_names, arg_types, arg_values, | 1057 num_args, arg_names, arg_types, arg_values, |
| 1058 flags); | 1058 flags); |
| 1059 } | 1059 } |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 void TraceLog::AddTraceEventEtw(char phase, | 1062 void TraceLog::AddTraceEventEtw(char phase, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 0, // num_args | 1343 0, // num_args |
| 1344 NULL, // arg_names | 1344 NULL, // arg_names |
| 1345 NULL, // arg_types | 1345 NULL, // arg_types |
| 1346 NULL, // arg_values | 1346 NULL, // arg_values |
| 1347 TRACE_EVENT_FLAG_NONE); // flags | 1347 TRACE_EVENT_FLAG_NONE); // flags |
| 1348 } | 1348 } |
| 1349 } | 1349 } |
| 1350 | 1350 |
| 1351 } // namespace trace_event_internal | 1351 } // namespace trace_event_internal |
| 1352 | 1352 |
| OLD | NEW |