Index: base/trace_event/trace_event_impl.cc |
diff --git a/base/trace_event/trace_event_impl.cc b/base/trace_event/trace_event_impl.cc |
index 5ae7fb2572f7b16653f0360a322f62298541829e..369d874266bae8ba2dcc7818cbee9c89ee944b13 100644 |
--- a/base/trace_event/trace_event_impl.cc |
+++ b/base/trace_event/trace_event_impl.cc |
@@ -1763,24 +1763,20 @@ void TraceLog::ConvertTraceEventsToTraceFormat( |
// The callback need to be called at least once even if there is no events |
// to let the caller know the completion of flush. |
- bool has_more_events = true; |
- do { |
- scoped_refptr<RefCountedString> json_events_str_ptr = |
- new RefCountedString(); |
- |
- while (json_events_str_ptr->size() < kTraceEventBufferSizeInBytes) { |
- const TraceBufferChunk* chunk = logged_events->NextChunk(); |
- has_more_events = chunk != NULL; |
- if (!chunk) |
- break; |
- for (size_t j = 0; j < chunk->size(); ++j) { |
- if (json_events_str_ptr->size()) |
- json_events_str_ptr->data().append(",\n"); |
- chunk->GetEventAt(j)->AppendAsJSON(&(json_events_str_ptr->data())); |
+ scoped_refptr<RefCountedString> json_events_str_ptr = new RefCountedString(); |
+ while (const TraceBufferChunk* chunk = logged_events->NextChunk()) { |
+ for (size_t j = 0; j < chunk->size(); ++j) { |
+ size_t size = json_events_str_ptr->size(); |
+ if (size > kTraceEventBufferSizeInBytes) { |
+ flush_output_callback.Run(json_events_str_ptr, true); |
+ json_events_str_ptr = new RefCountedString(); |
+ } else if (size) { |
+ json_events_str_ptr->data().append(",\n"); |
} |
+ chunk->GetEventAt(j)->AppendAsJSON(&(json_events_str_ptr->data())); |
} |
- flush_output_callback.Run(json_events_str_ptr, has_more_events); |
- } while (has_more_events); |
+ } |
+ flush_output_callback.Run(json_events_str_ptr, false); |
dsinclair
2015/06/11 13:54:39
Doesn't this new code do the same as the old code?
hubbe
2015/06/11 17:30:01
The new code will only create an empty callback if
dsinclair
2015/06/11 19:19:29
Right, but I don't see how the old code could prod
hubbe
2015/06/11 21:39:58
Apparently, it's been too long since I thought abo
dsinclair
2015/06/12 13:48:35
Ah, that makes a lot more sense, I can see how tha
|
} |
void TraceLog::FinishFlush(int generation) { |