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

Unified Diff: base/debug/trace_event.cc

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
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
//
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698