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

Side by Side Diff: components/tracing/core/scattered_stream_writer.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
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/logging.h" 10 #include "base/logging.h"
(...skipping 20 matching lines...) Expand all
31 // Due to the tracing buffer being split into fixed-size chunks, on some 31 // Due to the tracing buffer being split into fixed-size chunks, on some
32 // occasions, these writes need to be spread over two (or more) non-contiguous 32 // occasions, these writes need to be spread over two (or more) non-contiguous
33 // chunks of memory. Similarly, when the buffer is backed by the heap, we want 33 // chunks of memory. Similarly, when the buffer is backed by the heap, we want
34 // to avoid realloc() calls, as they might cause a full copy of the contents 34 // to avoid realloc() calls, as they might cause a full copy of the contents
35 // of the buffer. 35 // of the buffer.
36 // The purpose of this class is to abtract away the non-contiguous write logic. 36 // The purpose of this class is to abtract away the non-contiguous write logic.
37 // This class knows how to deal with writes as long as they fall in the same 37 // This class knows how to deal with writes as long as they fall in the same
38 // ContiguousMemoryRange and defers the chunk-chaining logic to the Delegate. 38 // ContiguousMemoryRange and defers the chunk-chaining logic to the Delegate.
39 class TRACING_EXPORT ScatteredStreamWriter { 39 class TRACING_EXPORT ScatteredStreamWriter {
40 public: 40 public:
41 class Delegate { 41 class TRACING_EXPORT Delegate {
42 public: 42 public:
43 virtual ~Delegate();
43 virtual ContiguousMemoryRange GetNewBuffer() = 0; 44 virtual ContiguousMemoryRange GetNewBuffer() = 0;
44 }; 45 };
45 46
46 explicit ScatteredStreamWriter(Delegate* delegate); 47 explicit ScatteredStreamWriter(Delegate* delegate);
47 ~ScatteredStreamWriter(); 48 ~ScatteredStreamWriter();
48 49
49 void WriteByte(uint8_t value); 50 void WriteByte(uint8_t value);
50 void WriteBytes(const uint8_t* src, size_t size); 51 void WriteBytes(const uint8_t* src, size_t size);
51 52
52 // Reserves a fixed amount of bytes to be backfilled later. The reserved range 53 // Reserves a fixed amount of bytes to be backfilled later. The reserved range
(...skipping 29 matching lines...) Expand all
82 ContiguousMemoryRange cur_range_; 83 ContiguousMemoryRange cur_range_;
83 uint8_t* write_ptr_; 84 uint8_t* write_ptr_;
84 85
85 DISALLOW_COPY_AND_ASSIGN(ScatteredStreamWriter); 86 DISALLOW_COPY_AND_ASSIGN(ScatteredStreamWriter);
86 }; 87 };
87 88
88 } // namespace v2 89 } // namespace v2
89 } // namespace tracing 90 } // namespace tracing
90 91
91 #endif // COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_ 92 #endif // COMPONENTS_TRACING_CORE_SCATTERED_STREAM_WRITER_H_
OLDNEW
« no previous file with comments | « components/tracing/core/proto_zero_message.h ('k') | components/tracing/core/scattered_stream_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698