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

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

Issue 2043913006: tracing v2: Add proto_utils.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@tv_ups2
Patch Set: rebase Created 4 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 unified diff | Download patch
« no previous file with comments | « components/tracing/core/proto_utils_unittest.cc ('k') | no next file » | 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_SCATTERED_STREAM_WRITER_H_ 5 #ifndef COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_
6 #define COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_ 6 #define COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "components/tracing/tracing_export.h" 11 #include "components/tracing/tracing_export.h"
12 12
13 namespace tracing { 13 namespace tracing {
14 namespace v2 { 14 namespace v2 {
15 15
16 struct ContiguousMemoryRange { 16 struct ContiguousMemoryRange {
17 uint8_t* begin; 17 uint8_t* begin;
18 uint8_t* end; // STL style: one byte past the end of the buffer. 18 uint8_t* end; // STL style: one byte past the end of the buffer.
19
20 inline bool is_valid() const { return begin != nullptr; }
21 inline void reset() { begin = nullptr; }
22 inline size_t size() { return static_cast<size_t>(end - begin); }
19 }; 23 };
20 24
21 // This class deals with the following problem: append-only proto messages want 25 // This class deals with the following problem: append-only proto messages want
22 // to write a stream of bytes, without caring about the implementation of the 26 // to write a stream of bytes, without caring about the implementation of the
23 // underlying buffer (which concretely will be either the trace ring buffer 27 // underlying buffer (which concretely will be either the trace ring buffer
24 // or a heap-allocated buffer). The main deal is: proto messages don't know in 28 // or a heap-allocated buffer). The main deal is: proto messages don't know in
25 // advance what their size will be. 29 // advance what their size will be.
26 // Due to the tracing buffer being split into fixed-size chunks, on some 30 // Due to the tracing buffer being split into fixed-size chunks, on some
27 // occasions, these writes need to be spread over two (or more) non-contiguous 31 // occasions, these writes need to be spread over two (or more) non-contiguous
28 // chunks of memory. Similarly, when the buffer is backed by the heap, we want 32 // chunks of memory. Similarly, when the buffer is backed by the heap, we want
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 ContiguousMemoryRange cur_range_; 71 ContiguousMemoryRange cur_range_;
68 uint8_t* write_ptr_; 72 uint8_t* write_ptr_;
69 73
70 DISALLOW_COPY_AND_ASSIGN(ScatteredStreamWriter); 74 DISALLOW_COPY_AND_ASSIGN(ScatteredStreamWriter);
71 }; 75 };
72 76
73 } // namespace v2 77 } // namespace v2
74 } // namespace tracing 78 } // namespace tracing
75 79
76 #endif // COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_ 80 #endif // COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_
OLDNEW
« no previous file with comments | « components/tracing/core/proto_utils_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698