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

Unified Diff: base/debug/trace_event.h

Issue 8355024: Internalize JSON chunk management to trace_event.h API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/trace_event.cc » ('j') | base/debug/trace_event.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | base/debug/trace_event.cc » ('j') | base/debug/trace_event.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698