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

Unified Diff: components/tracing/child_trace_message_filter.cc

Issue 22962004: Thread-local trace-event buffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update browser_shutdown_profile_dumper Created 7 years, 3 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 | « components/tracing/child_trace_message_filter.h ('k') | content/browser/browser_shutdown_profile_dumper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/child_trace_message_filter.cc
diff --git a/components/tracing/child_trace_message_filter.cc b/components/tracing/child_trace_message_filter.cc
index 154903a15d0725d6c72aa594165076d4cb5bea72..8310ec52db5748ae3abd4585d10fcb0f919bae89 100644
--- a/components/tracing/child_trace_message_filter.cc
+++ b/components/tracing/child_trace_message_filter.cc
@@ -65,16 +65,12 @@ void ChildTraceMessageFilter::OnBeginTracing(
void ChildTraceMessageFilter::OnEndTracing() {
TraceLog::GetInstance()->SetDisabled();
- // Flush will generate one or more callbacks to OnTraceDataCollected. It's
- // important that the last OnTraceDataCollected gets called before
- // EndTracingAck below. We are already on the IO thread, so the
+ // Flush will generate one or more callbacks to OnTraceDataCollected
+ // synchronously or asynchronously. EndTracingAck will be sent in the last
+ // OnTraceDataCollected. We are already on the IO thread, so the
// OnTraceDataCollected calls will not be deferred.
TraceLog::GetInstance()->Flush(
base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this));
-
- std::vector<std::string> category_groups;
- TraceLog::GetInstance()->GetKnownCategoryGroups(&category_groups);
- channel_->Send(new TracingHostMsg_EndTracingAck(category_groups));
}
void ChildTraceMessageFilter::OnGetTraceBufferPercentFull() {
@@ -94,15 +90,23 @@ void ChildTraceMessageFilter::OnCancelWatchEvent() {
}
void ChildTraceMessageFilter::OnTraceDataCollected(
- const scoped_refptr<base::RefCountedString>& events_str_ptr) {
+ const scoped_refptr<base::RefCountedString>& events_str_ptr,
+ bool has_more_events) {
if (!ipc_message_loop_->BelongsToCurrentThread()) {
ipc_message_loop_->PostTask(FROM_HERE,
base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this,
- events_str_ptr));
+ events_str_ptr, has_more_events));
return;
}
- channel_->Send(new TracingHostMsg_TraceDataCollected(
- events_str_ptr->data()));
+ if (events_str_ptr->data().size()) {
+ channel_->Send(new TracingHostMsg_TraceDataCollected(
+ events_str_ptr->data()));
+ }
+ if (!has_more_events) {
+ std::vector<std::string> category_groups;
+ TraceLog::GetInstance()->GetKnownCategoryGroups(&category_groups);
+ channel_->Send(new TracingHostMsg_EndTracingAck(category_groups));
+ }
}
void ChildTraceMessageFilter::OnTraceNotification(int notification) {
« no previous file with comments | « components/tracing/child_trace_message_filter.h ('k') | content/browser/browser_shutdown_profile_dumper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698