Chromium Code Reviews| 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..268f0d7ffd36ee52d1283c0eab074ad42ef9c8d7 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. |
| + template <size_t size> uint8_t* ReserveBytesUnsafe() { |
|
alph
2016/07/30 07:41:14
Why it needs to be a template?
Won't a simple func
Primiano Tucci (use gerrit)
2016/08/04 15:26:54
Fair point. I think I was just thinking to our pre
|
| + 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); |