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

Side by Side Diff: components/tracing/core/proto_utils.h

Issue 2196663002: tracing v2: Introduce TraceBufferWriter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@proto_refactor
Patch Set: Fix linking errors moving kChunkSize outside of exported class 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 unified diff | Download patch
« no previous file with comments | « components/tracing/BUILD.gn ('k') | components/tracing/core/proto_zero_message.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_TRACING_CORE_PROTO_UTILS_H_ 5 #ifndef COMPONENTS_TRACING_CORE_PROTO_UTILS_H_
6 #define COMPONENTS_TRACING_CORE_PROTO_UTILS_H_ 6 #define COMPONENTS_TRACING_CORE_PROTO_UTILS_H_
7 7
8 #include <inttypes.h> 8 #include <inttypes.h>
9 9
10 #include <type_traits> 10 #include <type_traits>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 template <size_t LENGTH> 88 template <size_t LENGTH>
89 void WriteRedundantVarIntU32(uint32_t value, uint8_t* buf) { 89 void WriteRedundantVarIntU32(uint32_t value, uint8_t* buf) {
90 for (size_t i = 0; i < LENGTH; ++i) { 90 for (size_t i = 0; i < LENGTH; ++i) {
91 const uint8_t msb = (i < LENGTH - 1) ? 0x80 : 0; 91 const uint8_t msb = (i < LENGTH - 1) ? 0x80 : 0;
92 buf[i] = static_cast<uint8_t>((value & 0x7F) | msb); 92 buf[i] = static_cast<uint8_t>((value & 0x7F) | msb);
93 value >>= 7; 93 value >>= 7;
94 } 94 }
95 DCHECK_EQ(0u, value) << "Buffer too short to encode the given value"; 95 DCHECK_EQ(0u, value) << "Buffer too short to encode the given value";
96 } 96 }
97 97
98 template <uint32_t field_id>
99 void StaticAssertSingleBytePreamble() {
100 static_assert(field_id < 16,
101 "Proto field id too big to fit in a single byte preamble");
102 };
103
98 } // namespace proto 104 } // namespace proto
99 } // namespace v2 105 } // namespace v2
100 } // namespace tracing 106 } // namespace tracing
101 107
102 #endif // COMPONENTS_TRACING_CORE_PROTO_UTILS_H_ 108 #endif // COMPONENTS_TRACING_CORE_PROTO_UTILS_H_
OLDNEW
« no previous file with comments | « components/tracing/BUILD.gn ('k') | components/tracing/core/proto_zero_message.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698