Index: base/debug/trace_event.cc |
diff --git a/base/debug/trace_event.cc b/base/debug/trace_event.cc |
index 347644f982ef3a4f3cd260b55a8b452e5217db3e..0fcdaf853b5d95f9d9b6c87c302ac74c88973ac9 100644 |
--- a/base/debug/trace_event.cc |
+++ b/base/debug/trace_event.cc |
@@ -224,13 +224,11 @@ void TraceEvent::AppendEventsAsJSON(const std::vector<TraceEvent>& events, |
size_t start, |
size_t count, |
std::string* out) { |
- *out += "["; |
for (size_t i = 0; i < count && start + i < events.size(); ++i) { |
if (i > 0) |
*out += ","; |
events[i + start].AppendAsJSON(out); |
} |
- *out += "]"; |
} |
void TraceEvent::AppendAsJSON(std::string* out) const { |
@@ -262,6 +260,32 @@ void TraceEvent::AppendAsJSON(std::string* out) const { |
//////////////////////////////////////////////////////////////////////////////// |
// |
+// TraceResultBuffer |
+// |
+//////////////////////////////////////////////////////////////////////////////// |
+ |
+TraceResultBuffer::TraceResultBuffer() { |
+} |
+ |
+TraceResultBuffer::~TraceResultBuffer() { |
+} |
+ |
+void TraceResultBuffer::AddFragment(const std::string& trace_fragment) { |
+ fragments_.push_back(trace_fragment); |
+} |
+ |
+void TraceResultBuffer::GetJSON(std::string* json_trace_output) { |
+ *json_trace_output = "["; |
+ for (size_t i = 0; i < fragments_.size(); ++i) { |
nduca
2011/10/20 00:28:03
Algorithmically, I see a bit too many strdups. I'd
jbates
2011/10/20 22:18:49
Similar optimizations occurred to me, but I though
|
+ if (i > 0) |
+ *json_trace_output += ","; |
+ *json_trace_output += fragments_[i]; |
+ } |
+ *json_trace_output += "]"; |
+} |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+// |
// TraceLog |
// |
//////////////////////////////////////////////////////////////////////////////// |