Chromium Code Reviews| 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(); |
|
Ken Russell (switch to Gerrit)
2015/05/08 18:54:34
What happens if this is hit during the last iterat
hubbe
2015/05/08 18:58:14
This flush happens before appending the current ev
|
| + } 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); |
| } |
| void TraceLog::FinishFlush(int generation) { |