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

Unified Diff: components/tracing/core/proto_zero_message.h

Issue 2240043004: Tracing V2: Fully-functional plugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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/BUILD.gn ('k') | components/tracing/test/fake_scattered_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/core/proto_zero_message.h
diff --git a/components/tracing/core/proto_zero_message.h b/components/tracing/core/proto_zero_message.h
index 6723eb6aeab88f619ad8cd473acc7b81156bda44..2e6bf4a1c3eba27ff037b41aa94114e5fe62ce85 100644
--- a/components/tracing/core/proto_zero_message.h
+++ b/components/tracing/core/proto_zero_message.h
@@ -83,6 +83,21 @@ class TRACING_EXPORT ProtoZeroMessage {
AppendVarInt(field_id, proto::ZigZagEncode(value));
}
+ // Proto types: bool, enum (small).
+ // Faster version of AppendVarInt for tiny numbers.
+ void AppendTinyVarInt(uint32_t field_id, int32_t value) {
+ DCHECK(0 <= value && value < 0x80);
+ if (nested_message_)
+ EndNestedMessage();
+
+ uint8_t buffer[proto::kMaxSimpleFieldEncodedSize];
+ uint8_t* pos = buffer;
+ // MakeTagVarInt gets super optimized here for constexpr.
+ pos = proto::WriteVarInt(proto::MakeTagVarInt(field_id), pos);
+ *pos++ = static_cast<uint8_t>(value);
+ WriteToStream(buffer, pos);
+ }
+
// Proto types: fixed64, sfixed64, fixed32, sfixed32, double, float.
template <typename T>
void AppendFixed(uint32_t field_id, T value) {
@@ -99,7 +114,6 @@ class TRACING_EXPORT ProtoZeroMessage {
WriteToStream(buffer, pos);
}
- // TODO(kraynov): Add AppendTinyInt.
void AppendString(uint32_t field_id, const char* str);
void AppendBytes(uint32_t field_id, const void* value, size_t size);
« no previous file with comments | « components/tracing/BUILD.gn ('k') | components/tracing/test/fake_scattered_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698