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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 std::string json_output; | 782 std::string json_output; |
783 }; | 783 }; |
784 | 784 |
785 TraceResultBuffer(); | 785 TraceResultBuffer(); |
786 ~TraceResultBuffer(); | 786 ~TraceResultBuffer(); |
787 | 787 |
788 // Set callback. The callback will be called during Start with the initial | 788 // Set callback. The callback will be called during Start with the initial |
789 // JSON output and during AddFragment and Finish with following JSON output | 789 // JSON output and during AddFragment and Finish with following JSON output |
790 // chunks. The callback target must live past the last calls to | 790 // chunks. The callback target must live past the last calls to |
791 // TraceResultBuffer::Start/AddFragment/Finish. | 791 // TraceResultBuffer::Start/AddFragment/Finish. |
792 void SetOutputCallback(OutputCallback json_chunk_callback); | 792 void SetOutputCallback(const OutputCallback& json_chunk_callback); |
793 | 793 |
794 // Start JSON output. This resets all internal state, so you can reuse | 794 // Start JSON output. This resets all internal state, so you can reuse |
795 // the TraceResultBuffer by calling Start. | 795 // the TraceResultBuffer by calling Start. |
796 void Start(); | 796 void Start(); |
797 | 797 |
798 // Call AddFragment 0 or more times to add trace fragments from TraceLog. | 798 // Call AddFragment 0 or more times to add trace fragments from TraceLog. |
799 void AddFragment(const std::string& trace_fragment); | 799 void AddFragment(const std::string& trace_fragment); |
800 | 800 |
801 // When all fragments have been added, call Finish to complete the JSON | 801 // When all fragments have been added, call Finish to complete the JSON |
802 // formatted output. | 802 // formatted output. |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 bool IsEnabled() { return enabled_; } | 849 bool IsEnabled() { return enabled_; } |
850 | 850 |
851 float GetBufferPercentFull() const; | 851 float GetBufferPercentFull() const; |
852 | 852 |
853 // When enough events are collected, they are handed (in bulk) to | 853 // When enough events are collected, they are handed (in bulk) to |
854 // the output callback. If no callback is set, the output will be | 854 // the output callback. If no callback is set, the output will be |
855 // silently dropped. The callback must be thread safe. The string format is | 855 // silently dropped. The callback must be thread safe. The string format is |
856 // undefined. Use TraceResultBuffer to convert one or more trace strings to | 856 // undefined. Use TraceResultBuffer to convert one or more trace strings to |
857 // JSON. | 857 // JSON. |
858 typedef RefCountedData<std::string> RefCountedString; | 858 typedef RefCountedData<std::string> RefCountedString; |
859 typedef base::Callback<void(scoped_refptr<RefCountedString>)> OutputCallback; | 859 typedef base::Callback<void(const scoped_refptr<RefCountedString>&)> |
| 860 OutputCallback; |
860 void SetOutputCallback(const OutputCallback& cb); | 861 void SetOutputCallback(const OutputCallback& cb); |
861 | 862 |
862 // The trace buffer does not flush dynamically, so when it fills up, | 863 // The trace buffer does not flush dynamically, so when it fills up, |
863 // subsequent trace events will be dropped. This callback is generated when | 864 // subsequent trace events will be dropped. This callback is generated when |
864 // the trace buffer is full. The callback must be thread safe. | 865 // the trace buffer is full. The callback must be thread safe. |
865 typedef base::Callback<void(void)> BufferFullCallback; | 866 typedef base::Callback<void(void)> BufferFullCallback; |
866 void SetBufferFullCallback(const BufferFullCallback& cb); | 867 void SetBufferFullCallback(const BufferFullCallback& cb); |
867 | 868 |
868 // Flushes all logged data to the callback. | 869 // Flushes all logged data to the callback. |
869 void Flush(); | 870 void Flush(); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 Data* p_data_; | 1028 Data* p_data_; |
1028 Data data_; | 1029 Data data_; |
1029 }; | 1030 }; |
1030 | 1031 |
1031 } // namespace internal | 1032 } // namespace internal |
1032 | 1033 |
1033 } // namespace debug | 1034 } // namespace debug |
1034 } // namespace base | 1035 } // namespace base |
1035 | 1036 |
1036 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 1037 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
OLD | NEW |