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

Unified Diff: components/tracing/core/trace_buffer_writer.cc

Issue 2303353002: Tracing v2: wire up stubs generated by the protozero protoc plugin (Closed)
Patch Set: petrcermak review Created 4 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
Index: components/tracing/core/trace_buffer_writer.cc
diff --git a/components/tracing/core/trace_buffer_writer.cc b/components/tracing/core/trace_buffer_writer.cc
index b811eeb9419cea535a141365aecaf4b95afb18ad..641521ed456f98ec75fb090beb135a1f649d3e32 100644
--- a/components/tracing/core/trace_buffer_writer.cc
+++ b/components/tracing/core/trace_buffer_writer.cc
@@ -7,6 +7,7 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "components/tracing/core/proto_utils.h"
+#include "components/tracing/proto/event.pbzero.h"
#include "components/tracing/proto/events_chunk.pbzero.h"
namespace tracing {
@@ -76,7 +77,7 @@ TraceEventHandle TraceBufferWriter::AddEvent() {
WriteEventPreambleForNewChunk(
stream_writer_.ReserveBytesUnsafe(kEventPreambleSize));
DCHECK_EQ(stream_writer_.write_ptr(), event_data_start_in_current_chunk_);
- return TraceEventHandle(static_cast<::tracing::proto::Event*>(&event_));
+ return TraceEventHandle(static_cast<pbzero::tracing::proto::Event*>(&event_));
}
// This is invoked by the ProtoZeroMessage write methods when reaching the
@@ -150,10 +151,9 @@ ContiguousMemoryRange TraceBufferWriter::AcquireNewChunk(
proto::MakeTagVarInt(ChunkProto::kWriterIdFieldNumber));
chunk_proto = proto::WriteVarInt(writer_id_, chunk_proto);
- proto::StaticAssertSingleBytePreamble<
- ChunkProto::kSeqIdFieldNumber>();
- *chunk_proto++ = static_cast<uint8_t>(
- proto::MakeTagVarInt(ChunkProto::kSeqIdFieldNumber));
+ proto::StaticAssertSingleBytePreamble<ChunkProto::kSeqIdFieldNumber>();
+ *chunk_proto++ =
+ static_cast<uint8_t>(proto::MakeTagVarInt(ChunkProto::kSeqIdFieldNumber));
chunk_proto = proto::WriteVarInt(chunk_seq_id_, chunk_proto);
if (is_fragmenting_event) {
@@ -194,6 +194,8 @@ uint8_t* TraceBufferWriter::WriteEventPreambleForNewChunk(uint8_t* begin) {
}
void TraceBufferWriter::Flush() {
+ if (!chunk_)
+ return;
FinalizeCurrentEvent();
FinalizeCurrentChunk(false /* is_fragmenting_event */);
trace_ring_buffer_->ReturnChunk(chunk_);
« no previous file with comments | « components/tracing/core/trace_buffer_writer.h ('k') | components/tracing/core/trace_buffer_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698