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

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

Issue 2197563002: tracing v2: minor refactoring to TraceRingBuffer test helpers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: simpler check 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 | « no previous file | components/tracing/core/scattered_stream_writer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/tracing/core/scattered_stream_writer.h
diff --git a/components/tracing/core/scattered_stream_writer.h b/components/tracing/core/scattered_stream_writer.h
index 00af4d70c3a3b56e0ea92b70f51df2503d24d606..8fbf84cbeb2c7330bbc6fb821c8fc130cf01dca7 100644
--- a/components/tracing/core/scattered_stream_writer.h
+++ b/components/tracing/core/scattered_stream_writer.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include "base/logging.h"
#include "base/macros.h"
#include "components/tracing/tracing_export.h"
@@ -52,6 +53,16 @@ class TRACING_EXPORT ScatteredStreamWriter {
// is guaranteed to be contiguous and not span across chunks.
ContiguousMemoryRange ReserveBytes(size_t size);
+ // Fast (but unsafe) version of the above. The caller must have previously
+ // checked that there are at least |size| contiguos bytes available.
+ // Returns only the start pointer of the reservation.
+ uint8_t* ReserveBytesUnsafe(size_t size) {
+ uint8_t* begin = write_ptr_;
+ write_ptr_ += size;
+ DCHECK_LE(write_ptr_, cur_range_.end);
+ return begin;
+ }
+
// Resets the buffer boundaries and the write pointer to the given |range|.
// Subsequent WriteByte(s) will write into |range|.
void Reset(ContiguousMemoryRange range);
« no previous file with comments | « no previous file | components/tracing/core/scattered_stream_writer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698