OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Trace events are for tracking application performance and resource usage. | 5 // Trace events are for tracking application performance and resource usage. |
6 // Macros are provided to track: | 6 // Macros are provided to track: |
7 // Begin and end of function calls | 7 // Begin and end of function calls |
8 // Counters | 8 // Counters |
9 // | 9 // |
10 // Events are issued against categories. Whereas LOG's | 10 // Events are issued against categories. Whereas LOG's |
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 std::string json_output; | 744 std::string json_output; |
745 }; | 745 }; |
746 | 746 |
747 TraceResultBuffer(); | 747 TraceResultBuffer(); |
748 ~TraceResultBuffer(); | 748 ~TraceResultBuffer(); |
749 | 749 |
750 // Set callback. The callback will be called during Start with the initial | 750 // Set callback. The callback will be called during Start with the initial |
751 // JSON output and during AddFragment and Finish with following JSON output | 751 // JSON output and during AddFragment and Finish with following JSON output |
752 // chunks. The callback target must live past the last calls to | 752 // chunks. The callback target must live past the last calls to |
753 // TraceResultBuffer::Start/AddFragment/Finish. | 753 // TraceResultBuffer::Start/AddFragment/Finish. |
754 void SetOutputCallback(OutputCallback json_chunk_callback); | 754 void SetOutputCallback(const OutputCallback& json_chunk_callback); |
755 | 755 |
756 // Start JSON output. This resets all internal state, so you can reuse | 756 // Start JSON output. This resets all internal state, so you can reuse |
757 // the TraceResultBuffer by calling Start. | 757 // the TraceResultBuffer by calling Start. |
758 void Start(); | 758 void Start(); |
759 | 759 |
760 // Call AddFragment 0 or more times to add trace fragments from TraceLog. | 760 // Call AddFragment 0 or more times to add trace fragments from TraceLog. |
761 void AddFragment(const std::string& trace_fragment); | 761 void AddFragment(const std::string& trace_fragment); |
762 | 762 |
763 // When all fragments have been added, call Finish to complete the JSON | 763 // When all fragments have been added, call Finish to complete the JSON |
764 // formatted output. | 764 // formatted output. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 bool IsEnabled() { return enabled_; } | 811 bool IsEnabled() { return enabled_; } |
812 | 812 |
813 float GetBufferPercentFull() const; | 813 float GetBufferPercentFull() const; |
814 | 814 |
815 // When enough events are collected, they are handed (in bulk) to | 815 // When enough events are collected, they are handed (in bulk) to |
816 // the output callback. If no callback is set, the output will be | 816 // the output callback. If no callback is set, the output will be |
817 // silently dropped. The callback must be thread safe. The string format is | 817 // silently dropped. The callback must be thread safe. The string format is |
818 // undefined. Use TraceResultBuffer to convert one or more trace strings to | 818 // undefined. Use TraceResultBuffer to convert one or more trace strings to |
819 // JSON. | 819 // JSON. |
820 typedef RefCountedData<std::string> RefCountedString; | 820 typedef RefCountedData<std::string> RefCountedString; |
821 typedef base::Callback<void(scoped_refptr<RefCountedString>)> OutputCallback; | 821 typedef base::Callback<void(const scoped_refptr<RefCountedString>&)> |
| 822 OutputCallback; |
822 void SetOutputCallback(const OutputCallback& cb); | 823 void SetOutputCallback(const OutputCallback& cb); |
823 | 824 |
824 // The trace buffer does not flush dynamically, so when it fills up, | 825 // The trace buffer does not flush dynamically, so when it fills up, |
825 // subsequent trace events will be dropped. This callback is generated when | 826 // subsequent trace events will be dropped. This callback is generated when |
826 // the trace buffer is full. The callback must be thread safe. | 827 // the trace buffer is full. The callback must be thread safe. |
827 typedef base::Callback<void(void)> BufferFullCallback; | 828 typedef base::Callback<void(void)> BufferFullCallback; |
828 void SetBufferFullCallback(const BufferFullCallback& cb); | 829 void SetBufferFullCallback(const BufferFullCallback& cb); |
829 | 830 |
830 // Flushes all logged data to the callback. | 831 // Flushes all logged data to the callback. |
831 void Flush(); | 832 void Flush(); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 Data* p_data_; | 988 Data* p_data_; |
988 Data data_; | 989 Data data_; |
989 }; | 990 }; |
990 | 991 |
991 } // namespace internal | 992 } // namespace internal |
992 | 993 |
993 } // namespace debug | 994 } // namespace debug |
994 } // namespace base | 995 } // namespace base |
995 | 996 |
996 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 997 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
OLD | NEW |