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

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

Issue 15418002: Record Chrome trace events in tcmalloc heap profiles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, cleanup Created 7 years, 6 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
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 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after
1041 1041
1042 void TraceLog::RemoveEnabledStateObserver(EnabledStateObserver* listener) { 1042 void TraceLog::RemoveEnabledStateObserver(EnabledStateObserver* listener) {
1043 std::vector<EnabledStateObserver*>::iterator it = 1043 std::vector<EnabledStateObserver*>::iterator it =
1044 std::find(enabled_state_observer_list_.begin(), 1044 std::find(enabled_state_observer_list_.begin(),
1045 enabled_state_observer_list_.end(), 1045 enabled_state_observer_list_.end(),
1046 listener); 1046 listener);
1047 if (it != enabled_state_observer_list_.end()) 1047 if (it != enabled_state_observer_list_.end())
1048 enabled_state_observer_list_.erase(it); 1048 enabled_state_observer_list_.erase(it);
1049 } 1049 }
1050 1050
1051 bool TraceLog::HasEnabledStateObserver(EnabledStateObserver* listener) const {
1052 std::vector<EnabledStateObserver*>::const_iterator it =
1053 std::find(enabled_state_observer_list_.begin(),
1054 enabled_state_observer_list_.end(),
1055 listener);
1056 return it != enabled_state_observer_list_.end();
1057 }
1058
1051 float TraceLog::GetBufferPercentFull() const { 1059 float TraceLog::GetBufferPercentFull() const {
1052 return (float)((double)logged_events_->Size()/(double)kTraceEventBufferSize); 1060 return (float)((double)logged_events_->Size()/(double)kTraceEventBufferSize);
1053 } 1061 }
1054 1062
1055 void TraceLog::SetNotificationCallback( 1063 void TraceLog::SetNotificationCallback(
1056 const TraceLog::NotificationCallback& cb) { 1064 const TraceLog::NotificationCallback& cb) {
1057 AutoLock lock(lock_); 1065 AutoLock lock(lock_);
1058 notification_callback_ = cb; 1066 notification_callback_ = cb;
1059 } 1067 }
1060 1068
1061 TraceBuffer* TraceLog::GetTraceBuffer() { 1069 TraceBuffer* TraceLog::GetTraceBuffer() {
1062 if (trace_options_ & RECORD_CONTINUOUSLY) 1070 if (trace_options_ & RECORD_CONTINUOUSLY)
1063 return new TraceBufferRingBuffer(); 1071 return new TraceBufferRingBuffer();
1064 else if (trace_options_ & ECHO_TO_VLOG) 1072 else if (trace_options_ & ECHO_TO_VLOG)
1065 return new TraceBufferDiscardsEvents(); 1073 return new TraceBufferDiscardsEvents();
1066 return new TraceBufferVector(); 1074 return new TraceBufferVector();
1067 } 1075 }
1068 1076
1069 void TraceLog::SetEventCallback(EventCallback cb) { 1077 void TraceLog::SetEventCallback(EventCallback cb) {
1070 AutoLock lock(lock_); 1078 AutoLock lock(lock_);
1071 event_callback_ = cb; 1079 event_callback_ = cb;
1072 }; 1080 };
1073 1081
1074 void TraceLog::Flush(const TraceLog::OutputCallback& cb) { 1082 void TraceLog::Flush(const TraceLog::OutputCallback& cb) {
1083 // Ignore memory allocations from here down.
1084 TRACE_MEMORY(TRACE_DISABLED_BY_DEFAULT("memory"), TRACE_MEMORY_IGNORE);
1075 scoped_ptr<TraceBuffer> previous_logged_events; 1085 scoped_ptr<TraceBuffer> previous_logged_events;
1076 { 1086 {
1077 AutoLock lock(lock_); 1087 AutoLock lock(lock_);
1078 previous_logged_events.swap(logged_events_); 1088 previous_logged_events.swap(logged_events_);
1079 logged_events_.reset(GetTraceBuffer()); 1089 logged_events_.reset(GetTraceBuffer());
1080 } // release lock 1090 } // release lock
1081 1091
1082 while (previous_logged_events->HasMoreEvents()) { 1092 while (previous_logged_events->HasMoreEvents()) {
1083 scoped_refptr<RefCountedString> json_events_str_ptr = 1093 scoped_refptr<RefCountedString> json_events_str_ptr =
1084 new RefCountedString(); 1094 new RefCountedString();
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 0, // num_args 1556 0, // num_args
1547 NULL, // arg_names 1557 NULL, // arg_names
1548 NULL, // arg_types 1558 NULL, // arg_types
1549 NULL, // arg_values 1559 NULL, // arg_values
1550 NULL, // convertable values 1560 NULL, // convertable values
1551 TRACE_EVENT_FLAG_NONE); // flags 1561 TRACE_EVENT_FLAG_NONE); // flags
1552 } 1562 }
1553 } 1563 }
1554 1564
1555 } // namespace trace_event_internal 1565 } // namespace trace_event_internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698