Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: base/debug/trace_event_impl.cc

Issue 13912028: Invoke trace callback even when trace buffer is full (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | base/debug/trace_event_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event_unittest.cc » ('j') | base/debug/trace_event_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698