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

Unified Diff: base/trace_event/trace_event_impl.cc

Issue 1239593002: Implement a new flow event API that allows binding flow events and regular events. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a redundant macro. Created 5 years, 5 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/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 1fc22565d0ec182e1e908abb40f36921846f23bb..71e64239f3b7cff38b20438321dddf71e5b33a95 100644
--- a/base/trace_event/trace_event_impl.cc
+++ b/base/trace_event/trace_event_impl.cc
@@ -602,6 +602,7 @@ void TraceEvent::Initialize(
thread_id_ = thread_id;
phase_ = phase;
flags_ = flags;
+ flowEvent_ = NULL;
// Clamp num_args since it may have been set by a third_party library.
num_args = (num_args > kTraceMaxNumArgs) ? kTraceMaxNumArgs : num_args;
@@ -862,6 +863,12 @@ void TraceEvent::AppendAsJSON(
StringAppendF(out, ",\"s\":\"%c\"", scope);
}
+ // Output flow event info if there is any
+ if (flowEvent_) {
+ StringAppendF(out, ",\"flow\":");
+ flowEvent_->AppendAsJSON(out, argument_filter_predicate);
+ }
+
*out += "}";
}
@@ -888,6 +895,12 @@ void TraceEvent::AppendPrettyPrinted(std::ostringstream* out) const {
}
}
+bool TraceEvent::isFlowEvent() const {
+ return ((phase() == TRACE_EVENT_PHASE_FLOW_BEGIN) ||
+ (phase() == TRACE_EVENT_PHASE_FLOW_STEP) ||
+ (phase() == TRACE_EVENT_PHASE_FLOW_END));
+}
+
////////////////////////////////////////////////////////////////////////////////
//
// TraceResultBuffer
@@ -1851,6 +1864,11 @@ void TraceLog::ConvertTraceEventsToTraceFormat(
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) {
+ // Flow Events are always bundled to regular events, and will be handled
+ // within their bundled events.
+ if (chunk->GetEventAt(j)->isFlowEvent())
+ continue;
+
size_t size = json_events_str_ptr->size();
if (size > kTraceEventBufferSizeInBytes) {
flush_output_callback.Run(json_events_str_ptr, true);

Powered by Google App Engine
This is Rietveld 408576698