Chromium Code Reviews| Index: base/debug/trace_event.h |
| diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h |
| index d5aa256dc15cb769c2de0a312eb5c2084f7f56ba..31819bc4b9a4ebb0295fcb0a1f8ebdc897f7d22e 100644 |
| --- a/base/debug/trace_event.h |
| +++ b/base/debug/trace_event.h |
| @@ -515,6 +515,23 @@ class TraceEvent { |
| }; |
| +// TraceResultBuffer collects and merges trace fragments returned by TraceLog. |
| +// Add all the trace event fragments with AddFragment and then call GetJSON to |
| +// retrieve the full set of trace events in JSON format. |
| +class TraceResultBuffer { |
| + public: |
| + TraceResultBuffer(); |
| + ~TraceResultBuffer(); |
| + |
| + void AddFragment(const std::string& trace_fragment); |
|
nduca
2011/10/20 00:28:03
Brownie points: typedef TraceFragment so nobody se
jbates
2011/10/20 22:18:49
I wanted to do this as well, but I didn't want to
nduca
2011/10/20 23:20:05
I realize its work, but we both agree its the righ
jbates
2011/10/20 23:55:13
Yup, we agree it's a good design, but low priority
|
| + |
| + void GetJSON(std::string* json_trace_output); |
| + |
| + private: |
| + std::vector<std::string> fragments_; |
| +}; |
| + |
| + |
| class BASE_EXPORT TraceLog { |
| public: |
| // Flags for passing to AddTraceEvent. |
| @@ -549,7 +566,9 @@ class BASE_EXPORT TraceLog { |
| // When enough events are collected, they are handed (in bulk) to |
| // the output callback. If no callback is set, the output will be |
| - // silently dropped. The callback must be thread safe. |
| + // silently dropped. The callback must be thread safe. The string format is |
| + // undefined. Use TraceResultBuffer to convert one or more trace strings to |
| + // JSON. |
| typedef RefCountedData<std::string> RefCountedString; |
| typedef base::Callback<void(scoped_refptr<RefCountedString>)> OutputCallback; |
| void SetOutputCallback(const OutputCallback& cb); |